Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy assets precompile always failed though i already set rails_env to production #239

Open
ibantoo opened this issue May 25, 2020 · 13 comments

Comments

@ibantoo
Copy link

ibantoo commented May 25, 2020

it said:

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as myapp@myIP: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

i already put set rails_env to production though
always failed on Running $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile

@amolplay
Copy link

amolplay commented Jul 9, 2020

Getting the same issue for capistrano 3.14 version @mattbrictson


 DEBUG [4e5af794] 	[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag

  INFO [4e5af794] Finished in 1.553 seconds with exit status 0 (successful).


 DEBUG [60c7c390] Running if test ! -d /var/www/html/myapp/releases/20200709070829; then echo "Directory does not exist '/var/www/html/myapp/releases/20200709070829'" 1>&2; false; fi as ubuntu@server_IP

 DEBUG [60c7c390] Command: if test ! -d /var/www/html/myapp/releases/20200709070829; then echo "Directory does not exist '/var/www/html/myapp/releases/20200709070829'" 1>&2; false; fi

 DEBUG [60c7c390] Finished in 0.356 seconds with exit status 0 (successful).

  INFO [33014fbd] Running ~/.rvm/bin/rvm default do bundle exec rake assets:precompile as ubuntu@my_ip

 DEBUG [33014fbd] Command: cd /var/www/html/myapp/releases/20200709070829 && ( export RAILS_ENV="staging" RAILS_GROUPS="" ; ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )

@mattbrictson
Copy link
Member

Without an error message it is hard to say what is going on. I see that the command being executed is bundle exec rake assets:precompile but I don't see anything after that in the logs you posted. There are many things that could go wrong. Asset complication is slow and resource intensive, so it is possible that the system is running out of memory. You could try logging into the machine via SSH separately while capistrano is running and use a command like top to see what is happening while the assets:precompile is seemingly stuck.

@amolplay
Copy link

amolplay commented Jul 11, 2020

@mattbrictson : Here are the complete capistrano logs

Error occured when assets:precompile executed. Server's memory is available. I think /releases/20200711132725 directory not creating for assets but not sure .

00:20 bundler:install
      01 ~/.rvm/bin/rvm default do bundle install --path /var/www/html/myapp/shared/bundle --jobs 4 --without development test --deployment --quiet
      01 [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Inst…
      01 [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead pl…
      01 [DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead…
    ✔ 01 ubuntu@myip
00:22 deploy:assets:precompile
      01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
#<Thread:0x000055f28bcb78b0 /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
  13: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
  12: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `run'
  11: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
  10: from /home/amol/.rvm/gems/ruby-2.7.1/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>'
   9: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:92:in `within'
   8: from /home/amol/.rvm/gems/ruby-2.7.1/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>'
   7: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:100:in `with'
   6: from /home/amol/.rvm/gems/ruby-2.7.1/gems/capistrano-rails-1.5.0/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>'
   5: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:80:in `execute'
   4: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
   3: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `tap'
   2: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
   1: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed)
rake stdout: Nothing written
rake stderr: Nothing written
  1: from /home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/amol/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ubuntu@myip: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: Nothing written
rake stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ubuntu@myip: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written


Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as ubuntu@myip: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


 DEBUG [928ca518]    * listen (3.2.1)

 DEBUG [928ca518]    * rubyzip (2.3.0)

 DEBUG [928ca518]    * selenium-webdriver (3.142.7)

 DEBUG [928ca518]    * spring (2.1.0)

 DEBUG [928ca518]    * spring-watcher-listen (2.0.1)

 DEBUG [928ca518]    * web-console (4.0.3)

 DEBUG [928ca518]    * webdrivers (4.4.1)

 DEBUG [928ca518]   Install missing gems with `bundle install`

 DEBUG [928ca518] Finished in 1.559 seconds with exit status 1 (failed).

  INFO [e088cd4e] Running ~/.rvm/bin/rvm default do bundle install --path /var/www/html/myapp/shared/bundle --jobs 4 --without development test --deployment --quiet as ubuntu@myip

 DEBUG [e088cd4e] Command: cd /var/www/html/myapp/releases/20200711132725 && ~/.rvm/bin/rvm default do bundle install --path /var/www/html/myapp/shared/bundle --jobs 4 --without development test --deployment --quiet

 DEBUG [e088cd4e]   [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag

 DEBUG [e088cd4e]   [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path '/var/www/html/myapp/shared/bundle'`, and stop using this flag

 DEBUG [e088cd4e]   [DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag

  INFO [e088cd4e] Finished in 1.236 seconds with exit status 0 (successful).

 DEBUG [ec74aa37] Running if test ! -d /var/www/html/myapp/releases/20200711132725; then echo "Directory does not exist '/var/www/html/myapp/releases/20200711132725'" 1>&2; false; fi as ubuntu@myip

 DEBUG [ec74aa37] Command: if test ! -d /var/www/html/myapp/releases/20200711132725; then echo "Directory does not exist '/var/www/html/myapp/releases/20200711132725'" 1>&2; false; fi

 DEBUG [ec74aa37] Finished in 0.492 seconds with exit status 0 (successful).

  INFO [36ca6f6b] Running ~/.rvm/bin/rvm default do bundle exec rake assets:precompile as ubuntu@myip

 DEBUG [36ca6f6b] Command: cd /var/www/html/myapp/releases/20200711132725 && ( export RAILS_ENV="staging" RAILS_GROUPS="" ; ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )

@mattbrictson
Copy link
Member

Hmm that is frustrating. I don't have any ideas but could you try running the command manually via SSH instead of through cap? That might make the error more apparent.

cd /var/www/html/myapp/releases/20200711132725 && \
( export RAILS_ENV="staging" RAILS_GROUPS="" ; ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )

@falegk
Copy link

falegk commented Jul 28, 2020

Same issue.

capistrano-3.14.1
capistrano-rails-1.6.1

@mattbrictson for me this command is working properly via SSH

cd /var/www/app/releases/20200728173430 && ( export PATH="$HOME/.npm-packages/bin/:$PATH" 
NODE_ENVIRONMENT="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.1" RAILS_ENV="production" 
RAILS_GROUPS="assets" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )

@lrphael
Copy link

lrphael commented Dec 29, 2020

No real solution? I have the same problem for 2 days. And I can't solve

@ilp416
Copy link

ilp416 commented Apr 25, 2021

Same issue for me. When I run command on server it finishes successfully. I check memory and CPU and all looks fine.

    capistrano (3.16.0)
    capistrano-rails (1.6.1)
    capistrano-rvm (0.1.2)

@allanjba
Copy link

allanjba commented May 7, 2021

@ilp416 Did you have any luck solving yours?

@obfuscoder
Copy link

Having a similar problem with a Rails 6 app (with webpack) using capistrano 3.16 and latest cap-rails and cap-rvm. When doing the assets:precompile step, capistrano is aborting almost imediatelly without any hint on why it failed. When I am running the same command on the server inside of the release directory (~/.rvm/bin/rvm default do bundle exec rake assets:precompile), everything works without problems. Though I get a few warnings about unmet dependencies and asset size limit. echo $? returns 0.

@allanjba
Copy link

@obfuscoder for me what worked was to scale up the memory for the virtual machine. I am hosting it on Azure and they allowed me to scale the VM for very cheap. So I chose a higher memory tier and the precompiled ran properly. Later I scaled the VM back so I would still pay less monthly.

@obfuscoder
Copy link

I figured out my problem. Asset compilation requires yarn on my setup. Yarn was not installed system-wide, but made available via snap. As capistrano uses a non-interactive non-login shell, it did not pick up what was set up in bashrc and co. I worked around this by installing yarn with npm system-wide. Next problem after this was, that it did not pick up my environment variables (e.g. DATABASE_URL) so I had to go through sshd_config to allow setting them via .ssh/environment, which can be a security risk, but as I am owning that host and am the only one logging in there, that was the quick solution for me.

@sbryans
Copy link

sbryans commented Oct 5, 2021

Yep! If you --trace the deploy command, the deploy:assets:precompile stage will fail at SSHKit::Runner::ExecuteError: meaning that the prod server can't process your request correctly. nodejs and yarn should be installed on the user you deploy to. Docker simplifies the stack by abstracting much of the production configuration from the developer.

@ilp416
Copy link

ilp416 commented Jan 15, 2022

I found solution of my trouble here koenpunt/capistrano-nvm#25 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants