[Rails] Can't deploy an app following the Getting Started guide

Rails 7.0.4
Ruby 3.1.0
I’m following step by step the basic guide Getting Started · Fly Docs (even naming the app the same way) but it always fails to deploy (fly deploy step)

First time it failed because it was trying to install development gems:

➜  list git:(master) ✗ fly deploy
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-shy-dream-3418 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  18.67kB
[+] Building 57.7s (20/20) FINISHED                                                                                                                                                                                                                    
 => [internal] load remote build context                                                                                                                                                                                                          0.0s
 => copy /context /                                                                                                                                                                                                                               0.1s
 => resolve image config for docker.io/docker/dockerfile:experimental                                                                                                                                                                             1.9s
 => docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5                                                                                                               0.8s
 => => resolve docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5                                                                                                                   0.0s
 => => sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5 1.69kB / 1.69kB                                                                                                                                                    0.0s
 => => sha256:3c244c0c6fc9d6aa3ddb73af4264b3a23597523ac553294218c13735a2c6cf79 528B / 528B                                                                                                                                                        0.0s
 => => sha256:b587adb6abfd8d6c87b1f649c2e924d53f148ae1c7f0ceaaded70b27b44dccb5 1.21kB / 1.21kB                                                                                                                                                    0.0s
 => => sha256:d7f0373ffb1d5ac3477b10ab7f91cba7c5df586c72e7e4a12649024efdc0d531 9.64MB / 9.64MB                                                                                                                                                    0.6s
 => => extracting sha256:d7f0373ffb1d5ac3477b10ab7f91cba7c5df586c72e7e4a12649024efdc0d531                                                                                                                                                         0.2s
 => [internal] load metadata for quay.io/evl.ms/fullstaq-ruby:3.1.0-jemalloc-slim                                                                                                                                                                 2.3s
 => [base 1/5] FROM quay.io/evl.ms/fullstaq-ruby:3.1.0-jemalloc-slim@sha256:fd986d88b25607ffb4f12495b3b74ce60525caf5677863ca9664459404814044                                                                                                      5.9s
 => => resolve quay.io/evl.ms/fullstaq-ruby:3.1.0-jemalloc-slim@sha256:fd986d88b25607ffb4f12495b3b74ce60525caf5677863ca9664459404814044                                                                                                           0.0s
 => => sha256:8af9292028033dd0adb719749f951a6463619094124fda64d6ae3a981774faf7 3.43kB / 3.43kB                                                                                                                                                    0.0s
 => => sha256:5eb5b503b37671af16371272f9c5313a3e82f1d0756e14506704489ad9900803 31.37MB / 31.37MB                                                                                                                                                  3.9s
 => => sha256:78bc648ed34cb4913faa1e3b8cafdb5522bc74df0809859dd5ca086813e01939 17.87MB / 17.87MB                                                                                                                                                  3.5s
 => => sha256:fd986d88b25607ffb4f12495b3b74ce60525caf5677863ca9664459404814044 741B / 741B                                                                                                                                                        0.0s
 => => extracting sha256:5eb5b503b37671af16371272f9c5313a3e82f1d0756e14506704489ad9900803                                                                                                                                                         1.0s
 => => extracting sha256:78bc648ed34cb4913faa1e3b8cafdb5522bc74df0809859dd5ca086813e01939                                                                                                                                                         0.8s
 => [base 2/5] RUN mkdir /app                                                                                                                                                                                                                     0.5s
 => [base 3/5] WORKDIR /app                                                                                                                                                                                                                       0.0s
 => [base 4/5] RUN mkdir -p tmp/pids                                                                                                                                                                                                              0.3s
 => [base 5/5] RUN gem update --system --no-document &&     gem install -N bundler -v 2.3.19                                                                                                                                                      7.2s
 => [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 update -qq &&     apt-get install --no-install-recommend  19.1s
 => [stage-3 1/7] 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 -qq &&     apt-get install --no-install-recommends   7.4s
 => [gems 1/2] COPY Gemfile* ./                                                                                                                                                                                                                   0.0s 
 => [gems 2/2] RUN bundle install && rm -rf vendor/bundle/ruby/*/cache                                                                                                                                                                           16.2s 
 => [stage-3 2/7] COPY --from=gems /app /app                                                                                                                                                                                                      0.5s 
 => [stage-3 3/7] COPY --from=gems /usr/lib/fullstaq-ruby/versions /usr/lib/fullstaq-ruby/versions                                                                                                                                                0.6s 
 => [stage-3 4/7] COPY --from=gems /usr/local/bundle /usr/local/bundle                                                                                                                                                                            0.2s 
 => [stage-3 5/7] COPY . .                                                                                                                                                                                                                        0.0s 
 => [stage-3 6/7] RUN chmod +x /app/bin/* &&     sed -i 's/ruby.exe\r*/ruby/' /app/bin/* &&     sed -i 's/ruby\r*/ruby/' /app/bin/* &&     sed -i '/^#!/aDir.chdir File.expand_path("..", __dir__)' /app/bin/*                                    0.3s 
 => ERROR [stage-3 7/7] RUN bin/rails fly:build                                                                                                                                                                                                   0.6s 
------                                                                                                                                                                                                                                                 
 > [stage-3 7/7] RUN bin/rails fly:build:                                                                                                                                                                                                              
#20 0.550 /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:271:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'debug' in locally installed gems. (Bundler::GemNotFound)                                         
#20 0.550       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:254:in `map!'                                                                                                                                                       
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:254:in `verify_gemfile_dependencies_are_found!'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:49:in `start'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:24:in `resolve'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:480:in `reresolve'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:283:in `resolve'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:488:in `materialize'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:191:in `specs'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:247:in `specs_for'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/runtime.rb:18:in `setup'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler.rb:163:in `setup'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/setup.rb:20:in `block in <top (required)>'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/ui/shell.rb:136:in `with_level'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/ui/shell.rb:88:in `silence'
#20 0.550 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/setup.rb:20:in `<top (required)>'
#20 0.550 	from <internal:/usr/lib/fullstaq-ruby/versions/3.1.0-jemalloc/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
#20 0.550 	from <internal:/usr/lib/fullstaq-ruby/versions/3.1.0-jemalloc/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
#20 0.550 	from /app/config/boot.rb:3:in `<top (required)>'
#20 0.550 	from bin/rails:4:in `require_relative'
#20 0.550 	from bin/rails:4:in `<main>'
------
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

I’m surprised that it’s trying to do that as the Dockerfile defines a production environment

ARG RAILS_ENV=production
ENV RAILS_ENV=${RAILS_ENV}

However I found the bundle install command in it and changed it so that it could get past this step

# before
RUN bundle install && rm -rf vendor/bundle/ruby/*/cache

# after
RUN bundle install --without development test && rm -rf vendor/bundle/ruby/*/cache

When running at this point, it fails to build due to missing image

➜  list git:(master) ✗ fly deploy
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-shy-dream-3418 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  18.69kB
[+] Building 807.7s (1/1) FINISHED                                                                                                                                                                                                                     
 => ERROR [internal] load remote build context                                                                                                                                                                                                  807.8s
------
 > [internal] load remote build context:
------
Error failed to fetch an image or build from source: error building: error during connect: Post "http://[fdaa:0:bea9:a7b:d829:6383:3466:2]:2375/v1.41/build?buildargs=null&buildid=upload-request%3Aa8a5a72b7f42f5db9ae20ab400b5e2cdf1a0ca15be349d19c51fc4311f7438d2&cachefrom=null&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=&labels=null&memory=0&memswap=0&networkmode=&rm=0&shmsize=0&target=&ulimits=null&version=2": EOF

I’ve asked a friend who has a deployed Rails app but he doesn’t seem to have any issues with it. He suggested deploying using the --remote-only flag, but that hasn’t helped either.

Could you please advise?

1 Like

Wow. That’s a long time.

For some strange reason the build machine had a hiccup and could not start. This has nothing to do with the changes you made as the build hasn’t started.

It probably is the case that if you were to try again you will actually build this time. But it doesn’t hurt to throw away this builder and start fresh:

fly apps destroy -y fly-builder-shy-dream-3418
1 Like

Ran

fly apps destroy -y fly-builder-shy-dream-3418
fly deploy

and got the same errors as before

Can you post your Dockerfile?

Alternately, you can try out the Dockerfile that I’m working on with DHH to support Rails 7.1: GitHub - rubys/dockerfile-rails: Provide Rails generators to produce Dockerfiles and related files.

This is the Dockerfile I’ve been using:

# syntax = docker/dockerfile:experimental

# Dockerfile used to build a deployable image for a Rails application.
# Adjust as required.
#
# Common adjustments you may need to make over time:
#  * Modify version numbers for Ruby, Bundler, and other products.
#  * Add library packages needed at build time for your gems, node modules.
#  * Add deployment packages needed by your application
#  * Add (often fake) secrets needed to compile your assets

#######################################################################

# Learn more about the chosen Ruby stack, Fullstaq Ruby, here:
#   https://github.com/evilmartians/fullstaq-ruby-docker.
#
# We recommend using the highest patch level for better security and
# performance.

ARG RUBY_VERSION=3.1.0
ARG VARIANT=jemalloc-slim
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base

LABEL fly_launch_runtime="rails"

ARG BUNDLER_VERSION=2.3.19

ARG RAILS_ENV=production
ENV RAILS_ENV=${RAILS_ENV}

ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true

ARG BUNDLE_WITHOUT=development:test
ARG BUNDLE_PATH=vendor/bundle
ENV BUNDLE_PATH ${BUNDLE_PATH}
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}

