1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Railsバージョンアップ時の LoadError: Unable to autoload constant ActiveStorage::Blob::Analyzable のエラー対応

Last updated at Posted at 2021-04-08

現象

Railsのライセンス問題対応のためv5.2.2.1からv5.2.5に更新したら、capで以下のエラーがでました。

参考:Railsのライセンス問題
https://github.com/rails/rails/releases/tag/v5.2.5

02:15 whenever:update_crontab
      01 /usr/local/rbenv/bin/rbenv exec bundle exec whenever --update-crontab XXXX 
      01 bundler: failed to load command: whenever (/var/www/XXXX/shared/bundle/ruby/2.4.0/bin/whenever)
      01 LoadError: Unable to autoload constant ActiveStorage::Blob::Analyzable, expected /var/www/XXXX/shared/bundle/ruby/2.4.0/gems/activestorage-5.2.5/app/models/active_storage/blob/analyzable.rb to define it
      01   /var/www/XXXX/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.5/lib/active_support/dependencies.rb:511:in `load_missing_constant'
      01   /var/www/XXXX/shared/bundle/ruby/2.4.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:43:in `load_missing_constant'
      01   /var/www/XXXX/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.5/lib/active_support/dependencies.rb:195:in `const_missing'
      01   /var/www/XXXX/shared/bundle/ruby/2.4.0/gems/activestorage-5.2.5/app/models/active_storage/blob.rb:21:in `<class:Blob>'

(一部伏せ字に改変してます)

解決法

検索してでてくる解決方法では、エラーがとれずハマってしまたったのですが、
近い環境を再現して、同様のrakeコマンドを発行したら、以下のエラーが原因であることがわかりました。

Caused by:
Gem::LoadError: can't activate aws-sdk-s3 (~> 1.48), already activated aws-sdk-s3-1.46.0. Make sure all dependencies are added to Gemfile.

Gemfile内のaws-sdk-s3 のバージョンを指定したら解決しました

- gem 'aws-sdk-s3'
+ gem 'aws-sdk-s3', '1.48'
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?