如何使用本地安装的gem执行Ruby程序?

Pet*_*r B 3 ruby gem bundler

我已经安装了我的依赖项

bundle package
Run Code Online (Sandbox Code Playgroud)

然后将它们转移到离线服务器并运行:

> bundle install --local
Using mime-types (1.19)
Using rest-client (1.6.7)
Using trollop (1.16.2)
Using bundler (1.1.4)
Your bundle is complete! It was installed into ./vendor/bundle
Run Code Online (Sandbox Code Playgroud)

但是,无法运行该应用程序:

ruby someprogram.rb
/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- trollop (LoadError)
        from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from someprogram.rb:2:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我需要为Ruby指定什么才能运行本地安装的gem?

KL-*_*L-7 6

你在命令bundle exec面前失踪了ruby someprogram.rb.

  • 如果您不想使用bundle exec,也可以使用--binstubs开关指向路径中的目录. - 有关说明,请参阅http://tomafro.net/2012/06/tip-bundler-with-binstubs (2认同)