Rails Heroku 部署:预编译资源失败。SassC::SyntaxError

Rails Heroku deploy: Precompiling assets failed. SassC::SyntaxError

提问人:whitemystyle 提问时间:11/16/2023 最后编辑:whitemystyle 更新时间:11/18/2023 访问量:44

问:

在部署到 heroku RoR 项目期间,我收到错误“预编译资产失败”。

我试图找到带有“calc(100vh - 110px)”的css代码,但在项目中没有找到任何东西。

可能是什么问题?谢谢

remote: -----> Installing node-v20.9.0-linux-x64
remote: -----> Installing yarn-v1.22.19
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        yarn install v1.22.19
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        [3/4] Linking dependencies...
remote:        warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        [4/4] Building fresh packages...
remote:        Done in 15.09s.
remote:        rake aborted!
remote:        SassC::SyntaxError: Error: "calc(100vh - 110px)" is not a number for `min'
remote:                on line 1:30534 of stdin, in function `min`
remote:                from line 1:30534 of stdin
remote:        >> x;flex:1;flex-direction:column;max-height:min(650px,calc(100vh - 110px));ove
remote:           ------------------------------------------^
remote:        stdin:1

我确实尝试运行rails assets:precompile:

    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:20: warning: already initialized constant Pathname::TO_PATH
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:20: warning: previous definition of TO_PATH was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:22: warning: already initialized constant Pathname::SAME_PATHS
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:22: warning: previous definition of SAME_PATHS was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:34: warning: already initialized constant Pathname::SEPARATOR_LIST
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:34: warning: previous definition of SEPARATOR_LIST was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:35: warning: already initialized constant Pathname::SEPARATOR_PAT
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:35: warning: previous definition of SEPARATOR_PAT was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:41: warning: already initialized constant Pathname::ABSOLUTE_PATH
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:41: warning: previous definition of ABSOLUTE_PATH was here
    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    yarn install v1.22.15
    warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
    [1/4] 🔍  Resolving packages...
    success Already up-to-date.
    ✨  Done in 0.15s.
    Warning: you are using an unstable release of Node.js (v21.2.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node
    Everything's up-to-date. Nothing to do

我也试过了: RAILS_ENV=production rails assets:precompile

olegmishyn@MacBook-Air-Oleg learnician % RAILS_ENV=production rails assets:precompile SECRET_KEY_BASE='07788fabf3594bf7c2d898acfd331bb39294bb613c2609e9d2966cd5593a3cb0131be5ce5165de67a10f24ade4bf45e5d74e80104beb79404f0f441b93e46eff'

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:20: warning: already initialized constant Pathname::TO_PATH
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:20: warning: previous definition of TO_PATH was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:22: warning: already initialized constant Pathname::SAME_PATHS
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:22: warning: previous definition of SAME_PATHS was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:34: warning: already initialized constant Pathname::SEPARATOR_LIST
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:34: warning: previous definition of SEPARATOR_LIST was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:35: warning: already initialized constant Pathname::SEPARATOR_PAT
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:35: warning: previous definition of SEPARATOR_PAT was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:41: warning: already initialized constant Pathname::ABSOLUTE_PATH
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:41: warning: previous definition of ABSOLUTE_PATH was here
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
yarn install v1.22.15
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.15s.
rails aborted!
SassC::SyntaxError: Error: "calc(100vh - 110px)" is not a number for `min'
        on line 1:30534 of stdin, in function `min`
        from line 1:30534 of stdin
>> x;flex:1;flex-direction:column;max-height:min(650px,calc(100vh - 110px));ove
   ------------------------------------------^

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Ruby-on-Rails Heroku 编译 资源

评论

0赞 Greg 11/16/2023
你有没有在本地尝试过,如果没有失败,你可以尝试吗?(请用这些详细信息更新您的问题)rails assets:precompileRAILS_ENV=production rails assets:precompile
0赞 whitemystyle 11/16/2023
@Greg更新,谢谢
0赞 whitemystyle 11/16/2023
@Greg使用密钥更新了命令并出现相同的错误
0赞 Greg 11/16/2023
我建议首先处理这个警告:.你知道你的项目是否应该使用纱线吗?Your project contains lock files generated by tools other than Yarn
0赞 whitemystyle 11/17/2023
@Greg通过将 config.assets.css_compressor = nil 添加到 application.rb 和 production.rb + 将 node.js 版本更改为 “engines”: { “node”: “16.13.1” } 在 package.json 中修复了它

答:

1赞 whitemystyle 11/18/2023 #1

通过将 config.assets.css_compressor = nil 添加到 application.rb 和 production.rb + 将 node.js 版本更改为 “engines”: { “node”: “16.13.1” } 在 package.json 中修复了它