RUN mkdir /app
WORKDIR /app
RUN mkdir -p tmp/pids

RUN gem update --system --no-document && \
    gem install -N bundler -v ${BUNDLER_VERSION}

#######################################################################

# install packages only needed at build time

FROM base as build_deps

ARG BUILD_PACKAGES="git build-essential libpq-dev wget vim curl gzip xz-utils libsqlite3-dev"
ENV BUILD_PACKAGES ${BUILD_PACKAGES}

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 update -qq && \
    apt-get install --no-install-recommends -y ${BUILD_PACKAGES} \
    && rm -rf /var/lib/apt/lists /var/cache/apt/archives

#######################################################################

# install gems

FROM build_deps as gems

COPY Gemfile* ./
RUN bundle install --without development test && rm -rf vendor/bundle/ruby/*/cache

#######################################################################

# install deployment packages

FROM base

ARG DEPLOY_PACKAGES="postgresql-client file vim curl gzip libsqlite3-0"
ENV DEPLOY_PACKAGES=${DEPLOY_PACKAGES}

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 -qq && \
    apt-get install --no-install-recommends -y \
    ${DEPLOY_PACKAGES} \
    && rm -rf /var/lib/apt/lists /var/cache/apt/archives

# copy installed gems
COPY --from=gems /app /app
COPY --from=gems /usr/lib/fullstaq-ruby/versions /usr/lib/fullstaq-ruby/versions
COPY --from=gems /usr/local/bundle /usr/local/bundle

#######################################################################

# Deploy your application
COPY . .

# Adjust binstubs to run on Linux and set current working directory
RUN chmod +x /app/bin/* && \
    sed -i 's/ruby.exe\r*/ruby/' /app/bin/* && \
    sed -i 's/ruby\r*/ruby/' /app/bin/* && \
    sed -i '/^#!/aDir.chdir File.expand_path("..", __dir__)' /app/bin/*

