Deploying a Rails/Postgres app

Hello, I’m trying to move one of my older Ruby on Rails projects from Heroku to Fly.io but I’m coming across the same error every time I try to deploy:

fly deploy
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-aged-dew-5396 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 55.7s (0/1)                                                                                                                  
[+] Building 10.6s (12/21)                                                                                                                
 => [internal] load remote build context                                                                                             0.0s
 => copy /context /                                                                                                                  1.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                           1.7s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14      0.0s
 => [internal] load metadata for docker.io/library/ruby:2.6.6-slim                                                                   0.6s
 => [base 1/5] FROM docker.io/library/ruby:2.6.6-slim@sha256:01bc049d1c0f5f4f0c4567429d97331f79003448bacab38b3b760887f7ca1032        0.0s
 => CACHED [base 2/5] WORKDIR /rails                                                                                                 0.0s
 => CACHED [base 3/5] RUN gem update --system --no-document &&     gem install -N bundler -v 2.2.25                                  0.0s
 => CACHED [base 4/5] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y curl unzip &&     rm -rf /var/lib/ap  0.0s
 => CACHED [base 5/5] RUN curl -fsSL https://fnm.vercel.app/install | bash &&     /root/.local/share/fnm/fnm install 14.15.4         0.0s
 => CANCELED [stage-2 1/2] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y postgresql-client redis &&       6.4s
 => ERROR [build 1/9] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential libpq-dev node-gyp p  6.4s
------                                                                                                                                    
 > [build 1/9] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential libpq-dev node-gyp pkg-config python-is-python3 redis:                                                                                                                      
#12 5.194 Reading package lists...
#12 5.981 Building dependency tree...
#12 6.192 Reading state information...
#12 6.325 E: Unable to locate package python-is-python3
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential libpq-dev node-gyp pkg-config python-is-python3 redis]: exit code: 100

I tried searching to see if anyone has had the same issue but couldn’t find an exact match to this situation.

Here is my dockerfile as well, if it helps:

# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="rails"

# Rails app lives here
WORKDIR /rails

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

# Update gems and preinstall the desired version of bundler
ARG BUNDLER_VERSION=2.2.25
RUN gem update --system --no-document && \
    gem install -N bundler -v ${BUNDLER_VERSION}

# Install packages needed to install nodejs
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl unzip && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install Node.js
ARG NODE_VERSION=14.15.4
RUN curl -fsSL https://fnm.vercel.app/install | bash && \
    /root/.local/share/fnm/fnm install $NODE_VERSION
ENV PATH=/root/.local/share/fnm/aliases/default/bin/:$PATH


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

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential libpq-dev node-gyp pkg-config python-is-python3 redis

# Install yarn
ARG YARN_VERSION=1.22.10
RUN npm install -g yarn@$YARN_VERSION

# ARG BUILD_PACKAGES="git build-essential libpq-dev wget vim curl gzip xz-utils libsqlite3-dev python-is-python3 pkg-config"

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle _${BUNDLER_VERSION}_ install && \
    bundle exec bootsnap precompile --gemfile

# Install node modules
COPY package.json package-lock.json yarn.lock ./
RUN yarn install

# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# 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 needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y postgresql-client redis && \
    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"]

The log reveals the issue: Unable to locate package python-is-python3

Do you need the python-is-python3 package? If not, try remove it from your apt-get install command. If you do need it, maybe try performing the symlink manually.

1 Like

I’ve pushed out a fix. Give it a try:

bundle update
bin/rails generate dockerfile

Accept the changes the to Dockerfile and deploy.

1 Like

Further background in case anybody is interested. ruby-slim docker hub images are based on Debian. The node build process uses Python. The name of the package installing python changed from the Buster release of Debian to the Bullseye release. I analyzed the Dockerhub images for Ruby 2.7.0+ to see where the cutover happened. I didn’t include 2.6 in my analysis.

If you upgrade to 2.6.8, you can use ruby:2.6.8-bullseye as the base. Or you can keep with 2.6.6 and change python-is-python3 to simply python.

The updated dockerfile generator will do the latter.

1 Like

Thank you for your quick reply! I did the following steps:

  1. Ran this code:
bundle update
bin/rails generate dockerfile
  1. Changed python-is-python3 to simply python in the dockerfile.

These definitely made a positive difference when I tried to deploy again, but now running into a new issue. Here are the logs:

$ fly logs -a campq

Waiting for logs...

2023-02-15T12:50:35.900 app[582096d7] nrt [info] Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as root

