简体   繁体   中英

Rails Deployment to Heroku: NoMethodError: undefined method `+' for nil:NilClass

I'm new to Rails but have been working on an app the last few weeks that has been working great in development and in production when I deploy to Heroku.

Today I made some minor changes to my application.css file and now I am getting a "Precompiling assets failed" error when I try to deploy to Heroku. With a NoMethodError: undefined method `+' for nil:NilClass. Running ruby 2.6.5, Rails 6.0.3.1, PG 1.2.3

I've attached the logs below which may or may not be helpful. I obviously don't have the knowledge of how to debug this properly so advice on what might be causing the error is great but failing that, how should I be trying to replicate this error locally and figuring it out?

I've already tried, with no success:

  1. Changing the application.css file to.scss
  2. Adding config.assets.initialize_on_precompile = false to the application.rb file
  3. Reverting to my last successful commit

Thank you!


    Enumerating objects: 78, done.
    Counting objects: 100% (78/78), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (61/61), done.
    Writing objects: 100% (61/61), 5.07 KiB | 519.00 KiB/s, done.
    Total 61 (delta 46), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote:
    remote: -----> Ruby app detected
    remote: -----> Installing bundler 1.17.3
    remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
    remote: -----> Compiling Ruby/Rails
    remote: -----> Using Ruby version: ruby-2.6.5
    remote:
    remote: ###### WARNING:
    remote:
    remote:        Removing `Gemfile.lock` because it was generated on Windows.
    remote:        Bundler will do a full resolve so native gems are handled properly.
    remote:        This may result in unexpected gem versions being used in your app.
    remote:        In rare occasions Bundler may not be able to resolve your dependencies at all.
    remote:        https://devcenter.heroku.com/articles/bundler-windows-gemfile
    remote:
    remote: -----> Installing dependencies using bundler 1.17.3
    remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
    remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64
    -mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
    remote:        Fetching gem metadata from https://rubygems.org/.............
    remote:        Fetching gem metadata from https://rubygems.org/.
    remote:        Resolving dependencies.....
    remote:        Using rake 13.0.1
    remote:        Using concurrent-ruby 1.1.6
    remote:        Using minitest 5.14.1
    remote:        Using thread_safe 0.3.6
    remote:        Using zeitwerk 2.3.0
    remote:        Using builder 3.2.4
    remote:        Using erubi 1.9.0
    remote:        Using mini_portile2 2.4.0
    remote:        Using crass 1.0.6
    remote:        Using rack 2.2.2
    remote:        Using nio4r 2.5.2
    remote:        Fetching websocket-extensions 0.1.5
    remote:        Using mimemagic 0.3.5
    remote:        Using mini_mime 1.0.2
    remote:        Using formtastic_i18n 0.6.0
    remote:        Using method_source 1.0.0
    remote:        Using thor 1.0.1
    remote:        Using kaminari-core 1.2.1
    remote:        Fetching ffi 1.13.0
    remote:        Using tilt 2.0.10
    remote:        Using bcrypt 3.1.13
    remote:        Using msgpack 1.3.3
    remote:        Using bundler 1.17.3
    remote:        Using orm_adapter 0.5.0
    remote:        Using hashids 1.0.5
    remote:        Using pg 1.2.3
    remote:        Using turbolinks-source 5.2.0
    remote:        Fetching i18n 1.8.3
    remote:        Installing websocket-extensions 0.1.5
    remote:        Installing i18n 1.8.3
    remote:        Using tzinfo 1.2.7
    remote:        Using nokogiri 1.10.9
    remote:        Using puma 4.3.5
    remote:        Using rack-test 1.1.0
    remote:        Fetching sprockets 4.0.1
    remote:        Installing sprockets 4.0.1
    remote:        Installing ffi 1.13.0 with native extensions
    remote:        Using warden 1.2.8
    remote:        Using rack-proxy 0.6.5
    remote:        Using marcel 0.3.3
    remote:        Using mail 2.7.1
    remote:        Using bootsnap 1.4.6
    remote:        Using turbolinks 5.2.1
    remote:        Using loofah 2.5.0
    remote:        Using websocket-driver 0.7.2
    remote:        Using activesupport 6.0.3.1
    remote:        Using rails-dom-testing 2.0.3
    remote:        Using rails-html-sanitizer 1.3.0
    remote:        Using globalid 0.4.2
    remote:        Using activemodel 6.0.3.1
    remote:        Using arbre 1.2.1
    remote:        Using jbuilder 2.10.0
    remote:        Using actionview 6.0.3.1
    remote:        Using activejob 6.0.3.1
    remote:        Using activerecord 6.0.3.1
    remote:        Using actionpack 6.0.3.1
    remote:        Using kaminari-actionview 1.2.1
    remote:        Using kaminari-activerecord 1.2.1
    remote:        Using polyamorous 2.3.2
    remote:        Using hashid-rails 1.4.0
    remote:        Using actioncable 6.0.3.1
    remote:        Using activestorage 6.0.3.1
    remote:        Using actionmailer 6.0.3.1
    remote:        Using formtastic 3.1.5
    remote:        Using has_scope 0.7.2
    remote:        Using railties 6.0.3.1
    remote:        Using kaminari 1.2.1
    remote:        Using ransack 2.3.2
    remote:        Using actionmailbox 6.0.3.1
    remote:        Using actiontext 6.0.3.1
    remote:        Using responders 3.0.1
    remote:        Using jquery-rails 4.4.0
    remote:        Using webpacker 4.2.2
    remote:        Using inherited_resources 1.11.0
    remote:        Using devise 4.7.1
    remote:        Using sprockets-rails 3.2.1
    remote:        Using rails 6.0.3.1
    remote:        Fetching sassc 2.4.0
    remote:        Installing sassc 2.4.0 with native extensions
    remote:        Using sassc-rails 2.1.2
    remote:        Using activeadmin 2.7.0
    remote:        Using sass-rails 6.0.0
    remote:        Bundle complete! 18 Gemfile dependencies, 77 gems now installed.
    remote:        Gems in the groups development and test were not installed.
    remote:        Bundled gems are installed into `./vendor/bundle`
    remote:        Post-install message from i18n:
    remote:
    remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
    remote:        But that may break your application.
    remote:
    remote:        If you are upgrading your Rails application from an older version of Rails:
    remote:
    remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
    remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
    remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
    remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
    remote:
    remote:        If you are starting a NEW Rails application, you can ignore this notice.
    remote:
    remote:        For more info see:
    remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
    remote:
    remote:        Removing i18n (1.8.2)
    remote:        Removing sprockets (4.0.0)
    remote:        Removing websocket-extensions (0.1.4)
    remote:        Removing ffi (1.12.2)
    remote:        Removing sassc (2.3.0)
    remote:        Bundle completed (186.51s)
    remote:        Cleaning up the bundler cache.
    remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64
    -mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
    remote: -----> Installing node-v10.15.3-linux-x64
    remote: -----> Installing yarn-v1.16.0
    remote: -----> Detecting rake tasks
    remote: -----> Preparing app for Rails asset pipeline
    remote:        Running: rake assets:precompile
    remote:        yarn install v1.16.0
    remote:        [1/4] Resolving packages...
    remote:        [2/4] Fetching packages...
    remote:        info fsevents@1.2.13: The platform "linux" is incompatible with this module.
    remote:        info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
    remote:        [3/4] Linking dependencies...
    remote:        warning " > webpack-dev-server@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
    remote:        warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
    remote:        [4/4] Building fresh packages...
    remote:        Done in 23.47s.
    remote:        yarn install v1.16.0
    remote:        [1/4] Resolving packages...
    remote:        [2/4] Fetching packages...
    remote:        info fsevents@1.2.13: The platform "linux" is incompatible with this module.
    remote:        info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
    remote:        [3/4] Linking dependencies...
    remote:        warning " > webpack-dev-server@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
    remote:        warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
    remote:        [4/4] Building fresh packages...
    remote:        Done in 5.05s.
    remote:        I, [2020-06-05T05:23:48.123557 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/active_admin-312e30985f3b0561c5db85eaba9b50b1d2c6fcbcff0e0cd5ae0862f13ef86223
    796473.css
    remote:        I, [2020-06-05T05:23:48.123844 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/active_admin-312e30985f3b0561c5db85eaba9b50b1d2c6fcbcff0e0cd5ae0862f13ef86223
    796473.css.gz
    remote:        I, [2020-06-05T05:23:48.124090 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/active_admin/print-312e30cf99cbf27fb92065a9eacd28e6fad48fa72cadaf6e0918790e8d
    35b11d8f99f6.css
    remote:        I, [2020-06-05T05:23:48.124270 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/active_admin/print-312e30cf99cbf27fb92065a9eacd28e6fad48fa72cadaf6e0918790e8d
    35b11d8f99f6.css.gz
    remote:        I, [2020-06-05T05:23:48.124504 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/manifest-312e3075a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb0
    70.js
    remote:        I, [2020-06-05T05:23:48.124686 #791]  INFO -- : Writing /tmp/build_89a8346fedd1ed19bb5329c741888493/public/assets/manifest-312e3075a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb0
    70.js.gz
    remote:        rake aborted!
    remote:        NoMethodError: undefined method `+' for nil:NilClass
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:138:in `etag'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `block in digest_path'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `sub'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `digest_path'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:175:in `block in compile'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:173:in `each'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:173:in `compile'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/rake/sprocketstask.rb:148:in `with_logger'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
    remote:        /tmp/build_89a8346fedd1ed19bb5329c741888493/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
    remote:        Tasks: TOP => assets:precompile
    remote:        (See full trace by running task with --trace)
    remote:
    remote:  !
    remote:  !     Precompiling assets failed.
    remote:  !
    remote:  !     Push rejected, failed to compile Ruby app.
    remote:
    remote:  !     Push failed
    remote: Verifying deploy...
    remote:
    remote: !       Push rejected to ...
    remote:

Here is possible solution: not tried yet, but you should take a look.

https://github.com/rails/sprockets/issues/683

Basically in config/initializers/assets.rb, you need to update the Rails.application.config.assets.version value as well. I dont know how this affects deployment (how to know when to change this value? do we rely on deployment to fail first, then change this?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM