Search code examples
ruby-on-railsherokuinternationalization

NoMethodError: undefined method `unsafe_load' for Psych:Module (I18n::InvalidLocaleData)


I have a rails app hosted on Heroku. For some reason, the app crashed and running rails console into the heroku console gives this error although the app is not multilingual, so no use of I18n at all.

Do you have any idea what is wrong?

1: from /app/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.10/lib/i18n/backend/base.rb:241:in `load_yml'
/app/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.10/lib/i18n/backend/base.rb:245:in `rescue in load_yml': can not load translations from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.2/lib/active_support/locale/en.yml: #<NoMethodError: undefined method `unsafe_load' for Psych:Module (I18n::InvalidLocaleData)

I don't get such an error on localhost, only on Heroku.


Solution

  • At least in my installation, the difference between the working Gemfile.lock and non-working, is the version of bootsnap:

    --- Gemfile.lock        2021-08-26 23:12:52.090787013 -0400
    +++ Gemfile.lock.bad    2021-08-26 23:07:36.116432150 -0400
    @@ -198,7 +198,7 @@
           aws-eventstream (~> 1, >= 1.0.2)
         bcrypt (3.1.16)
         bindex (0.8.1)
    -    bootsnap (1.7.7)
    +    bootsnap (1.8.0)
           msgpack (~> 1.0)
         bootstrap (4.6.0)
           autoprefixer-rails (>= 9.1.0)
    

    There must be an incompatibility buried somewhere in the dependencies of that gem. That's my guess anyway.