前提・実現したいこと
ここに質問の内容を詳しく書いてください。
awsにてnginx+unicornで構築したrailsアプリケーションをCapistranoを使用し、自動デプロイを行おうとしているのですが、assets:precompileが失敗し、デプロイが成功しません。
発生している問題・エラーメッセージ
Tasks: TOP => deploy:assets:precompile (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as *********: rake exit status: 1 rake stdout: Nothing written rake stderr: rake aborted! Uglifier::Error: Unexpected character '`' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define' /var/www/chatspace/shared/bundle/ruby/2.3.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.3.1/bin/bundle:23:in `load' /home/ec2-user/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>' Tasks: TOP => assets:precompile (See full trace by running task with --trace)
該当のソースコード
Capfile
1require "capistrano/setup" 2require "capistrano/deploy" 3require 'capistrano/scm/git' 4install_plugin Capistrano::SCM::Git 5 6require 'capistrano/rbenv' 7require 'capistrano/bundler' 8require 'capistrano/rails/assets' 9require 'capistrano/rails/migrations' 10require 'capistrano3/unicorn' 11 12Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
deploy
1# config valid for current version and patch releases of Capistrano 2lock "~> 3.11.0" 3 4set :application, "chatspace" 5set :repo_url, "git@github.com:*******/******.git" 6 7set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') 8 9set :rbenv_type, :user 10set :rbenv_ruby, '2.3.1' 11 12set :ssh_options, auth_methods: ['publickey'], 13 keys: ['~/.ssh/*****.pem'] 14 15set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" } 16set :unicorn_config_path, -> { "#{current_path}/config/unicorn.rb" } 17set :keep_releases, 5 18 19set :linked_files, %w{ config/secrets.yml } 20 21after 'deploy:publishing', 'deploy:restart' 22namespace :deploy do 23 task :restart do 24 invoke 'unicorn:restart' 25 end 26 27 desc 'upload secrets.yml' 28 task :upload do 29 on roles(:app) do |host| 30 if test "[ ! -d #{shared_path}/config ]" 31 execute "mkdir -p #{shared_path}/config" 32 end 33 upload!('config/secrets.yml', "#{shared_path}/config/secrets.yml") 34 end 35 end 36 before :starting, 'deploy:upload' 37 after :finishing, 'deploy:cleanup' 38end 39 40set :default_env, { 41 rbenv_root: "/usr/local/rbenv", 42 path: "/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH", 43 AWS_ACCESS_KEY_ID: ENV["AWS_ACCESS_KEY_ID"], 44 AWS_SECRET_ACCESS_KEY: ENV["AWS_SECRET_ACCESS_KEY"] 45} 46
試したこと
Uglifier::Error: Unexpected character '`'のエラー文が気になり以下色々試しました。
/config/environments/production.rbの以下をコメントアウトを試しましたがダメでした。
config.assets.js_compressor = :uglifier
上記の箇所を以下に変更したりしましたが、同様のエラーが発生しています。
config.assets.js_compressor = Uglifier.new(harmony: true)
一点気になりところとしては、コンパイルされるjsファイルの中身の変数にバッククォーテーションを使用しているので、
そこで引っかかっているのでは?と考えていますが、わからないので、知恵をお貸しいただければと思います。
補足情報(FW/ツールのバージョンなど)
ruby 2.3.1p112
Rails 5.0.7.1
unicorn v5.4.1
capistrano (3.11.0)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。