如何使用本地安装的gem来执行Ruby程序? [英] How to execute Ruby program with locally installed gems?
本文介绍了如何使用本地安装的gem来执行Ruby程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用
捆绑包
$ p安装了我的依赖关系
$ b然后将它们转移到离线服务器并运行:
> bundle install --local
使用mime-types(1.19)
使用rest-client(1.6.7)
使用trollop(1.16.2)
使用bundler(1.1.4 )
您的套餐已完成!它被安装到./vendor/bundle
然而,它不可能运行应用程序:
ruby someprogram.rb
/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb: 36:在'require'中:无法加载这样的文件 - trollop(LoadError)
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'
从someprogram.rb:2:在< main>'
我需要指定什么到Ruby能够运行本地安装的宝石?
解决方案您缺少
bundle exec
c> ruby someprogram.rb 命令。I have installed my dependencies using
bundle package
Then transferred them to the offline server and running:
> 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
However, it is not possible to run the application:
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>'
What do I need to specify to Ruby to be able to run locally installed gems?
解决方案You're missing
bundle exec
in front of yourruby someprogram.rb
command.这篇关于如何使用本地安装的gem来执行Ruby程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文