2023-02-15T12:50:35.917 app[582096d7] nrt [info] 2023/02/15 12:50:35 listening on [fdaa:1:4a78:a7b:b4f1:5820:96d7:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T12:50:37.387 app[582096d7] nrt [info] rails aborted!

2023-02-15T12:50:37.387 app[582096d7] nrt [info] ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:588:in `validate_secret_key_base'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:423:in `secret_key_base'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/secret_key_finder.rb:24:in `key_exists?'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/secret_key_finder.rb:16:in `find'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/rails.rb:37:in `block in <class:Engine>'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `instance_exec'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `run'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:61:in `block in run_initializers'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:60:in `run_initializers'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:363:in `initialize!'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/config/environment.rb:5:in `<main>'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:339:in `require_environment!'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:523:in `block in run_tasks_blocks'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/rake/rake_command.rb:20:in `perform'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/command.rb:48:in `invoke'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands.rb:18:in `<main>'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] ./bin/rails:9:in `<main>'

2023-02-15T12:50:37.387 app[582096d7] nrt [info] Tasks: TOP => db:prepare => db:load_config => environment

2023-02-15T12:50:37.387 app[582096d7] nrt [info] (See full trace by running task with --trace)

2023-02-15T12:50:37.854 app[582096d7] nrt [info] => Booting Puma

2023-02-15T12:50:37.854 app[582096d7] nrt [info] => Rails 6.0.4 application starting in production

2023-02-15T12:50:37.854 app[582096d7] nrt [info] => Run `rails server --help` for more startup options

2023-02-15T12:50:37.895 app[582096d7] nrt [info] Exiting

2023-02-15T12:50:37.895 app[582096d7] nrt [info] /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:588:in `validate_secret_key_base': Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError)

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:423:in `secret_key_base'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/secret_key_finder.rb:24:in `key_exists?'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/secret_key_finder.rb:16:in `find'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/devise-4.8.0/lib/devise/rails.rb:37:in `block in <class:Engine>'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `instance_exec'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:32:in `run'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:61:in `block in run_initializers'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `call'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /usr/local/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/initializable.rb:60:in `run_initializers'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/application.rb:363:in `initialize!'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/config/environment.rb:5:in `<main>'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' require_with_bootsnap_lfi'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `block in require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:291:in `load_dependency'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.4/lib/active_support/dependencies.rb:324:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from config.ru:3:in `block in <main>'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_a

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_a d_options_from_config'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in sta

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in sta t'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:379:in `handle_profiling'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:311:in `start'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/server/server_command.rb:39:in `start'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/server/server_command.rb:147:in `block in perform'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/server/server_command.rb:138:in `tap'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands/server/server_command.rb:138:in `perform'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/command/base.rb:69:in `perform'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/command.rb:46:in `invoke'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/railties-6.0.4/lib/rails/commands.rb:18:in `<main>'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'

2023-02-15T12:50:37.896 app[582096d7] nrt [info] from /rails/bin/rails:9:in `<main>'

2023-02-15T12:50:37.911 app[582096d7] nrt [info] Starting clean up.

I see that the 4th log in the list says ArgumentError: Missing secret_key_basefor 'production' environment, set this string withrails credentials:edit``. So is this new problem stemming from me not setting up secret keys and env variables yet?

Following the documentation for migrating from Heroku, I tried to run this:

heroku config -s | grep -v -e "DATABASE_URL" -e "REDIS_URL" -e "REDIS_TLS_URL" | fly secrets import

But got the following error:

›   Error: Missing required flag:
 ›    -a, --app APP  app to run command against
 ›   See more help with --help
Error requires at least one SECRET=VALUE pair

Hello Aidan,

It looks like “SECRET_KEY_BASE” is not set, you can set it with:

fly secrets set SECRET_KEY_BASE=<long_value>

Also, this string should be run in the application folder:

heroku config -s | grep -v -e "DATABASE_URL" -e "REDIS_URL" -e "REDIS_TLS_URL" | fly secrets import

Or your application name should be set as:

... | fly secrets import -a <application_name>

Hello Andrey,

Thank you for your reply. Apologies, this might be a silly question but I couldn’t find the answer after some searching - where do I find the “SECRET_KEY_BASE”? Or do I set a random value myself?

Does it show the key?

heroku config -s 

For Rails 5.2 applications onward, SECRET_KEY_BASE is encrypted and stored in config/credentials.yml.enc. What you want to do is to copy over the RAILS_MASTER_KEY from heroku:

heroku config -s | grep -v -e "RAILS_MASTER_KEY" | fly secrets import

For many applications, the secret key is the only secret stored in config/credentials.yml.enc. If so, you can generate a new one by deleting that file and then running:

bin/rails credentials:edit

Check your source code for Rails.application.credentials to see if you are using any other credentials.

1 Like

Nope, this is what I’m getting in response:

➜  CampQ git:(master) heroku config -s 
 ›   Error: Missing required flag:
 ›    -a, --app APP  app to run command against
 ›   See more help with --help

Could this be because I am not the dev who set up Heroku, it was done by one of my partners?

Unfortunately, heroku config -s | grep -v -e "RAILS_MASTER_KEY" | fly secrets import returned the same error as previously:

➜  CampQ git:(master) heroku config -s | grep -v -e "RAILS_MASTER_KEY" | fly secrets import                                       
Update available 0.0.456 -> 0.0.457.
Run "fly version update" to upgrade.
 ›   Error: Missing required flag:
 ›    -a, --app APP  app to run command against
 ›   See more help with --help
Error requires at least one SECRET=VALUE pair

As I just mentioned in another response, could this be because Heroku was not set up by myself, but by another person?

I suppose that most likely heroku config -s should be run in your application folder or you can replace it with heroku config -a <application_name> -s.

1 Like