Rails 7 with esbuild application production deploy failed
Hello there,
I'm using Capistrano for production deployment, getting below error when I try to deploy my rails 7 application to DigitalOcean server.
00:43 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 Parsing scenario file install
01 ERROR: [Errno 2] No such file or directory: 'install'
01 rake aborted!
01 jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
01 /home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
01 /home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
01 /home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
01 /home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
01 Tasks: TOP => assets:precompile => javascript:build
01 (See full trace by running task with --trace)
#<Thread:0x0000000106748860 /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
/Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy@137.184.28.52: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: Parsing scenario file install
rake stderr: ERROR: [Errno 2] No such file or directory: 'install'
rake aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed)
rake stdout: Parsing scenario file install
rake stderr: ERROR: [Errno 2] No such file or directory: 'install'
rake aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/netssh.rb:170:in `execute_command'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
from <internal:kernel>:90:in `tap'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:80:in `execute'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/capistrano-rails-1.6.2/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:100:in `with'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/capistrano-rails-1.6.2/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:92:in `within'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/capistrano-rails-1.6.2/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/backends/abstract.rb:31:in `run'
from /Users/varma/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@137.184.28.52: rake exit status: 1
rake stdout: Parsing scenario file install
rake stderr: ERROR: [Errno 2] No such file or directory: 'install'
rake aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Parsing scenario file install
rake stderr: ERROR: [Errno 2] No such file or directory: 'install'
rake aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@137.184.28.52: rake exit status: 1
rake stdout: Parsing scenario file install
rake stderr: ERROR: [Errno 2] No such file or directory: 'install'
rake aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/jsbundling-rails-1.0.2/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'
/home/deploy/truemango/shared/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/home/deploy/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
If you SSH to the server, can you run the 'yarn' command?
Is yarn installed on the server?
Because of this error:
jsbundling-rails: Command build failed, ensure yarn is installed and yarn build
runs without errors
The yarn is installed in the server.
Correct me if I’m wrong, the yarn build can be run in the application current folder. Because this is first deployment the folder will not get created until the successful deployment.
Have you tried becoming the 'deploy' user on your server and run the commands from there?
On the server, do su deploy
and then do
$HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
Do you then get errors?
I'm getting the below error message
Could not locate Gemfile or .bundle/ directory
As I mentioned that I'm using Capistrano gem for production deployment, it will take care of executing the commands.
To help you debug faster, you can pretend that you are Capistrano, so SSH into the server, and run every command that Capistrano would run, in the correct order.
Your latest error suggests you are not in the correct folder on the server, where your project should be. Or that your project does not have a Gemfile, which is needed to install all the dependencies.