我试图将Rails应用程序推送到Heroku。它总是无法预编译。我的提示发布在下面。我已经搜索过该网站,最常见的建议之一就是添加
config.assets.initialize_on_precompile = false
到您的application.rb。这没有用。我看到git告诉我“远程:未在系统中检测到纱线可执行文件。 remote:从https://yarnpkg.com/en/docs/install下载Yarn,因此我下载并安装了Yarn。但是,git仍然像什么都没有发生,因为当我将git push Heroku master放进去的时候,它也提供了完全相同的信息。解决这个问题。如果您需要更多详细信息,那么我很乐意将其发布。谢谢!
Enumerating objects: 203, done.
Counting objects: 100% (203/203), done.
Delta compression using up to 4 threads
Compressing objects: 100% (184/184), done.
Writing objects: 100% (203/203), 1.87 MiB | 1.62 MiB/s, done.
Total 203 (delta 65), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote: Detected buildpacks: Ruby,Node.js
remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.5.3
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.15.2
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 version metadata from https://rubygems.org/..
remote: Fetching dependency metadata from https://rubygems.org/.
remote: Resolving dependencies...
remote: Fetching rake 12.3.2
remote: Fetching concurrent-ruby 1.1.4
remote: Fetching minitest 5.11.3
remote: Installing minitest 5.11.3
remote: Installing rake 12.3.2
remote: Installing concurrent-ruby 1.1.4
remote: Fetching thread_safe 0.3.6
remote: Installing thread_safe 0.3.6
remote: Fetching builder 3.2.3
remote: Installing builder 3.2.3
remote: Fetching erubi 1.7.1
remote: Installing erubi 1.7.1
remote: Fetching mini_portile2 2.4.0
remote: Installing mini_portile2 2.4.0
remote: Fetching crass 1.0.4
remote: Installing crass 1.0.4
remote: Fetching rack 2.0.6
remote: Installing rack 2.0.6
remote: Fetching nio4r 2.3.1
remote: Installing nio4r 2.3.1 with native extensions
remote: Fetching websocket-extensions 0.1.3
remote: Installing websocket-extensions 0.1.3
remote: Fetching mini_mime 1.0.1
remote: Installing mini_mime 1.0.1
remote: Fetching arel 9.0.0
remote: Installing arel 9.0.0
remote: Fetching mimemagic 0.3.2
remote: Installing mimemagic 0.3.2
remote: Fetching msgpack 1.2.4
remote: Installing msgpack 1.2.4 with native extensions
remote: Using bundler 1.15.2
remote: Fetching coffee-script-source 1.12.2
remote: Installing coffee-script-source 1.12.2
remote: Fetching execjs 2.7.0
remote: Installing execjs 2.7.0
remote: Fetching method_source 0.9.2
remote: Installing method_source 0.9.2
remote: Fetching thor 0.20.3
remote: Installing thor 0.20.3
remote: Fetching duktape 2.0.1.0
remote: Installing duktape 2.0.1.0 with native extensions
remote: Fetching ffi 1.9.25
remote: Installing ffi 1.9.25 with native extensions
remote: Fetching multi_json 1.13.1
remote: Installing multi_json 1.13.1
remote: Fetching pg 1.1.3
remote: Installing pg 1.1.3 with native extensions
remote: Fetching puma 3.12.0
remote: Installing puma 3.12.0 with native extensions
remote: Fetching rb-fsevent 0.10.3
remote: Installing rb-fsevent 0.10.3
remote: Fetching tilt 2.0.9
remote: Installing tilt 2.0.9
remote: Fetching turbolinks-source 5.2.0
remote: Installing turbolinks-source 5.2.0
remote: Fetching tzinfo 1.2.5
remote: Installing tzinfo 1.2.5
remote: Fetching nokogiri 1.9.0
remote: Installing nokogiri 1.9.0 with native extensions
remote: Fetching i18n 1.2.0
remote: Installing i18n 1.2.0
remote: Fetching websocket-driver 0.7.0
remote: Installing websocket-driver 0.7.0 with native extensions
remote: Fetching mail 2.7.1
remote: Installing mail 2.7.1
remote: Fetching rack-test 1.1.0
remote: Installing rack-test 1.1.0
remote: Fetching sprockets 3.7.2
remote: Installing sprockets 3.7.2
remote: Fetching marcel 0.3.3
remote: Installing marcel 0.3.3
remote: Fetching coffee-script 2.4.1
remote: Installing coffee-script 2.4.1
remote: Fetching uglifier 4.1.20
remote: Installing uglifier 4.1.20
remote: Fetching bootsnap 1.3.2
remote: Installing bootsnap 1.3.2 with native extensions
remote: Fetching rb-inotify 0.10.0
remote: Installing rb-inotify 0.10.0
remote: Fetching turbolinks 5.2.0
remote: Installing turbolinks 5.2.0
remote: Fetching activesupport 5.2.2
remote: Installing activesupport 5.2.2
remote: Fetching loofah 2.2.3
remote: Installing loofah 2.2.3
remote: Fetching sass-listen 4.0.0
remote: Fetching rails-dom-testing 2.0.3
remote: Installing rails-dom-testing 2.0.3
remote: Installing sass-listen 4.0.0
remote: Fetching globalid 0.4.1
remote: Installing globalid 0.4.1
remote: Fetching activemodel 5.2.2
remote: Fetching jbuilder 2.8.0
remote: Installing activemodel 5.2.2
remote: Installing jbuilder 2.8.0
remote: Fetching rails-html-sanitizer 1.0.4
remote: Installing rails-html-sanitizer 1.0.4
remote: Fetching sass 3.7.2
remote: Fetching activejob 5.2.2
remote: Installing activejob 5.2.2
remote: Installing sass 3.7.2
remote: Fetching activerecord 5.2.2
remote: Fetching actionview 5.2.2
remote: Installing actionview 5.2.2
remote: Installing activerecord 5.2.2
remote: Fetching actionpack 5.2.2
remote: Installing actionpack 5.2.2
remote: Fetching actioncable 5.2.2
remote: Fetching actionmailer 5.2.2
remote: Fetching activestorage 5.2.2
remote: Installing actionmailer 5.2.2
remote: Installing activestorage 5.2.2
remote: Installing actioncable 5.2.2
remote: Fetching railties 5.2.2
remote: Installing railties 5.2.2
remote: Fetching sprockets-rails 3.2.1
remote: Installing sprockets-rails 3.2.1
remote: Fetching rails 5.2.2
remote: Fetching sass-rails 5.0.7
remote: Fetching coffee-rails 4.2.2
remote: Installing coffee-rails 4.2.2
remote: Installing sass-rails 5.0.7
remote: Installing rails 5.2.2
remote: Bundle complete! 16 Gemfile dependencies, 62 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: Please check your Rails app for 'config.i18n.fallbacks = true'.
remote: If you're using I18n 1.1.x and Rails (< 6.0), 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: For more info see:
remote: https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:
remote: Post-install message from sass:
remote:
remote: Ruby Sass is deprecated and will be unmaintained as of 26 March 2019.
remote:
remote: * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote: primary implementation: https://sass-lang.com/install
remote:
remote: * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote: sassc gem: https://github.com/sass/sassc-ruby#readme
remote:
remote: * For more details, please refer to the Sass blog:
remote: http://sass.logdown.com/posts/7081811
remote:
remote: Bundle completed (66.42s)
remote: Cleaning up the bundler cache.
remote: The latest bundler is 2.0.0.pre.2, but you are currently running 1.15.2.
remote: To update, run `gem install bundler --pre`
remote: -----> Installing node-v8.10.0-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: Yarn executable was not detected in the system.
remote: Download Yarn at https://yarnpkg.com/en/docs/install
remote: I, [2018-12-18T00:20:36.942680 #1410] INFO -- : Writing /tmp/build_91a0385c01ee50024d705167797cefde/public/assets/background-22f0da6b56b83c5381a219c64b68ace6f415ead2fa430af99a9805cf48660ca7.jpg
remote: rake aborted!
remote: Uglifier::Error: Unexpected token: operator (=). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote: /tmp/build_91a0385c01ee50024d705167797cefde/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/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 secure-earth-41846.
remote:
To https://git.heroku.com/secure-earth-41846.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/secure-earth-41846.git'
这是我的宝石文件:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'duktape'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'pg'
答案 0 :(得分:1)
输出中的yarn注释可能是红色鲱鱼。 Uglifier::Error: Unexpected token: operator (=). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
看起来像是罪魁祸首。
您可以根据此uglifier post尝试在config/environmonts/production.rb
文件中覆盖uglifier
替换
config.assets.js_compressor = :uglifier
使用
config.assets.js_compressor = Uglifier.new(harmony: true)
似乎您缺少js / v8引擎。在生产区的gem 'mini_racer'
中添加Gemfile
可以解决此问题。由于mini_racer在本地不可用,因此将其添加到生产模块中