0

我有一个工作的centOS服务器,据我所知,它带有puppet所需的ruby 1.8.7,根据我的作品devops团队,我正在使用需要ruby 1.9+的Sinatra应用程序,他们拒绝使用RVM或rbenv,并坚持为 puppet 保留 1.8.7,因此他们从源代码安装了 1.9.3

/opt/ruby-1.9.3/bin/ruby

对于我的用户,我必须在我的 .bash_profile 中创建一些别名

alias ruby="/opt/ruby-1.9.3/bin/ruby"
alias gem="/opt/ruby-1.9.3/bin/gem"
alias erb="/opt/ruby-1.9.3/bin/erb"
alias bundle="/opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/bin/bundle"
alias rackup="/opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.5.2/bin/rackup"

ruby 可以工作,gem 也可以,但从来没有捆绑器或 rackup,我必须使用普通的 gem install 安装我的 Sinatra 应用程序依赖项,这对我来说没问题。

但是现在我想通过 apache 和乘客 (mod_rails) 为应用程序提供服务,我收到关于未找到 gems 的错误,例如:

Could not find nokogiri-1.5.9 in any of the sources (Bundler::GemNotFound)
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
  /opt/ruby-1.9.3/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
  /opt/ruby-1.9.3/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
  /opt/ruby-1.9.3/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/lib/phusion_passenger/loader_shared_helpers.rb:212:in `run_load_path_setup_code'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:73:in `preload_app'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:127:in `<module:App>'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
  /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:5:in `<main>'

当我尝试使用捆绑器时,我收到此错误:

$ bundle install
/opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:7:in `require': no such file to load -- bundler (LoadError)
    from /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:7

第 7 行文件的内容是:

require 'bundler'

有什么线索吗?提前致谢!

4

1 回答 1

0

我在这里大错特错,指向 bundle 和 rackup 的别名指向了不正确的路径,它们最终是这样的:

alias ruby="/opt/ruby-1.9.3/bin/ruby"
alias gem="/opt/ruby-1.9.3/bin/gem"
alias erb="/opt/ruby-1.9.3/bin/erb"
alias bundle="/opt/ruby-1.9.3/bin/bundle"
alias rackup="/opt/ruby-1.9.3/bin/rackup"

可能将两个 ruby​​ 版本放在一起的别名方法不是最好的方法(记住这里没有 RVM 或 rbenv),但现在可以使用

于 2013-06-20T17:10:02.513 回答