読者です 読者をやめる 読者になる 読者になる

[Error] bin/rails:6: warning: already initialized constant APP_PATH [rails]

エラー

rails new でAPPを作成後、rails s で躓いた.

$ rails s
bin/rails:6: warning: already initialized constant APP_PATH
/home/dev1/railbook/bin/rails:6: warning: previous definition of APP_PATH was here

環境

$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ rails -v
Rails 4.2.0

解決

rake rails:update:bin を実行してみる.

$ rake rails:update:bin
(in /home/dev1/railbook)
rake aborted!
LoadError: cannot load such file -- readline
/home/dev1/railbook/config/application.rb:7:in `<top (required)>'
/home/dev1/railbook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

更にエラーが出た. Gemfileに以下の1行を追加する.

gem 'rb-readline'

bundle installする.

$ bundle install

再度rails sを実行してみる

$ rails s
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-02-14 02:17:26] INFO  WEBrick 1.3.1
[2015-02-14 02:17:26] INFO  ruby 2.2.0 (2014-12-25) [x86_64-linux]
[2015-02-14 02:17:26] INFO  WEBrick::HTTPServer#start: pid=1278 port=3000

ok. WEBrickが起動できた.


Ruby on Rails 4 アプリケーションプログラミング

Ruby on Rails 4 アプリケーションプログラミング