2016年9月27日火曜日

rubyのバージョンをあげたらrails consoleが起動しなくなった件

rubyのバージョンを2.1.3から2.3.1にあげることになったので、バージョンアップをしたところ、
bundle exec rails cでエラーが出るようになりました。
$ bundle exec rails c
/Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
 from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/commands.rb:33:in `'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/commands.rb:4:in `'
 from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/xxx.rb:140:in `serve'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
 from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `'
 from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from -e:1:in `
'

調べてみると、bundle installでvendor/bundle配下に入れた時に、
springがvendor/bundleのbundlerを読み込もうとしてないよってエラーになっているようです。

更に調べてみると、springの1.6.3で直っているようです。

元のspringのバージョンが以下
$ bundle exec gem list|grep spring
spring (1.1.3)
spring-commands-rspec (1.0.2)

springのバージョンを最新にする
$ bundle update spring
$ bundle exec gem list|grep spring
spring (1.7.2)
spring-commands-rspec (1.0.2)

springを停止してからrails cをしてみると、いろいろメッセージでるけど、ちゃんと起動しました
$ bundle exec bin/spring stop
Spring stopped.
$ bundle exec rails c
Resque::Helpers will be gone with no replacement in Resque 2.0.0.
Running via Spring preloader in process 8207
Loading development environment (Rails 4.1.6)
irb: warn: can't alias context from irb_context.
Cannot read termcap database;
using dumb terminal settings.
irb(main):001:0> 


参考URL
http://qiita.com/koshigoe/items/2304ec081a9f036e8941