
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).
2020/12/16この記事の対象者
- Railsアプリケーションで発生している
- Sidekiq (Redis)を利用している
- Railsコマンドを実行した際に, 以下のエラーが出ている
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).
This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system.
To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.解決策
- rails, redis, sidekiqを全て落とす
- railsアプリケーションのルートディレクトリに移動
bin/spring statusでstatusを確認Sprint is running:の場合,bin/spring stopを実行rm -rf binでRailsアプリケーションのbinディレクトリを削除bundle exec rake app:update:binを実行
これでrailsコマンドが正常に動くようになる.
- 上記を実行した後にrailsコマンドを実行してエラーが発生する場合は, モジュールを再インストールする.
※僕はvendor/bundleにインストールしているため, 下記のコマンドになる
$ rm -rf vendor/bundle
$ bundle install --path vendor/bundleLoadError: cannot load such file -- bootsnap/setup
以下のようなエラーが出た場合は環境をきれいにしてから, 再度解決策を実行する.
$ bundle exec rake app:update:bin
rake aborted!
LoadError: cannot load such file -- bootsnap/setup- を実行した際に,
Using bootsnapのような表示が出る場合は, Railsアプリケーションにbootsnapが入っていない可能性が高い.
僕の場合はrbenvでRubyのバージョンを管理していたため, 利用しているバージョンを再インストールしてから, 1 ~ 7まで実行する.
$ rbenv uninstall 2.6.5
$ rbenv install 2.6.5Twitterフォロー待ってます!