【问题标题】:Unable to activate sinatra-contrib gem无法激活 sinatra-contrib gem
【发布时间】:2012-07-31 17:38:56
【问题描述】:

当我在 Sinatra forked 应用程序中运行 ruby application.rb 时,我在控制台中运行:

~/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate sinatra-contrib-1.3.1, because sinatra-1.4.0 conflicts with sinatra (~> 1.3.0) (Gem::LoadError)

看到:

bundle show sinatra
~/.rvm/gems/ruby-1.9.3-p194/bundler/gems/sinatra-b18310f73635

# Gemfile
source :rubygems
gem 'sinatra', git: 'https://github.com/juanpastas/sinatra.git'

bundle exec ruby application.rb 
application.rb:2:in `require': cannot load such file -- sinatra/content_for (LoadError)

如果我将 gem 'sinatra-contrib' 添加到 Gemfile,然后运行 ​​bundle,我会得到:

Bundler could not find compatible versions for gem "sinatra":
  In Gemfile:
    sinatra-contrib (>= 0) ruby depends on
      sinatra (~> 1.3.0) ruby

    sinatra (1.4.0)

【问题讨论】:

  • 你试过在require之前添加gem 'sinatra'吗?
  • 我试过了,但没有。顺便说一句,$LOAD_PATH 包含 ~/.rvm/gems/ruby-1.9.3-p194/bundler/gems/sinatra-b18310f73635/lib

标签: rubygems sinatra rvm bundler


【解决方案1】:

你使用的是旧版本的sinatra-contrib,切换到git版本:

source :rubygems
gem 'sinatra', git: 'https://github.com/juanpastas/sinatra.git'
gem 'sinatra-contrib', git: 'https://github.com/sinatra/sinatra-contrib.git'

【讨论】:

  • 我认为~> 表示任何版本greater than 1.3,它表示greater or equal to 1.3 and less than 1.4(bundler help)。谢谢你帮助我。
猜你喜欢
  • 2015-06-07
  • 2012-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-12
  • 2018-06-21
  • 2011-11-10
  • 1970-01-01
相关资源
最近更新 更多