Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to activate sinatra-1.4.7, because rack-2.0.1 conflicts with rack (~> 1.5)

I Just updated my OS from Ubuntu 14.04 LTS to 16.04, and I was running my Ruby Sinatra project in there. The thing is after the update I tried to ran The server and then localhost in browser I got this error Boot Error

Something went wrong while loading app.rb
Gem::ConflictError: Unable to activate sinatra-1.4.7, because rack-2.0.1 conflicts with rack (~> 1.5)

/usr/lib/ruby/2.3.0/rubygems/specification.rb:2286:in `raise_if_conflicts'
/usr/lib/ruby/2.3.0/rubygems/specification.rb:1407:in `activate'
/usr/lib/ruby/2.3.0/rubygems.rb:196:in `rescue in try_activate'
/usr/lib/ruby/2.3.0/rubygems.rb:193:in `try_activate'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:125:in `rescue in require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/home/leandro/Downloads/git-master/ruby sinatra/app.rb:1:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:115:in `inner_app'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:103:in `assemble_app'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:86:in `proceed_as_child'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:31:in `call!'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:18:in `call'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/favicon.rb:12:in `call'
/var/lib/gems/2.3.0/gems/shotgun-0.9.1/lib/shotgun/static.rb:14:in `call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/urlmap.rb:68:in `block in call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/urlmap.rb:53:in `each'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/urlmap.rb:53:in `call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:153:in `call'
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/handler/webrick.rb:86:in `service'
/usr/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
/usr/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
/usr/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

I already tried gem install bundle and bundle install inside the folder that contains app.rb. I also put gem "rack", "~> 1.5" in the gem file but I still have the same error. Can you please help me? thanks a lot in advance

like image 810
Leandro Gabrielli Avatar asked Aug 02 '16 04:08

Leandro Gabrielli


2 Answers

I had a similar problem (exactly the same error message) today when trying to run a suite of automated tests I'm maintaining that somehow depend on Sinatra.

Gem::ConflictError: Unable to activate sinatra-1.4.7, because rack-2.0.1 conflicts with rack (~> 1.5)

I found a solution on this Japanese (?) blog

Uninstalling rack-2.0.1 did the trick for me

> gem uninstall rack

Select gem to uninstall:
 1. rack-2.0.1
 2. rack-1.6.4
 3. All versions

> 1

Successfully uninstalled rack-2.0.1
like image 83
toniedzwiedz Avatar answered Nov 22 '22 06:11

toniedzwiedz


I have the same problem, and rack version 2.0.1 is a dependecy of Rails 5, so I can't remove it. So I found a different (better?) way around it.

Make sure this is in your Gemfile:

gem 'rack', '<2.0'
gem 'sinatra'

... then bundle exec <server-start-command> should work as expected.

like image 33
Jim Meyer Avatar answered Nov 22 '22 07:11

Jim Meyer