【问题标题】:Library not loaded error -- wrong ruby库未加载错误 - 错误的 ruby
【发布时间】:2013-08-11 03:04:32
【问题描述】:

我正在使用带有 Ruby 1.9.3 p448 的 RVM,但是当我尝试运行我的 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 的帮助。

【问题讨论】:

  • 这个老问题对stackoverflow.com/questions/11287274/…有帮助吗
  • 我希望你在启动你的 Rails 服务器之前做了rvm use ruby_version_you_want_to_use --default
  • 嗯。我尝试安装 p327,就像原始海报一样,但没有成功。然后我尝试重新安装我的捆绑包。然后我注释掉了有问题的宝石,但这没有用。 RVM 默认使用正确的 ruby​​。

标签: ruby-on-rails ruby rvm


【解决方案1】:

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

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 可以使用不同的设置进行编译,这可能会破坏不同 ruby​​ 中使用的 c-extension gem。

【讨论】:

  • 谢谢!但很可惜,问题仍然存在。我认为这是 gem 的问题——无论出于何种原因,它似乎都特别需要 p327。虽然这适用于我的另一台计算机。不记得它使用的是什么红宝石版本。无论如何,我会在上面发布完整的错误。也许那里有一些不明显的东西。
  • 一开始我错过了,用修复和描述更新了我的答案
猜你喜欢
  • 2014-07-25
  • 2018-04-17
  • 2011-05-09
  • 1970-01-01
  • 2023-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多