20

Similar to problem with rack 1.3.2. You have already activated rack 1.3.2, but your Gemfile requires rack 1.2.3 -- I'm experiencing You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4 when attempting to run Rails (4.2) in production with Puma and Nginx.

bundle update rake nor rm Gemfile.lock && bundle install seem to help, the only solution I have so far is manually changing rack (1.6.4) to rack (1.6.0) in Gemfile.lock.

Community
  • 1
  • 1
Mark Boulder
  • 13,577
  • 12
  • 48
  • 78
  • 2
    this is similar to your case. http://stackoverflow.com/questions/9241912/how-to-force-rack-to-work-around-the-usual-you-have-already-activated-rack. you have to remove rack version 1.6.0 like this `gem uninstall rack -v 1.6.0` – Athar Aug 02 '15 at 19:58
  • Have you tried binstub? Check the answer below – Anatoly Aug 03 '15 at 13:45
  • 2
    That did indeed to the trick @Athar - tyvm! – Mark Boulder Aug 04 '15 at 15:04

6 Answers6

23

you need to uninstall one version of rack which is not required.

Do this please

gem uninstall rack -v 1.6.0

Reference: How to force rack to work around the usual "You have already activated rack..." bug?

Community
  • 1
  • 1
Athar
  • 3,258
  • 1
  • 11
  • 16
2

One experienced Rails developer highly recommends using binstubs. Have it installed by:

bundle install --binstubs

and run it via relative path:

./bin/rails server

or what is most recommended update PATH and forget about bundler issues:

export PATH="./bin:$PATH"
rails server
Anatoly
  • 15,298
  • 5
  • 53
  • 77
1

Run it like this: bundle exec rails s. This will use settings from your Gemfile.lock

Zepplock
  • 28,655
  • 4
  • 35
  • 50
  • Thanks, but see Athar's comment above. – Mark Boulder Aug 04 '15 at 15:05
  • 1
    No matter how carefully you install or uninstall gems you will end up with multiple versions. Running it is bundle exec is the right way to do it and removes version ambiguity from your deployment – Zepplock Aug 04 '15 at 15:08
  • @Zepplock right, "binstubs" is a way to avoid prepend *bundle exec* all the time – Anatoly Aug 04 '15 at 20:03
1

These issues might arise if you are using local or global gemset for more than one project. Why not create seprate gemset for each project.

You can do this using rvm

Create new gemset

rvm gemset create new_test

rvm gemset use new_test

bundle install
Syed Shibli
  • 992
  • 1
  • 12
  • 15
  • Indeed. Multiple projects was my issue and this is a clean solution. Also, adding #ruby-gemset=new_test to the Gemfile sets the gemset for the project – scottysmalls Aug 29 '19 at 23:37
0

You can simply run below cmd to get the latest rack installed in server to fix the issue:

gem install rack
Ravistm
  • 2,163
  • 25
  • 25
0

I experienced this issue:

Here's my solution:

Solution 1:

This solution works a lot of the time, simply update the gem causing the issue.

bundle update rack

Solution 2:

In some cases Solution 1 may not work, and you will need to edit your Gemfile.lock file.

Simply, open your Gemfile.lock file and then change the version to the update requested.

In my case, I had rack 2.0.7 defined in my Gemfile.lock file, but my application required rack 2.1.2, I simply had to modify it to rack 2.1.2 in the Gemfile.lock file.

I then had to uninstall the previous version of rack which is rack 2.0.7

 gem uninstall rack -v 2.0.7

And finally installed the new gem in production

bundle install --without development test

Solution 3:

In very rare cases Solution 1 and Solution 2 may not work, and you will need to edit your Gemfile before updating the gem.

In my case, the gem was puma, I had puma ~> 3.11 defined in my Gemfile, but my application required puma ~> 4.3.1. At this point running bundle update puma and editing my Gemfile.lock file didn't work, since puma ~> 3.11 version specified in the Gemfile would not allow an update to puma ~> 4.3.1.

I simply had to change the version of puma in the Gemfile to puma ~> 4.3.1 and then ran the command.

bundle update puma

That's all.

I hope this helps

Promise Preston
  • 24,334
  • 12
  • 145
  • 143