2012-07-02 68 views
3

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

bundle package 

我已经安装了依赖然后将它们转移到离线服务器,并运行:

> 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 

但是,这是不可能来运行应用程序:

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>' 

我需要指定哪些Ruby才能运行本地安装的gems?

+0

>宝石环境 RubyGems的环境: - RubyGems的VERSION:23年8月1日 - RUBY VERSION:1.9.3(2012-04-20 PATCHLEVEL 194)[x86_64的Linux的] - 安装目录:在/ usr /本地/ LIB /红宝石/宝石/ 1.9.1 - Ruby可执行文件:在/ usr/local/bin目录/红宝石 - 可执行文件目录:在/ usr/local/bin目录 - RubyGems的平台: - 红宝石 - x86_64的Linux的 - GEM PATHS : - /usr/local/lib/ruby/gems/1.9.1 - /root/.gem/ruby/1.9.1 –

+0

>宝石名单 *** LOCAL GEMS *** 的BigDecimal(1.1.0) 捆绑(1.1.4) IO-控制台(0.3) JSON(1.5.4) MINITEST(2.5.1) 耙(0.9.2.2) 的RDoc(3.9.4) –

+1

我想你在'ruby someprogram.rb'命令前缺少['bundle exec'](http://gembundler.com/man/bundle-exec.1.html)。 –

回答

6

您在ruby someprogram.rb命令前缺少bundle exec

+2

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