4

我将 RVM 与 Ruby 1.9.3 p448 一起使用,但是当我尝试运行我的 rails 服务器时,我得到了这个错误(加上其他一些东西)

9): Library not loaded: /Users/sashafklein/.rvm/rubies/ruby-1.9.3-p327/lib/libruby.1.9.1.dylib (LoadError)
      Referenced from: /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle
      Reason: image not found - /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle

奇怪的是,它引用了 ruby​​-1.9.3-p327,它甚至不是我安装的 RVM 之一。我应该删除它没有找到 libruby 的那个 Ruby 文件夹吗?或者还有什么可能是错的?

编辑——完全错误

/Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': dlopen(/Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle, 9): Library not loaded: /Users/sashafklein/.rvm/rubies/ruby-1.9.3-p327/lib/libruby.1.9.1.dylib (LoadError)
  Referenced from: /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle
  Reason: image not found - /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:2:in `<top (required)>'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix-spawn.rb:1:in `<top (required)>'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/albino-1.3.3/lib/albino.rb:1:in `<top (required)>'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
  from /Users/sashafklein/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
  from /Users/sashafklein/rails/<appname>/config/application.rb:12:in `<top (required)>'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
  from /Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

白化宝石似乎在这个底部,但我认为它是应用程序所必需的,所以我不能把它拿出来。我尝试了 gem uninstall albino (没有输出)然后捆绑安装,但这并没有解决任何问题。捆绑更新也是如此,下面是 mpapis 和 sahil 的帮助。

4

1 回答 1

12

当宝石链接错误时可能会发生这种事情,试试这个:

rvm get head
rvm reinstall 1.9.3-p448
rvm use 1.9.3-p448

这将重新安装 ruby​​ 并使所有 gem 保持原始状态,这应该可以防止此类问题发生 - 除非 gem 作者做了一些超出标准 ruby​​ 检测的额外技巧。

更新

使用bundlers 标志--deployment--path并不总是安全的,错误消息说:

/Users/sashafklein/rails/<appname>/vendor/bundle/ruby/1.9.1/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle

这意味着 gem 是用其他 ruby​​ 编译的,现在找不到它。

修复它的最简单方法是停止使用--deployment 标志,因为它是持久化的,摆脱它(以及所有其他潜在危险设置)的最简单方法是:

rm -rf .bundle/ vendor/bundle 
bundle install

解释

Bundler 在运行时过滤 gem 方面做得很好,不幸的是,它使用标志强制执行另一层过滤--deployment,这会强制将 gem 安装到多个 rubies 常见的路径 - 在这种情况下:ruby/1.9.1,这是不安全的,因为 rubies 可以使用不同的设置进行编译这可以破坏不同红宝石中使用的 c 扩展宝石。

于 2013-08-11T06:20:01.973 回答