Deploy failing

First time for Rails v 6.0.1, Ruby v2.7.6.

Two things stand out for me. Yarn executable was not detected, but ➜ yarn -v shows 1.22.19. Update: I see that this is a rather old version, so will explore updating yarn. Or maybe I should just step back and revise the whole asset pipeline. I was planning to do this after deploying, but maybe should go ahead and do that rather than fiddle with yarn. And would also get rid of webpacker which seems to be causing problems, see below.

error Command "webpack" not found. Webpacker is used in the app gem 'webpacker', '~> 5.0'. The app works on localhost and at Heroku (which I’m migrating from).

Any ideas? Newbie to Fly and very amateur Rails user.

➜ fly deploy
Update available 0.0.387 -> v0.0.388.
Run "fly version update" to upgrade.
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-young-cloud-9276 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 162.7s (0/1)
[+] Building 44.3s (23/23) FINISHED
 => [internal] load remote build context                                                                                                                                                             0.0s
 => copy /context /                                                                                                                                                                                  6.9s
 => resolve image config for                                                                                                                                0.6s
 => CACHED docker-image://                                                           0.0s
 => [internal] load metadata for                                                                                                                    0.3s
 => [base 1/6] FROM                                                         0.0s
 => CACHED [base 2/6] RUN mkdir /app                                                                                                                                                                 0.0s
 => CACHED [base 3/6] WORKDIR /app                                                                                                                                                                   0.0s
 => CACHED [base 4/6] RUN mkdir -p tmp/pids                                                                                                                                                          0.0s
 => CACHED [base 5/6] RUN curl | bash                                                                                                                                           0.0s
 => CACHED [base 6/6] RUN volta install node@18.8.0 && volta install yarn                                                                                                                            0.0s
 => CACHED [build_deps 1/1] RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt     --mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt     apt-get updat  0.0s
 => CACHED [gems 1/3] RUN gem install -N bundler -v 2.3.3                                                                                                                                            0.0s
 => [gems 2/3] COPY Gemfile* ./                                                                                                                                                                      0.3s
 => [gems 3/3] RUN bundle install &&  rm -rf vendor/bundle/ruby/*/cache                                                                                                                             20.5s
 => CACHED [stage-4 1/5] RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt     --mount=type=cache,id=prod-apt-lib,sharing=locked,target=/var/lib/apt     apt-get update  0.0s
 => [stage-4 2/5] COPY --from=gems /app /app                                                                                                                                                         0.6s
 => CACHED [node_modules 1/3] COPY package*json ./                                                                                                                                                   0.0s
 => CACHED [node_modules 2/3] COPY yarn.* ./                                                                                                                                                         0.0s
 => CACHED [node_modules 3/3] RUN if [ -f "yarn.lock" ]; then     yarn install;     elif [ -f "package-lock.json" ]; then     npm install;     else     mkdir node_modules;     fi                   0.0s
 => [stage-4 3/5] COPY --from=node_modules /app/node_modules /app/node_modules                                                                                                                       0.0s
 => [stage-4 4/5] COPY . .                                                                                                                                                                           4.6s
 => ERROR [stage-4 5/5] RUN bin/rails fly:build                                                                                                                                                      4.0s
 > [stage-4 5/5] RUN bin/rails fly:build:
#23 2.795 Yarn executable was not detected in the system.
#23 2.795 Download Yarn at
#23 2.817 I, [2022-09-07T03:31:30.779057 #1]  INFO -- : Writing /app/public/assets/manifest-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.js
#23 2.818 I, [2022-09-07T03:31:30.779943 #1]  INFO -- : Writing /app/public/assets/manifest-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.js.gz
#23 2.818 I, [2022-09-07T03:31:30.780420 #1]  INFO -- : Writing /app/public/assets/DrawTool-1c1f7325e3601283c47d1041a6bef90e94a1203860fd08d6e46536536b5841c7.png
#23 2.819 I, [2022-09-07T03:31:30.781500 #1]  INFO -- : Writing /app/public/assets/down_arrow-3449825c216087a0c2d630a477104a78d834ec34116de097f87be34e03d7a816.png
#23 2.820 I, [2022-09-07T03:31:30.782058 #1]  INFO -- : Writing /app/public/assets/up_arrow-94bb436b257fa40c68ef408a0bb28985d7d1389ebe0e280190dd9c0ee5890406.png
#23 2.821 I, [2022-09-07T03:31:30.782571 #1]  INFO -- : Writing /app/public/assets/images/spritesheet-8e29c56b821c132a47523088cfc0f11f260b417627794f1e17bc37af52d0bbdb.png
#23 2.821 I, [2022-09-07T03:31:30.783047 #1]  INFO -- : Writing /app/public/assets/images/spritesheet-2x-4a1b749c0a6201339961e17f7c8313a62e487888e7197bec29ebdd803fc6f551.png
#23 3.148 Compiling...
#23 3.937 Compilation failed:
#23 3.937 yarn run v1.22.19
#23 3.937 info Visit for documentation about this command.
#23 3.937
#23 3.937
#23 3.937 error Command "webpack" not found.
#23 3.937
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -c bin/rails fly:build]: exit code: 1

I’ve reproduced the problem here. All I can say so far is that I see it with Rails v 6.0.1, Ruby v2.7.6, but not with Rails, Ruby 3.1.2 - even when the latter is configured with -j webpack.

The problem does NOT appear to be a yarn version problem, but rather a problem with volta binstubs and rails binstubs not getting along somehow.

Before I invest more time into this, I’m curious as to what you mean by revise the whole asset pipeline and get rid of webpacker?

Just an update: I see similar problems with Rails, but was able to get this working with Rails, with a one line workaround:


ENV NODE_OPTIONS=--openssl-legacy-provider

Immediately before:

RUN bin/rails fly:build

@rubys Thank you. I tried your second suggestion with that as the only change and got different errors. Don’t invest more time now until I’ve explored it a bit more.

I hadn’t looked at the Dockerfile in any detail but this seems to be using the bash shell and I have been using zsh per recommendations for macOS of late (Monterey?). I forget the reasons, but I think it was licensing problems. I don’t know that Apple said, but his was the assumption. But bash-3.2 is installed. bash -v switched iTerm to the bash shell. A surprise to me. In any case, I guess the bash shell is still here and the script runs, so maybe this isn’t an issue. But in my .zshrc some PATH variables are set and .bashrc won’t have those.

By revising the asset pipeline I meant moving to Rails 7 and dropping webpacker. But you’re suggesting that isn’t the issue:

Rails 7 and JavaScript

Rails 7 brings Import Maps into the limelight

Migrating from Webpacker to the New Bundling Approach

I do highly recommend moving to Rails 7. And I might not have been clear, but yes, moving to Rails 7 (with or without webpacker) will solve this issue, and not need any workarounds. And I also recommend moving away from webpacker.

FYI: the Dockerfile is not run on your machine. It is run on a build machine. The operating system that the build machine will be running is Linux. Which version of Linux is controlled by the Dockerfile itself (in this case, Debian GNU/Linux 10 (buster)).

Thank you. I am starting to upgrade. And good for me to understand about where Docker is run.