当我在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)
答案 0 :(得分:2)
您正在使用旧版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'