为什么80%的码农都做不了架构师?>>>   

Mac OS X TextMate 运行 OCaml代码提示出错 Uncaught exception: Invalid_argument("Fl_package_base.query")  
解决办法,修改 ~/Library/Application\ Support/TextMate/Managed/Bundles/OCaml.tmbundle/Support/OCamlMate/run_script.rb 文件

@ocamlc = ARGV[0]
#修改为:
@ocamlc = File.basename(ARGV[0])

搞定。

顺便美化一下输出,对比测试一下效果:

Printf.printf "Hello world\nHello world";;

美化前:

美化后:

输出看上去清晰很多。

最终修改文件:

#!/usr/bin/env ruby18require "#{ENV["TM_SUPPORT_PATH"]}/lib/escape"require 'open3'
require 'cgi'
require 'fcntl'def esc(str)CGI.escapeHTML(str).gsub(/\n/, '<br/>')
endclass UserScriptdef initialize@ocamlc = File.basename(ARGV[0])@srcfile = ARGV[1]@dstfile = ARGV[2]if ENV.has_key? 'TM_FILEPATH' then@path = ENV['TM_FILEPATH']@display_name = File.basename(@path)else@path = '-'@display_name = 'untitled'end@findlibpackages = (ENV['TM_OCAML_FINDLIB_PACKAGES'] || '').strip()@findlib = "ocamlfind"end# looks for the location of the threads librarydef find_threads()possibilities = ['/opt/local/godi/lib/ocaml/std-lib/threads','/usr/local/godi/lib/ocaml/std-lib/threads','/godi/lib/ocaml/std-lib/threads','/opt/local/lib/ocaml/threads','/usr/local/lib/ocaml/threads','/usr/lib/ocaml/threads']possibilities.each() do |p|if File.exists?(p)return pendendreturn ""enddef compilethreadsincludedir = find_threads()# compile itif threadsincludedir != ""command = "#{e_sh @findlib} #{e_sh @ocamlc} -o #{e_sh @dstfile} -I #{e_sh(threadsincludedir)} -package #{e_sh @findlibpackages} -linkpkg str.cma unix.cma threads.cma #{e_sh @srcfile} 2>&1"elsecommand = "#{e_sh @findlib} #{e_sh @ocamlc} -o #{e_sh @dstfile} -package #{e_sh @findlibpackages} -linkpkg str.cma unix.cma #{e_sh @srcfile} 2>&1"endputs "<div style=\"color: #999;border:1px solid #CCC;padding:3px;\">#{command}</div>"puts "<pre style=\"background:#FFF; margin:10px 0; padding: 10px; text-shadow:0 0 2px rgba(0,0,0,0.2);\">"output = `#{command}`onlywarnings = trueif output != ""output.each_line() do |line|if line =~ /^File "(?:.*?)", (line ([0-9]+), characters [0-9]+-[0-9]+):/location, line = $1, $2print "<span>File \"#{@path}\", <a style=\"color: blue;\" href=\"txmt://open?url=file://#{e_url(@path)}&line=#{line}\">#{location}</a>:</span><br/>"elseprint esc(line)if line !~ /^Warning/onlywarnings = falseendendendif !onlywarningsexit 1endendenddef run# run it if the compile suceededstdin, stdout, stderr = Open3.popen3(@dstfile)Thread.new { stdin.write @content; stdin.close } unless ENV.has_key? 'TM_FILEPATH'[stdout, stderr]endattr_reader :display_name, :pathenderror = ""
STDOUT.sync = truescript = UserScript.new
map = {'SCRIPT_NAME'       => script.display_name,'BUNDLE_SUPPORT'    => "file://#{ENV['TM_BUNDLE_SUPPORT'].gsub(/ /, '%20')}",
}
puts DATA.read.gsub(/\$\{([^}]+)\}/) { |m| map[$1] }script.compile
stdout, stderr = script.run
descriptors = [ stdout, stderr ]descriptors.each { |fd| fd.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) }
until descriptors.empty?select(descriptors).shift.each do |io|str = io.readif str.to_s.empty? thendescriptors.delete ioio.closeelsif io == stdout thenprint esc(str)elsif io == stderr thenprint "<span style='color: red'>#{esc str}</span>"elsif io == stack_dump thenerror << strendend
endputs '</pre></div></div>'
puts error
puts '<div id="exception_report" class="framed" style="color: #999;">Program exited.</div>'
puts '</body></html>'__END__
<html><head><title>OCamlMate</title><link rel="stylesheet" href="${BUNDLE_SUPPORT}/pastel.css" type="text/css"></head>
<body><div id="script_output" class="framed" style="font-size:10px;"><strong>OCamlMate</strong><strong>${SCRIPT_NAME}</strong><div id="actual_output" style="word-wrap: break-word;margin-top:3px;">

