0
votes

I have an application running remotely, and I just upgraded rails to version 4.2.8, which upgraded other gems as well. I ran service unicorn restart afterwards, but the log for unicorn gives me this error:

You have already activated unicorn 5.2.0, but your Gemfile requires unicorn 5.3.0. Prepending bundle exec to your command may solve this. (Gem::LoadError)

I have tried gem uninstall unicorn -v 5.2.0, which returned successfully, and then gem install -v 5.3.0, which also returned successfully. Afterwards, I ran service unicorn restart, but the error persists.

I noticed the bundle exec suggestion, but I'm not sure what I should prepend this command to.

4

4 Answers

1
votes

Try deleting your gemfile.lock file, and then running bundle install again, which will repopulate it from scratch, that normally sorts out my gem conflicts.

0
votes

That means that the version of unicorn running on your machine is different than the version specified in your application. service unicorn is probably pointing to unicorn installed on the server/computer not pointing to your apps version of unicorn, right? Then when that starts your application, your app is trying to load a different version of the gem.

You could also run unicorn within the context of your app, like bundle exec unicorn - How to start rails server in production mode using unicorn and config file?.

0
votes

If you have found a solution, good. If not, next time, create a new rails app using a unique gemset like 2.3.1@myapp. This way, when you deploy to a remote server you will avoid this type of gems conflicts.

0
votes

This could be caused by you having two different sources for gems on your machine.

If you use something like RVM with gemsets, make sure you are using the correct gemset. Especially, be sure that your gem install and gem uninstall act upon the application-sepcific gemset and not on the system-wide gems. You can find details at https://rvm.io/gemsets.

Bundler also generates a separate gemset per application. So if you use bundler, you have to run all your commands by prepending them with bundle exec (e.g. bundle exec rspec spec). If you want to remove gems from the bundle, remove it from your Gemfile and run bundle update gem_in_question afterwards (this will also update your Gemfile.lock). You can find more at http://bundler.io/v1.14/guides/using_bundler_in_application.html#executing-commands---bundle-exec.

I hope that this helps to solve your problem.