Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Ruby脚本中需要来自gem的文件,而不需要bundle exec_Ruby_Bundler - Fatal编程技术网

在Ruby脚本中需要来自gem的文件,而不需要bundle exec

在Ruby脚本中需要来自gem的文件,而不需要bundle exec,ruby,bundler,Ruby,Bundler,我有一个脚本,需要在项目Gemfile中定义的gems中使用特定的文件 #!/usr/bin/env ruby require 'some_gem/helpers/some_helper' ... rest of script 当我运行脚本时,我遇到一个错误,即无法加载some\u helper.rb。如果我使用bundle exec命令运行…则一切正常。 我知道bundle exec将Gems公开到$LOAD_路径,该路径允许require工作。是否有办法将该功能移到脚本中,这样用户就不必

我有一个脚本,需要在项目Gemfile中定义的gems中使用特定的文件

#!/usr/bin/env ruby
require 'some_gem/helpers/some_helper'

... rest of script
当我运行脚本时,我遇到一个错误,即无法加载
some\u helper.rb
。如果我使用
bundle exec命令运行…
则一切正常。
我知道bundle exec将Gems公开到$LOAD_路径,该路径允许
require
工作。是否有办法将该功能移到脚本中,这样用户就不必键入
bundle exec

在我需要gem文件之前,我是否只需要向脚本中添加
require“bundler/setup”

:)

你也可以检查一下

#!/usr/bin/env ruby
require 'rubygems' # because reasons.. most probably it is not needed unless you are using really old ruby where it is not loaded by default
                   # also at the moment rubygems and bundler are being merged :) 
require 'bundler/setup' # for things installed with bundler
require 'some_gem/helpers/some_helper'