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

Sinatraで、

$ rackup -p 4567
/Users/mk/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2288:in `raise_if_conflicts': Unable to activate sinatra-1.4.7, because rack-2.0.1 conflicts with rack (~> 1.5) (Gem::ConflictError)
	from /Users/mk/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1408:in `activate'
	from /Users/mk/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems.rb:200:in `rescue in try_activate'
	from /Users/mk/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems.rb:193:in `try_activate'
...以下省略

として表題のように怒られるときの対処法です。特にバージョン指定せずに gem install rack とするとsinatraとのバージョンが合わないようなので、

$ gem uninstall rack

Select gem to uninstall:
 1. rack-1.6.4
 2. rack-2.0.1
 3. All versions
> 2
Successfully uninstalled rack-2.0.1
$ rackup -v
Rack 1.3 (Release: 1.6.4)

↑上記のようにして新しい方のrackを消します。

↓動かしてみます。
$ rackup -p 4567
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop

↑OKですね!

Bookmark the permalink.

Comments are closed.