如何使 ruby ocra 与多个源文件一起工作?
How do I make ruby ocra work with multiple source file?
我正在使用 ocra 将我的 rb 脚本转换为 exe,但如果它有多个源,exe 将显示 LoadError,抱怨找不到其他源文件。
例如,在我的 main.rb
:
require_relative 'lib/user'
# blabla bla
在我用 ocra main.rb
ocra main.rb ./lib/user.rb
打包我的 main 之后,然后在其他地方 运行 main.exe 并且它说 cannot load such file -- lib/user (LoadError)
如何让它与多个来源一起使用?
好的,所以我错过了手册中的 this...
OCRA does not set up the include path. Use $:.unshift File.dirname([=10=])
at the start of your script if you need to 'require' additional source
files from the same directory as your main script.
在我的入口脚本的开头添加了 $:.unshift File.dirname([=10=])
,还将我的 require './somescript'
更改为 require 'somescript'
然后它起作用了
我正在使用 ocra 将我的 rb 脚本转换为 exe,但如果它有多个源,exe 将显示 LoadError,抱怨找不到其他源文件。
例如,在我的 main.rb
:
require_relative 'lib/user'
# blabla bla
在我用 ocra main.rb
ocra main.rb ./lib/user.rb
打包我的 main 之后,然后在其他地方 运行 main.exe 并且它说 cannot load such file -- lib/user (LoadError)
如何让它与多个来源一起使用?
好的,所以我错过了手册中的 this...
OCRA does not set up the include path. Use
$:.unshift File.dirname([=10=])
at the start of your script if you need to 'require' additional source files from the same directory as your main script.
在我的入口脚本的开头添加了 $:.unshift File.dirname([=10=])
,还将我的 require './somescript'
更改为 require 'somescript'
然后它起作用了