无法激活sinatra-1.4.7,因为rack-2.0.1与rack冲突(〜> 1.5)

时间:2016-08-02 04:57:47

标签: rubygems sinatra rack

我刚刚将我的操作系统从Ubuntu 14.04 LTS更新到16.04,我在那里运行我的Ruby Sinatra项目。事情是在更新后我试图运行服务器然后在浏览器中的localhost我得到了这个错误     引导错误

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'

我已经在包含app.rb的文件夹中尝试了gem install bundle和bundle install。我还在gem文件中放了gem“rack”,“〜&gt; 1.5”,但我仍然有同样的错误。你能帮我么?非常感谢提前

3 个答案:

答案 0 :(得分:16)

当我尝试运行一系列自动化测试时,我遇到了类似的问题(完全相同的错误消息)我维护它不知何故依赖于Sinatra。

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

我在this Japanese (?) blog

上找到了解决方案

卸载rack-2.0.1为我做了诀窍

> 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

答案 1 :(得分:6)

我有同样的问题,rack版本2.0.1是Rails 5的依赖,所以我无法将其删除。所以我发现了一种不同的(更好的?)方式。

确保它在您的Gemfile中:

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

...然后bundle exec <server-start-command>应按预期工作。

答案 2 :(得分:1)

出于某种原因,当我向Gemfile(rspec-sidekiq)添加一个gem而忘记这样做时,就发生了这种情况:

 bundle install