TextMate的PATH变量里,需要有 ~/.opam/system/bin/ 路径

转载于:https://my.oschina.net/jsk/blog/477148

Mac OS X TextMate 运行 OCaml代码提示出错相关推荐

  1. php os darwin,解决Mac os(10.12.6) 编译php7提示“/usr/lib/system/libsystem_darwin.dylib”找不到...

    直接引用老外的问题描述: I can't install php71 with brew install php71 --with-httpd as an error appears during t ...

  2. 开源免费软件推荐-独立调节mac OS运行App的音量

    title: 开源免费软件推荐-独立调节mac OS运行App的音量 最近考驾照,要刷驾考宝典的课, 移动端刷课效率很低, 于是我从App Store商店下载了iPad版(M1芯片mac OS特供), ...

  3. Mac OS X上获取鼠标事件

    原文地址:http://www.keakon.net/2011/11/10/监听MacOSX的全局鼠标事件 Mac OS X下怎么监听全局的鼠标事件呢? 首先不能错过的是Cocoa Event-Han ...

  4. 监听Mac OS X的全局鼠标事件

    因为Mac OS X下没有给力的鼠标手势软件,所以昨天突然想自己实现个玩玩,便研究了一番怎么监听全局的鼠标事件. 首先不能错过的是Cocoa Event-Handling Guide这篇文档.它详细介 ...

  5. 黑苹果的初安装与升级 VMware12+mac os x 10.9+升级+VMware Tools安装

    此文主要记录黑苹果的安装与升级虚拟机中mac 系统重要步骤.供自己回头查看. 二大步骤:①安装VMware12   ③安装VMware tools(黑苹果需要安装tools才能共享主机文件和设置网络等 ...

  6. MAC OS X 文件系统介绍

    打开Macintosh HD你会发现内中有四个文件夹(一般情况下,隐藏文件夹是不可见的,而且,可能会更多,比如安装xcode后会有developer文件夹). 分别有--应用程序(Applicatio ...

  7. macos模拟器_苹果芯补完计划,iOS终将回归mac OS?

    在过去几年时间里,国内外有越来越多小道消息都在传苹果将为新款Mac改用定制设计的ARM处理器:<彭博社>曾报道,苹果可能于今年开始在 Mac 电脑上改用内部代号为Kalamata的自研处理 ...

  8. mongodb mac安装_在Mac OS X上安装MongoDB

    mongodb mac安装 Today we will install MongoDB on Mac OS X. MongoDB is one of the leading NoSQL databas ...

  9. Mac OS X: 苹果机支持的分区表类型及问题解决

    苹果机支持的分区表类型 Mac系统支持如下三种硬盘分区: GUID 是基于Intel处理器苹果电脑使用的新的分区表, 也叫GUID Partition Table, GPT,是EFI标准的一个部分,详 ...

最新文章

  1. Android移动开发之【Android实战项目】DAY7-项目结构
  2. js 获取中文的拼音
  3. 利用spring AOP注解实现日志管理
  4. Oracle Spatial 翻译第一漳
  5. 如何在vmware虚拟机下挂载windows硬盘
  6. 十、非规则组织分析及其数学模型——锯齿形斜纹组织
  7. linux 创建用户和修改新增用户默认的家目录
  8. twitter数据集_推特宠物数据整理及分析
  9. 人脸关键点:DAN-Deep Alignment Network: A convolutional neural network for robust face alignment
  10. C++基础::string(二)
  11. 【JAVA】线程安全的案例
  12. java分页计算_java分页算法
  13. 为什么企业要招应届生?
  14. PIE-Engine 教程:水稻面积提取1(宿迁市)
  15. CuraEngine三维切片源码编译与解读
  16. 实验4 数据查询-mysql_实验四 数据库查询
  17. asponse.word按模板导出word文档
  18. 大学开设大数据专业,都安排了哪些课程?
  19. Umi部署pages多页面访问配置
  20. android 8 奕骆,【innos奕骆D6000评测】又一待机神器诞生 innos 奕骆D6000评测(全文)_innos 奕骆D6000_手机评测-中关村在线...

热门文章

  1. 简图 新聚合图床源码 自带鉴黄功能
  2. 南昌大学超级计算机,南昌大学-理学院
  3. 商汤发布首份业绩报告,数字经济新拐点,商汤的价值逻辑变了吗?
  4. 男子学比基尼电影派对开泡澡电影院 泡澡电影被赞好创意!
  5. CAD中图框和比例和打印机的纸张尺寸的关系
  6. 不谋全局者 , 不足以谋一域 : 不谋万世者 , 不足以谋一时
  7. Mac版 Adobe PS CC 2019 安装教程
  8. ChatGPT APK 安卓手机 安装包
  9. (详细)华为畅享6S DIG-AL00的usb调试模式在哪里打开的教程
  10. 2019 牛客多校第二场 4/10