# The following enable assets to precompile on the build server.  Adjust
# as necessary.  If no combination works for you, see:
# https://fly.io/docs/rails/getting-started/existing/#access-to-environment-variables-at-build-time
ENV SECRET_KEY_BASE 1
# ENV AWS_ACCESS_KEY_ID=1
# ENV AWS_SECRET_ACCESS_KEY=1

# Run build task defined in lib/tasks/fly.rake
ARG BUILD_COMMAND="bin/rails fly:build"
RUN ${BUILD_COMMAND}

# Default server start instructions.  Generally Overridden by fly.toml.
ENV PORT 8080
ARG SERVER_COMMAND="bin/rails fly:server"
ENV SERVER_COMMAND ${SERVER_COMMAND}
CMD ${SERVER_COMMAND}

I force-generated the dockerfile from your gem and this was the error message this time:

➜  fly-test git:(master) ✗ fly deploy                                                                                                                                                                                                     [🐍 lewagon]
==> Verifying app config
--> Verified app config
==> Building image
Waiting for remote builder fly-builder-delicate-field-7747... 
Remote builder fly-builder-delicate-field-7747 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  18.72kB
[+] Building 5.4s (5/5) FINISHED                                                                                                                                                                                                                       
 => [internal] load remote build context                                                                                                                                                                                                          0.0s
 => copy /context /                                                                                                                                                                                                                               0.1s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                                                        2.1s
 => docker-image://docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                                                                                          0.8s
 => => resolve docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                                                                                              0.0s
 => => sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc 2.00kB / 2.00kB                                                                                                                                                    0.0s
 => => sha256:ad87fb03593d1b71f9a1cfc1406c4aafcb253b1dabebf569768d6e6166836f34 528B / 528B                                                                                                                                                        0.0s
 => => sha256:1e8a16826fd1c80a63fa6817a9c7284c94e40cded14a9b0d0d3722356efa47bd 2.37kB / 2.37kB                                                                                                                                                    0.0s
 => => sha256:1328b32c40fca9bcf9d70d8eccb72eb873d1124d72dadce04db8badbe7b08546 9.94MB / 9.94MB                                                                                                                                                    0.6s
 => => extracting sha256:1328b32c40fca9bcf9d70d8eccb72eb873d1124d72dadce04db8badbe7b08546                                                                                                                                                         0.2s
 => ERROR [internal] load metadata for docker.io/library/ruby:3.1.0.0-slim                                                                                                                                                                        2.3s
