I've been using Capistrano for deployment of my Rails app. It is failing on the following step:
01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/bubblin.io/shared/bundle --without development test --deployment --quiet
✔ 01 marvin@bubblin.io 1.053s
00:26 yarn:install
01 $HOME/.rbenv/bin/rbenv exec yarn install --production
01 rbenv: yarn: command not found
$HOME/.rbenv/bin/rbenv exec yarn install --production
01 rbenv: yarn: command not found
#<Thread:0x00007fb9b626fcd8@/Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/sa/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as marvin@bubblin.io: yarn exit status: 127 (SSHKit::Runner::ExecuteError)
yarn stdout: rbenv: yarn: command not found
yarn stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as marvin@bubblin.io: yarn exit status: 127
yarn stdout: rbenv: yarn: command not found
yarn stderr: Nothing written
I ssh'ed into the server and tried the following, which works:
$ yarn install --production
yarn install v1.10.1
[1/4] Resolving packages...
success Nothing to install.
success Saved lockfile.
Done in 0.06s.
But when I prefix the same command with rbenv exec
it fails.
$ rbenv exec yarn install --production
rbenv: yarn: command not found
All dependencies appear to be installed correctly, but rbenv
isn't able to find yarn
for some reason?
I think yarn
is nodejs package manager, should not run via rbenv exec
perhaps?
So, in this case, you could simply use it from regular shell rather than rbenv. For example, try to create task like the following should do the job.
desc "Yarn Install"
task :yarn_install do
on roles(:all) do |host|
execute :yarn, :install, "--production"
end
end
Then, run it with
bundle exec cap production yarn_install
Or, invoke the task from another task you have etc.
Update:
If not using yarn,
In Gemfile, remove or comment 'capistrano-yarn'
#gem 'capistrano-yarn'
In Capfile, remove or comment 'capistrano/yarn'
#require 'capistrano/yarn'
For creating a new project:
rails new <name> --skip-yarn
But, on existing project, set webpacker.check_yarn_integrity
to false
in app env files (i.e. app/config/development.rb app/config/production.rb)
config.webpacker.check_yarn_integrity = false
Find javascript_pack_tag
or stylesheet_pack_tag
in app/views/*
path, then comment them out, like so:
<%# javascript_pack_tag "" %>
<%# stylesheet_pack_tag "" %>