无法加载此类文件 - unicorn / version(LoadError)

时间:2014-02-03 09:10:26

标签: ruby-on-rails ruby gem rvm unicorn

尝试从WEBrick切换到Unicorn,我已经在我的机器上安装了Unicorn gem v 4.8.1 [通过“gem install unicorn”],它也位于我的Gemfile [“gem”unicorn“,”〜 > 4.8.1“],我已经成功运行了bundle install。

然而,当通过“rails s”在本地启动服务器(在Unicorn之前工作正常)时,我收到以下错误:

...../vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1/lib/unicorn/const.rb:44:in `require': cannot load such file -- unicorn/version (LoadError)
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1/lib/unicorn/const.rb:44:in `<top (required)>'
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1/lib/unicorn.rb:108:in `require'
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1/lib/unicorn.rb:108:in `<top (required)>'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/johndoe/Sites/my_app/config/application.rb:7:in `<top (required)>'
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /Users/johndoe/Sites/my_app/vendor/cache/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>'

我在想这可能是因为使用了RVM?当我输入'哪个宝石'独角兽''我得到:

/Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/bin/gem
/Users/johndoe/.rvm/gems/ruby-1.9.3-p392/bin/unicorn

另外参考我的$ PATH:/Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/bin/gem:/usr/local/rvm/bin:/Users/joh‌​ndoe/.rvm/gems/ruby-1.9.3-p392/bin:/Users/johndoe/.rvm/gems/ruby-1.9.3-p392@globa‌​l/bin:/Users/johndoe/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/johndoe/.rvm/bin:/usr‌​/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin

“捆绑秀独角兽”给出:/Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1

应用程序成功部署到Heroku,因此我认为这个问题与我的机器隔离(而不是应用程序的问题)。关于如何解决这个问题的任何想法?

3 个答案:

答案 0 :(得分:3)

我似乎通过“sudo bundle exec gem uninstall unicorn”卸载gem来解决问题,然后通过标准的“sudo bundle install”重新安装它

仍然不确定问题究竟发生的原因,但修复确实有效。

答案 1 :(得分:0)

你能用这个..

$ rails server unicorn

bundle exec unicorn -p 3000

答案 2 :(得分:-1)

仍不确定导致此问题的原因。

我只是通过重新安装独角兽宝石来解决这个问题 宝石卸载独角兽
捆绑安装
捆绑更新