1

几天来,我一直在为 Rails 应用程序苦苦挣扎。我尽我所能,问了一些关于 SO 的问题,并试图收集我能收集到的所有信息和技巧。这是摘要:

几天前,当我运行时rails s,我知道我删除了 ruby​​-2.0.0-p0,得到以下信息:

`require': dlopen(/Users/git/gitlab/vendor/bundle/ruby/2.0.0/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle, 9): Library not loaded: /home/.rvm/rubies/ruby-2.0.0-p0/lib/libruby.2.0.0.dylib (LoadError)
      Referenced from: /Users/git/gitlab/vendor/bundle/ruby/2.0.0/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle
      Reason: image not found - /Users/git/gitlab/vendor/bundle/ruby/2.0.0/gems/posix-spawn-0.3.6/lib/posix_spawn_ext.bundle

有人告诉我这可能与 RVM 有关。我从 RVM 切换到 rbenv,并卸载/重新安装了 Ruby(不是内置的 OS X)和 Rails,运行时得到了相同的消息rails s

然后我完全卸载并删除了 Macports 并再次尝试使用 rbenv 并得到相同的消息。

我试图符号链接/home/.rvm/rubies/ruby-2.0.0-p0/lib/libruby.2.0.0.dylib/usr/local,我得到了同样的信息。

我试着玩出口DYLD_LIBRARY_PATH,但我得到了同样的信息。

我卸载了 rbenv、Rails,然后返回到 Macports 和 RVM,但仍然收到相同的消息。

有人可以帮忙吗?

我正在使用 OS X。

ruby -v outputs ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0] rails -v outputs Rails 3.2.13

我删除了 ruby​​-2.0.0-p0。


编辑:

grep rvm ~/.bashrc输出:

PATH=$HOME/.rvm/bin:$PATH # Add RVM to PATH for scripting

grep rvm ~/.bash_profile输出:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

echo $PATH输出:

/home/.rvm/gems/ruby-2.0.0-p195/bin:/home/.rvm/gems/ruby-2.0.0-p195@global/bin:/home/.rvm/rubies/ruby-2.0.0-p195/bin:/home/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Applications/MAMP/bin/php/php5.4.4/bin:/usr/local/ActivePerl-5.16/site/bin:/usr/local/ActivePerl-5.16/bin:/usr/local/mysql/bin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/ant/bin:/usr/local/mongodb/bin:/home/bin:/Users/otherhome/Desktop/Sites/apache-ant/bin:/usr/local/bro/bin:/opt/bro/bin

gem env输出:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-05-14 patchlevel 195) [x86_64-darwin12.4.0]
  - INSTALLATION DIRECTORY: /home/.rvm/gems/ruby-2.0.0-p195
  - RUBY EXECUTABLE: /home/.rvm/rubies/ruby-2.0.0-p195/bin/ruby
  - EXECUTABLE DIRECTORY: /home/.rvm/gems/ruby-2.0.0-p195/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /home/.rvm/gems/ruby-2.0.0-p195
     - /home/.rvm/gems/ruby-2.0.0-p195@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

rvm info输出:

system:
    uname:       "Darwin MacBook-Pro-de-moi.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64"
    system:      "osx/10.8/x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)"
    zsh:         "/bin/zsh => zsh 4.3.11 (i386-apple-darwin12.0)"

  rvm:
    version:      "rvm 1.21.7 () by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "13 hours 8 minutes 18 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "2.0.0p195"
    date:         "2013-05-14"
    platform:     "x86_64-darwin12.4.0"
    patchlevel:   "2013-05-14 revision 40734"
    full_version: "ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]"

  homes:
    gem:          "/home/.rvm/gems/ruby-2.0.0-p195"
    ruby:         "/home/.rvm/rubies/ruby-2.0.0-p195"

  binaries:
    ruby:         "/home/.rvm/rubies/ruby-2.0.0-p195/bin/ruby"
    irb:          "/home/.rvm/rubies/ruby-2.0.0-p195/bin/irb"
    gem:          "/home/.rvm/rubies/ruby-2.0.0-p195/bin/gem"
    rake:         "/home/.rvm/gems/ruby-2.0.0-p195@global/bin/rake"

  environment:
    PATH:         "/home/.rvm/gems/ruby-2.0.0-p195/bin:/home/.rvm/gems/ruby-2.0.0-p195@global/bin:/home/.rvm/rubies/ruby-2.0.0-p195/bin:/home/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Applications/MAMP/bin/php/php5.4.4/bin:/usr/local/ActivePerl-5.16/site/bin:/usr/local/ActivePerl-5.16/bin:/usr/local/mysql/bin:/sw/bin:/sw/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/ant/bin:/usr/local/mongodb/bin:/home/bin:/Users/otherhome/Desktop/Sites/apache-ant/bin:/usr/local/bro/bin:/opt/bro/bin"
    GEM_HOME:     "/home/.rvm/gems/ruby-2.0.0-p195"
    GEM_PATH:     "/home/.rvm/gems/ruby-2.0.0-p195:/home/.rvm/gems/ruby-2.0.0-p195@global"
    MY_RUBY_HOME: "/home/.rvm/rubies/ruby-2.0.0-p195"
    IRBRC:        "/home/.rvm/rubies/ruby-2.0.0-p195/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

which ruby输出:

/home/.rvm/rubies/ruby-2.0.0-p195/bin/ruby
4

1 回答 1

3

您的 rails 认为它​​应该使用--deployment/ 或--path来自 bundler - 这是通往 gems: 的路径/Users/git/gitlab/vendor/bundle/ruby/2.0.0/gems,不幸的是,bundler 足够聪明并且无法正确处理 ruby​​ 中的更改,您需要再次删除整个rm -rf /Users/git/gitlab/vendor/bundle目录bundle install

我建议您停止使用捆绑器中的--deployment/ 或--path标志,删除目录rm -rf /Users/git/gitlab/vendor/bundlerm -rf /Users/git/gitlab/.bundle/并在 gemset 中安装 gem,这样这个问题就不会再发生了。

在 capistrano 部署的情况下,将此标志设置为bundler/capistrano

set :bundle_dir, ''
set :bundle_flags, '--system --quiet'

防止在捆绑器中使用--deployment--path标记。

于 2013-07-10T02:52:38.253 回答