Error when deploying Rails application

Hi. I’m trying to run the flyctl deploy command but I get this error:

 => ERROR [stage-3 7/7] RUN bin/rails fly:build                                                                                                                                                             1.9s
------
 > [stage-3 7/7] RUN bin/rails fly:build:
#20 1.859 rails aborted!
#20 1.859 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in `autodetect'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/execjs-2.8.1/lib/execjs.rb:5:in `<module:ExecJS>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/execjs-2.8.1/lib/execjs.rb:4:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/autoprefixer-rails-10.4.7.0/lib/autoprefixer-rails/processor.rb:4:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/autoprefixer-rails-10.4.7.0/lib/autoprefixer-rails.rb:39:in `require_relative'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/autoprefixer-rails-10.4.7.0/lib/autoprefixer-rails.rb:39:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootstrap-5.2.2/lib/bootstrap/engine.rb:3:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootstrap-5.2.2/lib/bootstrap.rb:61:in `register_rails_engine'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootstrap-5.2.2/lib/bootstrap.rb:11:in `load!'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootstrap-5.2.2/lib/bootstrap.rb:75:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler/runtime.rb:55:in `each'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler/runtime.rb:55:in `block in require'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler/runtime.rb:44:in `each'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler/runtime.rb:44:in `require'
#20 1.859 /usr/local/bundle/gems/bundler-2.3.24/lib/bundler.rb:186:in `require'
#20 1.859 /app/config/application.rb:7:in `<main>'
#20 1.859 /app/Rakefile:4:in `require_relative'
#20 1.859 /app/Rakefile:4:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:51:in `invoke'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
#20 1.859 bin/rails:5:in `<main>'
#20 1.859 (See full trace by running task with --trace)
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c ${BUILD_COMMAND}]: exit code: 1

Any help?

Try adding nodejs to the ARG DEPLOY_PACKAGES line in your Dockerfile.

After I did this I’m getting another error:

 > [stage-3 7/7] RUN bin/rails fly:build:
#20 3.028 sh: 1: yarn: not found

Try adding yarnpkg to the ARG DEPLOY_PACKAGES line in your Dockerfile. :slight_smile:

Thanks for your help but I don’t think it’s working. This is the line I have:

ARG DEPLOY_PACKAGES="postgresql-client file vim curl gzip libsqlite3-0 nodejs yarnpkg"

Edit: I had a gem that I needed to remove from my Gemfile