------
 > [internal] load metadata for docker.io/library/ruby:3.1.0.0-slim:
------
Error failed to fetch an image or build from source: error building: failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = docker.io/library/ruby:3.1.0.0-slim: not found

EDIT:
The Dockerfile generated by your gem is as follows:

# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.1.0.0
FROM ruby:$RUBY_VERSION-slim as base

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_ENV="production" \
    BUNDLE_PATH="vendor/bundle" \
    BUNDLE_WITHOUT="development:test"

ARG BUNDLER_VERSION=2.3.19
RUN gem update --system --no-document && \
    gem install -N bundler -v ${BUNDLER_VERSION}


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages need to build gems
RUN apt-get update -qq && \
    apt-get install -y build-essential libpq-dev

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle _${BUNDLER_VERSION}_ install

# Copy application code
COPY . .

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile


# Final stage for app image
FROM base

# Install packages need for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built application from previous stage
COPY --from=build /rails /rails

# Deployment options
ENV RAILS_LOG_TO_STDOUT="1" \
    RAILS_SERVE_STATIC_FILES="true"

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]

That’s odd. The number is too long. Can you run the following:

ruby -e 'puts Gem.ruby_version.to_s.inspect'

That’s your second run. As to the first, I get:

==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-holy-shape-7053 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  24.36kB
[+] Building 32.2s (14/20)                                                      
 => [internal] load remote build context                                   0.0s
 => copy /context /                                                        0.1s
 => resolve image config for docker.io/docker/dockerfile:experimental      0.2s
 => docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c  0.3s
 => => resolve docker.io/docker/dockerfile:experimental@sha256:600e5c62ee  0.0s
 => => sha256:3c244c0c6fc9d6aa3ddb73af4264b3a23597523ac553294 528B / 528B  0.0s
 => => sha256:b587adb6abfd8d6c87b1f649c2e924d53f148ae1c7f 1.21kB / 1.21kB  0.0s
 => => sha256:d7f0373ffb1d5ac3477b10ab7f91cba7c5df586c72e 9.64MB / 9.64MB  0.1s
 => => sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2 1.69kB / 1.69kB  0.0s
 => => extracting sha256:d7f0373ffb1d5ac3477b10ab7f91cba7c5df586c72e7e4a1  0.2s
 => [internal] load metadata for quay.io/evl.ms/fullstaq-ruby:3.1.0-jemal  0.7s
 => [base 1/5] FROM quay.io/evl.ms/fullstaq-ruby:3.1.0-jemalloc-slim@sha2  2.5s
 => => resolve quay.io/evl.ms/fullstaq-ruby:3.1.0-jemalloc-slim@sha256:fd  0.0s
 => => sha256:78bc648ed34cb4913faa1e3b8cafdb5522bc74df0 17.87MB / 17.87MB  0.6s
 => => sha256:fd986d88b25607ffb4f12495b3b74ce60525caf5677863c 741B / 741B  0.0s
 => => sha256:8af9292028033dd0adb719749f951a6463619094124 3.43kB / 3.43kB  0.0s
 => => sha256:5eb5b503b37671af16371272f9c5313a3e82f1d07 31.37MB / 31.37MB  0.4s
 => => extracting sha256:5eb5b503b37671af16371272f9c5313a3e82f1d0756e1450  1.1s
 => => extracting sha256:78bc648ed34cb4913faa1e3b8cafdb5522bc74df0809859d  0.7s
 => [base 2/5] RUN mkdir /app                                              0.5s
 => [base 3/5] WORKDIR /app                                                0.0s
 => [base 4/5] RUN mkdir -p tmp/pids                                       0.4s
 => [base 5/5] RUN gem update --system --no-document &&     gem install -  7.6s
 => [build_deps 1/1] RUN --mount=type=cache,id=dev-apt-cache,sharing=loc  19.1s
 => [stage-3 1/7] RUN --mount=type=cache,id=prod-apt-cache,sharing=locked  7.3s
 => [gems 1/2] COPY Gemfile* ./                                            0.0s
 => ERROR [gems 2/2] RUN bundle install --without development test && rm   0.7s
