Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/bin/rails assets:precompile" did not complete successfully: exit code: 1 randomly fails #849

Open
eddygarcas opened this issue Jun 20, 2024 · 1 comment

Comments

@eddygarcas
Copy link

Hi,

I saw there was a similar issue in the past regarding this error when precompiling assets. It was suggested that it was a Ruby issue and recommended to wait until Ruby 3.3.1 is released.

In my case, this issue is still happening with the following setup:

Ruby 3.3.1
Kamal 1.7.0
Rails 7.1.3

When running kamal deploy -d staging, I eventually get the following error:

------
kamal-backoffice-service.dockerfile:45
--------------------
  43 |     #    SECRET_KEY_BASE_DUMMY=1 RAILS_MASTER_KEY=$RAILS_MASTER_KEY ./bin/rails assets:precompile
  44 |     
  45 | >>> RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
  46 |     
  47 |     # Final stage for app image
--------------------
ERROR: failed to solve: process "/bin/sh -c SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile" did not complete successfully: exit code: 1

When I run the docker-compose, the whole process works, but running kamal deploy fails. I've also tried to pass the RAILS_MASTER_KEY as an argument into the build process, but it keeps failing:

# Set up a secret mount and precompile assets
RUN --mount=type=secret,id=RAILS_MASTER_KEY \
    RAILS_MASTER_KEY=$(cat /run/secrets/RAILS_MASTER_KEY) && \
    SECRET_KEY_BASE_DUMMY=1 RAILS_MASTER_KEY=$RAILS_MASTER_KEY ./bin/rails assets:precompile

Is anyone else facing the same situation?

@oandalib
Copy link

oandalib commented Oct 6, 2024

I was attempting to access credentials like so Rails.application.credentials.gmail.username, whereas I should've been accessing it as Rails.application.credentials.dig(:gmail, :username). Making this change solved the issue for me.

buncis added a commit to buncis/rails that referenced this issue Oct 8, 2024
this is beneficial to avoid issues like this 
basecamp/kamal#849

the problem is there is no dig that raise error if the key is not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants