2015-04-02 32 views
4

試圖運行一個應用程序末日,我不斷收到此錯誤:西納特拉錯誤:無法激活西納特拉-的contrib-1.4.2

/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中也是如此,但沒有奏效。
任何想法?

回答

2

在我的Gemfile指定此:

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

和運行

bundle update 

固定對我來說。

+0

我會嘗試這個,謝謝。出於某種原因,我在我的Gemfile.lock中顯示了兩個Tilt版本。一個是獨立的,一個是Sinatra的依賴。如果我卸載版本2.0.1(最新更新)應用程序運行,但每次捆綁更新,我必須卸載更新版本的Tilt。 – 2015-04-06 16:12:46

+0

'bundle update'重新解析了gem依賴關係並重寫了你的Gemfile.lock。在運行它之前,請確保您的Gemfile中只包含您需要的寶石,這將確保您只有需要的傾斜版本。祝你好運:) – DaveStephens 2015-04-06 17:07:30

+0

@MatthewSmith你是怎麼過的? – DaveStephens 2015-04-11 11:00:11

4

我有同樣的問題。我刪除了傾斜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