------
 > [gems 2/2] RUN bundle install --without development test && rm -rf vendor/bundle/ruby/*/cache:
#14 0.506 [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 --local without 'development test'`, and stop using this flag
#14 0.671 Your Ruby version is 3.1.0, but your Gemfile specified 3.2.0
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c bundle install --without development test && rm -rf vendor/bundle/ruby/*/cache]: exit code: 18

The deprecation warning makes sense as you indicated that you changed that portion. The difference in Ruby versions (I’m running 3.2.0 here) then stopped it dead. I presumably could work around that, but what’s puzzling is that I’m getting much further than you are. And that you previously were able to get to this point too.

➜  fly-test git:(master) ✗ ruby -e 'puts Gem.ruby_version.to_s.inspect'
"3.1.0.0"

I removed the extra 0 from the Docker file and re-ran fly deploy. Got again the error with trying to install development gems

Added the --without development test flag to your Dockerfile and re-ran, but oddly enough it fails with the same error. Tried fly apps destroy -y xxx and re-running, but to no avail.

➜  fly-test git:(master) ✗ fly deploy                                                                                                                                                                                                     [🐍 lewagon]
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-late-shadow-8295 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  18.73kB
[+] Building 43.1s (14/15)                                                                                                                                                                                                                             
 => [internal] load remote build context                                                                                                                                                                                                          0.0s
 => copy /context /                                                                                                                                                                                                                               0.1s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                                                        1.8s
 => docker-image://docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                                                                                          0.9s
 => => resolve docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                                                                                              0.0s
 => => sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc 2.00kB / 2.00kB                                                                                                                                                    0.0s
 => => sha256:ad87fb03593d1b71f9a1cfc1406c4aafcb253b1dabebf569768d6e6166836f34 528B / 528B                                                                                                                                                        0.0s
 => => sha256:1e8a16826fd1c80a63fa6817a9c7284c94e40cded14a9b0d0d3722356efa47bd 2.37kB / 2.37kB                                                                                                                                                    0.0s
 => => sha256:1328b32c40fca9bcf9d70d8eccb72eb873d1124d72dadce04db8badbe7b08546 9.94MB / 9.94MB                                                                                                                                                    0.6s
 => => extracting sha256:1328b32c40fca9bcf9d70d8eccb72eb873d1124d72dadce04db8badbe7b08546                                                                                                                                                         0.2s
 => [internal] load metadata for docker.io/library/ruby:3.1.0-slim                                                                                                                                                                                0.8s
 => [base 1/3] FROM docker.io/library/ruby:3.1.0-slim@sha256:d2ec60a604ba35e726ba8721c9344a83888b0d11f2b4f2d56a117e53eac6295a                                                                                                                     3.6s
 => => resolve docker.io/library/ruby:3.1.0-slim@sha256:d2ec60a604ba35e726ba8721c9344a83888b0d11f2b4f2d56a117e53eac6295a                                                                                                                          0.0s
 => => sha256:5eb5b503b37671af16371272f9c5313a3e82f1d0756e14506704489ad9900803 31.37MB / 31.37MB                                                                                                                                                  0.7s
 => => sha256:fdff106a7aee40df40a7cb793f08d6b21a8759f52b60e3a67116075d6229c72d 9.99MB / 9.99MB                                                                                                                                                    0.7s
 => => sha256:95ddd5adb14c63934b4f115d3ec0844fdb4912004e484a4258ed50f026f5ceee 198B / 198B                                                                                                                                                        0.2s
 => => sha256:fb5f74939d1d2144aa3130834df2988e4db58a3fb90a1f5f0f5525f2b6b756fd 31.98MB / 31.98MB                                                                                                                                                  1.2s
 => => sha256:e2486c559ec9ad228e253c9ad39555faf9450807849ed7906f53ce7a7c35b15e 176B / 176B                                                                                                                                                        0.1s
 => => sha256:d2ec60a604ba35e726ba8721c9344a83888b0d11f2b4f2d56a117e53eac6295a 1.86kB / 1.86kB                                                                                                                                                    0.0s
 => => sha256:02664ed5db4c0da90172c89f6e0d1e0deb25e8eb1c18e8dd2fef6e5ce43a8457 1.37kB / 1.37kB                                                                                                                                                    0.0s
 => => sha256:566678fbe6d4d67c90e1f1f386c30a16ecf3fb41cff09722fef8cd2d99a80fea 5.80kB / 5.80kB                                                                                                                                                    0.0s
 => => extracting sha256:5eb5b503b37671af16371272f9c5313a3e82f1d0756e14506704489ad9900803                                                                                                                                                         1.3s
 => => extracting sha256:fdff106a7aee40df40a7cb793f08d6b21a8759f52b60e3a67116075d6229c72d                                                                                                                                                         0.5s
 => => extracting sha256:95ddd5adb14c63934b4f115d3ec0844fdb4912004e484a4258ed50f026f5ceee                                                                                                                                                         0.0s
 => => extracting sha256:fb5f74939d1d2144aa3130834df2988e4db58a3fb90a1f5f0f5525f2b6b756fd                                                                                                                                                         0.7s
 => => extracting sha256:e2486c559ec9ad228e253c9ad39555faf9450807849ed7906f53ce7a7c35b15e                                                                                                                                                         0.0s
 => [base 2/3] WORKDIR /rails                                                                                                                                                                                                                     0.3s
 => [base 3/3] RUN gem update --system --no-document &&     gem install -N bundler -v 2.3.19                                                                                                                                                      6.0s
 => [stage-2 1/2] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y postgresql-client &&     rm -rf /var/lib/apt/lists /var/cache/apt/archives                                                                             5.3s
 => [build 1/5] RUN apt-get update -qq &&     apt-get install -y build-essential libpq-dev                                                                                                                                                       14.9s
 => [build 2/5] COPY Gemfile Gemfile.lock ./                                                                                                                                                                                                      0.0s 
 => [build 3/5] RUN bundle _2.3.19_ install --without development test                                                                                                                                                                           13.9s 
 => [build 4/5] COPY . .                                                                                                                                                                                                                          0.0s 
 => ERROR [build 5/5] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile                                                                                                                                                                     0.5s 
------                                                                                                                                                                                                                                                 
 > [build 5/5] RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile:                                                                                                                                                                                
#14 0.535 /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:271:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'debug' in locally installed gems. (Bundler::GemNotFound)                                         
#14 0.535       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:254:in `map!'                                                                                                                                                       
#14 0.535       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:254:in `verify_gemfile_dependencies_are_found!'                                                                                                                     
#14 0.535       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:49:in `start'                                                                                                                                                       
#14 0.535       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/resolver.rb:24:in `resolve'                                                                                                                                                     
#14 0.535       from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:480:in `reresolve'                                                                                                                                                
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:283:in `resolve'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:488:in `materialize'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:191:in `specs'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/definition.rb:247:in `specs_for'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/runtime.rb:18:in `setup'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler.rb:163:in `setup'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/setup.rb:20:in `block in <top (required)>'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/ui/shell.rb:136:in `with_level'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/ui/shell.rb:88:in `silence'
#14 0.535 	from /usr/local/bundle/gems/bundler-2.3.19/lib/bundler/setup.rb:20:in `<top (required)>'
#14 0.535 	from <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
#14 0.535 	from <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
#14 0.535 	from /rails/config/boot.rb:3:in `<top (required)>'
#14 0.535 	from ./bin/rails:3:in `require_relative'
#14 0.535 	from ./bin/rails:3:in `<main>'
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile]: exit code: 1

