【问题标题】:Sinatra Error: Unable to activate sinatra-contrib-1.4.2Sinatra 错误:无法激活 sinatra-contrib-1.4.2
【发布时间】:2015-06-07 21:20:13
【问题描述】:

尝试运行 Sinatra 应用程序,但我不断收到此错误:

/Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:2064:in `raise_if_conflicts': 
Unable to activate sinatra-contrib-1.4.2, because tilt-2.0.1 conflicts with tilt (~> 1.3) (Gem::LoadError)
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1262:in `activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:196:in `rescue in try_activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:193:in `try_activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from app.rb:3:in `<main>'

这是我的 Gemfile:

gem 'sinatra', '~> 1.4.5'
gem 'activerecord'
gem 'pg'

我试过包括

gem 'tilt', '~> 1.3' 

在 Gemfile 中也是如此,但这不起作用。
有什么想法吗?

【问题讨论】:

    标签: ruby rubygems sinatra sinatra-activerecord


    【解决方案1】:

    在我的 Gemfile 中指定:

    gem 'sinatra-contrib', github: 'sinatra/sinatra-contrib'
    

    正在运行

    bundle update
    

    帮我修好了。

    【讨论】:

    • 我会试试这个,谢谢。出于某种原因,我的 Gemfile.lock 中显示了两个版本的 Tilt。一个独立,一个作为 Sinatra 依赖项。如果我卸载 2.0.1 版(最新更新),应用程序会运行,但每次我捆绑更新时,我都必须卸载 Tilt 的更新版本。
    • bundle update 重新解析 gem 依赖关系并重写您的 Gemfile.lock。在你运行它之前,确保你的 Gemfile 中只有你需要的 gem,这应该确保你只有你需要的倾斜版本。祝你好运:)
    • @MatthewSmith 你过得怎么样?
    • @MatthewSmith,由于某种原因,bundler 卡在这一步:“Fetching git://github.com/sinatra/sinatra-contrib.git”
    【解决方案2】:

    我遇到了同样的问题。我删除了 Tilt 2.0.1,我的应用程序按预期工作。

    移除宝石:

    $ gem uninstall tilt -v 2.0.1
    Successfully uninstalled tilt-2.0.1
    
    $ bundle install
    Resolving dependencies...
    ...
    Bundle complete! 9 Gemfile dependencies, 17 gems now installed.
    Use `bundle show [gemname]` to see where a bundled gem is installed.
    

    重新启动的应用程序(通过 Pow):

    ~/app-dir$ touch tmp/restart.txt
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-13
      • 1970-01-01
      • 2016-12-07
      • 1970-01-01
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 2014-12-01
      相关资源
      最近更新 更多