我正在使用 OCRA 从我的 ruby 文件中制作一个 exe。.exe 创建工作没有任何错误,但是当我尝试启动它时,我得到了这个:
C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `chdir': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)
No such file or directory @ dir_chdir - C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/gems/2.1.0/gems/json-1.8.2/ext/json/ext/generator
Gem files will remain installed in C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/gems/2.1.0/gems/json-1.8.2 for inspection.
Results logged to C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/json-1.8.2/gem_make.out
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `block in build_extension'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `synchronize'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `build_extension'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from filename.rb:1:in `<top (required)>'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/src/runThemAll.rb:3:in `load'
from C:/Users/XX/AppData/Local/Temp/ocr81CD.tmp/src/runThemAll.rb:3:in `<main>'
所以,正如你所看到的,我在文件上有一个正确的问题,但我不知道哪些问题。另外,我在我的exe中包含的一个文件(filename.rb)中有一个问题,但是当我单独启动它时,这个文件运行得很好......
所以我真的不明白我在这里的问题是什么。我在 Windows 7 上,使用 ruby 2.1。
如果你能给我一个提示,我将非常感激!
编辑:代码
runThemAll.rb
$:.unshift File.dirname($0)
load 'filename.rb'
load 'filename2.rb'
require 'securerandom'
文件名1.rb
require 'Watir'
require 'csv'
require 'mechanize'
#here some code
文件名2.rb
require 'Watir'
require 'csv'
require 'mechanize'
#here some code too
我用来制作 exe 的命令行:
ocra runThemAll.rb