Can I get you to try:

ruby -e 'puts RUBY_VERSION.to_s.inspect'

That shouldn’t be necessary as that Dockerfile sets BUNDLE_WITHOUT="development:test".

Would you be willing to share your Gemfile?

➜  fly-test git:(master) ✗ ruby -e 'puts RUBY_VERSION.to_s.inspect'
"3.1.0"

Gemfile:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.0"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Sass to process CSS
# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"

  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
  # gem "rack-mini-profiler"

  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end


gem "dockerfile-rails", "~> 0.3.1", :group => :development

Cool. I’ve fixed the dockerfile-rails gem to use this going forward.

OK, so it is not your Dockerfile, and is not your Gemfile. Now lets move on to Gemfile.lock. Delete it and redeploy. The last time I asked somebody to try this it solved their problem. And did not reappear when they ran bundle install again. See: Existing Rails app errors out on fly-deploy - #11 by doctor.quinoa .

Deleting Gemfile.lock doesn’t work with the Dockerfile you provided

 => ERROR [build 2/5] COPY Gemfile Gemfile.lock ./                                                                                                                                                                                                0.0s
------
 > [build 2/5] COPY Gemfile Gemfile.lock ./:
------
Error failed to fetch an image or build from source: error building: failed to compute cache key: "/Gemfile.lock" not found: not found

Restarting with a fresh application and deleting Gemfile.lock got us further than ever, but it’s still failing:

--> Pushing image done
image: registry.fly.io/silent-sun-3977:deployment-01GPXGFA55HWP6DJ52YW5CBS0R
image size: 297 MB
==> Creating release
--> release v2 created

--> You can detach the terminal anytime without stopping the deployment
==> Release command detected: bin/rails fly:release

