【问题标题】:Precompiling assets failed - remote rejected预编译资产失败 - 远程拒绝
【发布时间】:2021-06-04 22:26:36
【问题描述】:

我一直在四处寻找,试图找出 Heroku 不“接受”我的部署并寻求帮助的原因。我没有做任何重要的事情,只是添加了引导程序和一些编辑。我的第一次部署是成功的,但下一次失败了。我在某处读到这是一个错误,所以我添加了一个 src 文件夹并制作了一个 index.js 文件。运行 yarn update,运行 bundle install 以防我需要更新一些东西。查看了我的 babel.config.js,但没有什么突出的(我真的不知道要寻找什么)任何帮助都非常感谢!

错误:

  [4/4] Building fresh packages...
remote:        Done in 25.62s.
remote:        I, [2021-06-04T21:52:45.128952 #360]  INFO -- : Writing /tmp/build_5fa23b33/public/assets/application-43e83168d1536a5883821e3cc8ec1131ee502acb6d26a77dd45b93ad11dda098.css
remote:        I, [2021-06-04T21:52:45.129249 #360]  INFO -- : Writing /tmp/build_5fa23b33/public/assets/application-43e83168d1536a5883821e3cc8ec1131ee502acb6d26a77dd45b93ad11dda098.css.gz
remote:        I, [2021-06-04T21:52:45.129462 #360]  INFO -- : Writing /tmp/build_5fa23b33/public/assets/custom-91d5d37298ccb7c5bf6e028899e879468125e1aededc57df093f84b618cde2bd.css
remote:        I, [2021-06-04T21:52:45.129719 #360]  INFO -- : Writing /tmp/build_5fa23b33/public/assets/custom-91d5d37298ccb7c5bf6e028899e879468125e1aededc57df093f84b618cde2bd.css.gz
remote:        Compiling...
remote:        Compilation failed:
remote:        Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
remote:        The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
remote:         ["@babel/plugin-proposal-private-methods", { "loose": true }]
remote:        to the "plugins" section of your Babel config.

remote:         ["@babel/plugin-proposal-private-methods", { "loose": true }]
remote:        to the "plugins" section of your Babel config.
remote:        Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
remote:        The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
remote:         ["@babel/plugin-proposal-private-methods", { "loose": true }]
remote:        to the "plugins" section of your Babel config.
remote:
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 afternoon-lf-49433.
remote:
To https://git.heroku.com/afternoon-lf-49433.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs 

babel.config.js

module.exports = function(api) {   var validEnv = ['development', 'test', 'production']   var currentEnv = api.env()   var isDevelopmentEnv = api.env('development')   var isProductionEnv = api.env('production')   var isTestEnv = api.env('test')

  if (!validEnv.includes(currentEnv)) {
    throw new Error(
      'Please specify a valid `NODE_ENV` or ' +
        '`BABEL_ENV` environment variables. Valid values are "development", ' +
        '"test", and "production". Instead, received: ' +
        JSON.stringify(currentEnv) +
        '.'
    )   }

  return {
    presets: [
      isTestEnv && [
        '@babel/preset-env',
        {
          targets: {
            node: 'current'
          }
        }
      ],
      (isProductionEnv || isDevelopmentEnv) && [
        '@babel/preset-env',
        {
          forceAllTransforms: true,
          useBuiltIns: 'entry',
          corejs: 3,
          modules: false,
          exclude: ['transform-typeof-symbol']
        }
      ]
    ].filter(Boolean),
    plugins: [
      'babel-plugin-macros',
      '@babel/plugin-syntax-dynamic-import',
      isTestEnv && 'babel-plugin-dynamic-import-node',
      '@babel/plugin-transform-destructuring',
      [
        '@babel/plugin-proposal-class-properties',
        {
          loose: true
        }
      ],
      [
        '@babel/plugin-proposal-object-rest-spread',
        {
          useBuiltIns: true
        }
      ],
      [
        '@babel/plugin-transform-runtime',
        {
          helpers: false
        }
      ],
      [
        '@babel/plugin-transform-regenerator',
        {
          async: false
        }
      ]
    ].filter(Boolean)   } }

特殊控制器

class SpecialsController <ApplicationController
    before_action :set_special, only: [:show, :edit, :update, :destroy]
    

    def show    
    end

    def index
        @specials = Special.all 
    end

    def new
        @special = Special.new
    end

    def edit    
    end

    def create
        @special = Special.new(special_params)
        if @special.save
            flash[:notice] = "Special was created successfully!" 
            redirect_to @special
        else
            render 'new'
        end
    end

    def update
        if @special.update(special_params)
            flash[:notice] = "Special was updated!"
            redirect_to @special
        else
            render 'edit'
        end
    end

    def destroy
        @special.destroy
        redirect_to specials_path
    end

    def day_of_week
        t = Time.now
        t.strftime("%A")
    end

    helper_method :day_of_week

    private

    def set_special
        @special = Special.find(params[:id])
    end

    def special_params
        params.require(:special).permit(:day, :title, :description, :price)
    end
end

index.html.erb

<h1 class="text-center mt-4 text-info">Specials for <%= day_of_week %></h1>

<div class= "container">
    <div class="row">
        <% @specials.each do |special| %>
            <div class="col-md-4 mt-4">
                <div class="card text-center shadow p-3 mb-5 bg-white rounded" style="width: 18rem;">
                  <div class="card-body ">
                    <h5 class="card-title"><%= link_to special.title, special_path(special), class: "text-success" %></h5>
                    <h6 class="card-subtitle mb-2 text-muted font-italic">Applebees</h6>
                    <p class="card-text"><%= truncate(special.description, length: 50) %></p>

                  </div>    
                </div>
            </div>
        <% end %>
    </div>
</div>


<table>
    <thead>
        <tr>
            <th>Day</th>
            <th>Title</th>
            <th>Description</th>
            <th>Price</th>
            <th colspan ="3">Actions</th>
        </tr>
    </thead>
    <tbody>
        <% @specials.each do |special| %>
            <tr>
            
                <td><%= special.day %></td>
                <td><%= special.title %></td>
                <td><%= special.description %></td>
                <td>$<%= special.price %></td>
                <td><%= link_to 'Show', special_path(special)%></td>
                <td><%= link_to 'Edit', edit_special_path(special)%></td>
                <td><%= link_to "Delete", special_path(special), method: :delete, data: { confirm: "Are you sure?"} %></td>
                    
            </tr>
            
        <% end%>
    </tbody>

</table>
<p>
    <%= link_to 'Add a Special', new_special_path %>
</p>

宝石文件

  remote: https://rubygems.org/
  specs:
    actioncable (6.1.3.2)
      actionpack (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (6.1.3.2)
      actionpack (= 6.1.3.2)
      activejob (= 6.1.3.2)
      activerecord (= 6.1.3.2)
      activestorage (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      mail (>= 2.7.1)
    actionmailer (6.1.3.2)
      actionpack (= 6.1.3.2)
      actionview (= 6.1.3.2)
      activejob (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (6.1.3.2)
      actionview (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      rack (~> 2.0, >= 2.0.9)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.2.0)
    actiontext (6.1.3.2)
      actionpack (= 6.1.3.2)
      activerecord (= 6.1.3.2)
      activestorage (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      nokogiri (>= 1.8.5)
    actionview (6.1.3.2)
      activesupport (= 6.1.3.2)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.1, >= 1.2.0)
    activejob (6.1.3.2)
      activesupport (= 6.1.3.2)
      globalid (>= 0.3.6)
    activemodel (6.1.3.2)
      activesupport (= 6.1.3.2)
    activerecord (6.1.3.2)
      activemodel (= 6.1.3.2)
      activesupport (= 6.1.3.2)
    activestorage (6.1.3.2)
      actionpack (= 6.1.3.2)
      activejob (= 6.1.3.2)
      activerecord (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      marcel (~> 1.0.0)
      mini_mime (~> 1.0.2)
    activesupport (6.1.3.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      tzinfo (~> 2.0)
      zeitwerk (~> 2.3)
    addressable (2.7.0)
      public_suffix (>= 2.0.2, < 5.0)
    bindex (0.8.1)
    bootsnap (1.7.5)
      msgpack (~> 1.0)
    builder (3.2.4)
    byebug (11.1.3)
    capybara (3.35.3)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (>= 1.5, < 3.0)
      xpath (~> 3.2)
    childprocess (3.0.0)
    concurrent-ruby (1.1.8)
    crass (1.0.6)
    erubi (1.10.0)
    ffi (1.15.1-x64-mingw32)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.8.10)
      concurrent-ruby (~> 1.0)
    jbuilder (2.11.2)
      activesupport (>= 5.0.0)
    loofah (2.9.1)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (1.0.1)
    method_source (1.0.0)
    mini_mime (1.0.3)
    minitest (5.14.4)
    msgpack (1.4.2)
    nio4r (2.5.7)
    nokogiri (1.11.6-x64-mingw32)
      racc (~> 1.4)
    pg (1.2.3-x64-mingw32)
    public_suffix (4.0.6)
    puma (5.3.2)
      nio4r (~> 2.0)
    racc (1.5.2)
    rack (2.2.3)
    rack-mini-profiler (2.3.2)
      rack (>= 1.2.0)
    rack-proxy (0.7.0)
      rack
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (6.1.3.2)
      actioncable (= 6.1.3.2)
      actionmailbox (= 6.1.3.2)
      actionmailer (= 6.1.3.2)
      actionpack (= 6.1.3.2)
      actiontext (= 6.1.3.2)
      actionview (= 6.1.3.2)
      activejob (= 6.1.3.2)
      activemodel (= 6.1.3.2)
      activerecord (= 6.1.3.2)
      activestorage (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      bundler (>= 1.15.0)
      railties (= 6.1.3.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.3.0)
      loofah (~> 2.3)
    railties (6.1.3.2)
      actionpack (= 6.1.3.2)
      activesupport (= 6.1.3.2)
      method_source
      rake (>= 0.8.7)
      thor (~> 1.0)
    rake (13.0.3)
    regexp_parser (2.1.1)
    rubyzip (2.3.0)
    sass-rails (6.0.0)
      sassc-rails (~> 2.1, >= 2.1.1)
    sassc (2.4.0-x64-mingw32)
      ffi (~> 1.9)
    sassc-rails (2.1.2)
      railties (>= 4.0.0)
      sassc (>= 2.0)
      sprockets (> 3.0)
      sprockets-rails
      tilt
    selenium-webdriver (3.142.7)
      childprocess (>= 0.5, < 4.0)
      rubyzip (>= 1.2.2)
    semantic_range (3.0.0)
    sprockets (4.0.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.2)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.4.2)
    thor (1.1.0)
    tilt (2.0.10)
    turbolinks (5.2.1)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (2.0.4)
      concurrent-ruby (~> 1.0)
    tzinfo-data (1.2021.1)
      tzinfo (>= 1.0.0)
    web-console (4.1.0)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webdrivers (4.6.0)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (>= 3.0, < 4.0)
    webpacker (5.4.0)
      activesupport (>= 5.2)
      rack-proxy (>= 0.6.1)
      railties (>= 5.2)
      semantic_range (>= 2.3.0)
    websocket-driver (0.7.4)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.4.2)

PLATFORMS
  x64-mingw32

DEPENDENCIES
  bootsnap (>= 1.4.4)
  byebug
  capybara (>= 3.26)
  jbuilder (~> 2.7)
  pg
  puma (~> 5.0)
  rack-mini-profiler (~> 2.0)
  rails (~> 6.1.3, >= 6.1.3.2)
  sass-rails (>= 6)
  selenium-webdriver
  sqlite3 (~> 1.4)
  turbolinks (~> 5)
  tzinfo-data
  web-console (>= 4.1.0)
  webdrivers
  webpacker (~> 5.0)

RUBY VERSION
   ruby 2.7.3p183

BUNDLED WITH
   2.1.4

【问题讨论】:

    标签: ruby-on-rails heroku


    【解决方案1】:

    错误表明 loose 对于预设环境是 false,对于 plugin-proposal-class-propertiestrue。我可以看到你的 babel 配置中有 "loose": true 对应于 plugin-proposal-class-propertiesplugin-proposal-class-properties 配置,也许你也可以尝试将 "loose": true 添加到 preset-env 配置中:

          (isProductionEnv || isDevelopmentEnv) && [
            '@babel/preset-env',
            {
              forceAllTransforms: true,
              useBuiltIns: 'entry',
              corejs: 3,
              modules: false,
              exclude: ['transform-typeof-symbol'],
              loose: true
            }
          ]
    

    【讨论】:

    • 我以前从未改变过这个。我应该改变这个是正常的还是因为我错误地写了一个方法?
    • 不改变与资产相关的任何东西是不正常的,它也与控制器方法的改变完全无关。您是否在部署之间更改了 yarn.lock 文件?如果您部署以前工作的代码的先前版本,那么部署是否工作?您必须将有效的提交与不检查差异的提交进行比较,我们不可能知道发生了什么变化,因为您现在显示的是差异,只是一些当前代码。也许您确实错误地更改了某些内容?你说你添加了引导程序,然后尝试了纱线更新,不清楚发生了什么变化
    猜你喜欢
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多