Question

Attempting to switch from WEBrick to Unicorn, I've got the Unicorn gem v 4.8.1 installed on my machine [via "gem install unicorn"] and it's also located in my Gemfile ["gem "unicorn", "~> 4.8.1"], for which I've successfully run bundle install.

However, when starting the server locally via "rails s" (worked fine pre-Unicorn), I get the following error:

...../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>'

I'm thinking this may be due to using RVM? When I type 'which gem "unicorn"' I get:

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

Also for reference, my $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

"bundle show unicorn" gives: /Users/johndoe/Sites/my_app/vendor/cache/ruby/1.9.1/gems/unicorn-4.8.1

The application successfully deploys to Heroku, so I believe this issue is isolated to my machine (rather than being an issue with the application). Any ideas on how to solve this?

Was it helpful?

Solution

I seemed to fix the problem by uninstalling the gem via "sudo bundle exec gem uninstall unicorn", then reinstalling it via standard "sudo bundle install"

Still not sure exactly why the issue occurred, but that fix did seem to work.

OTHER TIPS

Can you used this..

$ rails server unicorn

or

bundle exec unicorn -p 3000

Still not sure what caused this problem.

I solved this simply by reinstalling the unicorn gem.

gem uninstall unicorn
bundle install
bundle update

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top