--> This release will not be available until the release command succeeds.
	 Starting instance
	 Configuring virtual machine
	 Pulling container image
	 Unpacking image
	 Preparing kernel init
	 Configuring firecracker
	 Starting virtual machine
	 Starting init (commit: b8364bb)...
	 no label, UUID=a6a3c112-2d0e-4554-a776-d4f89814f3fd
	 Preparing to run: `bin/rails fly:release` as root
	 2023/01/16 14:46:20 listening on [fdaa:0:bea9:a7b:d86c:144a:94d3:2]:22 (DNS: [fdaa::3]:53)
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/message_encryptor.rb:209:in `rescue in _decrypt'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/messages/rotator.rb:22:in `decrypt_and_verify'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_file.rb:66:in `read'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:21:in `read'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:33:in `config'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:48:in `options'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/module/delegation.rb:303:in `method_missing'
	 /app/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/railtie.rb:332:in `block in <class:Railtie>'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:60:in `run_initializers'
	 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
	 Caused by:
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/messages/rotator.rb:22:in `decrypt_and_verify'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:21:in `read'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:33:in `config'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/encrypted_configuration.rb:48:in `options'
	 /app/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/core_ext/module/delegation.rb:303:in `method_missing'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:32:in `instance_exec'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:32:in `run'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:61:in `block in run_initializers'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:60:in `run_initializers'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application.rb:372:in `initialize!'
	 /app/config/environment.rb:5:in `<main>'
	 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application.rb:348:in `require_environment!'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
	 /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
	 /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
	 /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	 Tasks: TOP => fly:release => db:migrate => db:load_config => environment
	 (See full trace by running task with --trace)
	 Starting clean up.
Error release command failed, deployment aborted

The Dockerfile produced by fly launch contains COPY Gemfile* ./ instead of COPY Gemfile Gemfile.lock ./, which is why you got further. Let’s continue with the Dockerfile produced by fly launch.

It is troublesome that you have to delete Gemfile.lock to get this to work. When you get a chance can you regenerate it (bundle update will do) and email it to rubys @ fly.io ? Also let me know what operating system you are using, and what version of that operating system.

Now as to the new problem: you are indeed getting close. Your image is built and ready to deploy. All that is needed is to initialize the database. Rails tracebacks can be lengthy and what you are seeing is the last lines of the log (the full log can be seen by going to your dashboard and clicking on your app, then on monitoring, or from the command line via fly logs. But it looks like the problem is in decrypting your credentials, and the reason for this is generally that your RAILS_MASTER_KEY secret isn’t set.

Verify by running fly secrets list.

You can set your master key using the following command:

fly secrets set RAILS_MASTER_KEY=$(cat config/master.key)

Notes:

  • If you are using config/credentials/production.key, use that instead.
  • Windows users will need to replace $(cat config/master.key) with the contents of the config\master.key file.

Sent you the Gemfile. I’m on a Mac Ventura 13.0.1

Tried setting the fly secrets but it doesn’t seem to register

➜  fly-test git:(master) ✗ fly secrets list
NAME	DIGEST	CREATED AT 

➜  fly-test git:(master) ✗ fly secrets set RAILS_MASTER_KEY=$(cat config/master.key)
Error No change detected to secrets. Skipping release.


➜  fly-test git:(master) ✗ fly secrets list 
NAME	DIGEST	CREATED AT 

Rails 7.0.4. Ruby 3.1.0. Mac Ventura 13.0.1. You can’t get much more mainstream than that. I’m not sure why you are seeing so many problems, but quite a few people with that exact configuration find that things “just work”. One of my primary machines is basically that configuration, though I recently updated to Ruby 3.2.0.

OK, so if we rule out the secrets being set, next lets verify the credentials. On your Mac:

bin/rails credentials:edit

If the above command launches an editor, your credentials should be able to be decoded with that key; check to make sure you do not have a config/credentials/*.key file. If it produces an error, we found the problem. If you’ve not added any credentials yourself the quickest fix is to delete the file, run bin/rails credentials:edit and save that file.

P.S. I got your Gemfile.lock. I’ll look at it in a bit.

I might be cursed… :sob:

ran bin/rails credentials:edit, it opened the editor, but the file inside was empty. I saved it anyway and tried redeploying, but same error as before.

delete the file, and rerun bin/rails credentials:edit.

same result as before

Ok, so running EDITOR="code --wait" rails credentials:edit actually opened the file with the following content:

# aws:
#   access_key_id: 123
#   secret_access_key: 345

# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: <REDACTED>

But deploying still not working