mina-deploy / mina

Blazing fast deployer and server automation tool

Home Page:https://rubygems.org/gems/mina

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running "mina deploy" failed when "Precompiling asset files", without any detailed error info

ChrisZou opened this issue · comments

commented

Hi, I ran into an error without any detail info when running mina deploy:

-----> Precompiling asset files
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK
       Connection to myserver.com closed.

 !     Run Error

My config/deploy.rb content:

# frozen_string_literal: true

require 'mina/rails'
require 'mina/git'
require 'mina/rvm'    # for rvm support. (https://rvm.io)

set :application_name, 'myapp'
set :domain, 'mydomain.com
set :deploy_to, '/var/www/myapp'
set :repository, 'git@myrepo.git'
set :branch, 'master'

# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more
# run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files`
# set :shared_dirs, fetch(:shared_dirs, []).push('public/assets')
 set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/master.key')

# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :remote_environment do
  # For those using RVM, use this to load an RVM version@gemset.
   invoke :'rvm:use', 'ruby-2.7.0'
end

# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do
  # command %{rbenv install 2.3.0 --skip-existing}
end

desc 'Deploys the current version to the server.'
task :deploy do
  # uncomment this line to make sure you pushed your local branch to the remote origin
  invoke :'git:ensure_pushed'
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      in_path(fetch(:current_path)) do
        command %(mkdir -p tmp/)
        command %(touch tmp/restart.txt)
      end
    end
  end

end

The previous steps(bundle installing, db migration) seem to be working fine.

My env:
Ruby 2.7.0
Rails 6.0.2.1
Ubuntu 18.04

Any idea why and how to fix it?

commented

I'm facing the same issue. Any update on this?

I had the same problem and in my case I did 2 things:

  1. I've changed manifest.js file in app/assets/config which now contain only this one line:
//= link_tree .
  1. I've added command "RAILS_ENV=#{fetch(:rails_env)} bundle exec rails webpacker:yarn_install" before I invoke rails:assets_precompile in deploy.rb

With this 2 things precompiling assets with mina works as intended 🙂

commented

I think I later found out the cause of the issue. It was that the yarn command was not in my ssh PATH, since I installed yarn using linuxbrew and it was not in the default PATH of a ssh connection. Add /the/path/of/my/linuxbrew/bin to PATH and it should be working all right.