LoginSignup
31
29

More than 5 years have passed since last update.

warning: already initialized constant APP_PATH というエラーで rails server コマンドが失敗する問題を解決する

Last updated at Posted at 2015-02-19
$ bundle exec rails s
bin/rails:6: warning: already initialized constant APP_PATH

なんじゃこりゃー!

とりあえず rails/spring の Issue を読む。
warning: already initialized constant APP_PATH · Issue #259 · rails/spring

rake rails:update:bin すれば本来の原因が判明するっぽい。

$ bundle exec rake rails:update:bin
rake aborted!
LoadError: cannot load such file -- guard/guard
(stack trace は省略)
LoadError: cannot load such file -- guard-sprockets2
(stack trace は省略)

僕の環境に起きていた問題は guard のバージョンアップによりそのディレクトリ構造が変化したことで、
guard-sprockets2 がそれを正しく require できていないというもののようだ。
そこで、もはや不要だった guard-sprockets2 を Gemfile から削除して bundle install しなおし、その後再度 bin ファイルを生成しなおした。

$ bundle exec rake rails:update:bin
$ bundle exec spring binstub --all
$ bundle exec rails s
=> Booting Thin
=> 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
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop

動くようになった! ✌ ('ω' ✌ )三 ✌ ('ω') ✌ 三( ✌ 'ω') ✌

31
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
29