/bin/bash: line 1: bin/rails: Permission denied
myxoh
PROOP

3 months ago

The problem started with: /bin/bash: line 1: bin/rails: Permission denied

It happens on the build logs on a specific commit - but building an old commit worked. However nothing about the new commit should have changed that permission.

RUN POSTGRES__DATABASE_HOST="dummy" POSTGRES__DATABASE_REPLICA_HOST="dummy" RELEASE_SHA=REDACTEDSENTRY_AUTH_TOKEN=REDACTEDSECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile

94ms

/bin/sh: 1: ./bin/rails: Permission denied

Dockerfile:62

-------------------

61 | # Precompiling assets for production without requiring secret RAILS_MASTER_KEY

62 | >>> RUN POSTGRES__DATABASE_HOST="dummy" POSTGRES__DATABASE_REPLICA_HOST="dummy" RELEASE_SHA=$RAILWAY_GIT_COMMIT_SHA \

63 | >>> SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN SECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile

64 |

-------------------

ERROR: failed to build: failed to solve: process "/bin/sh -c POSTGRES__DATABASE_HOST=\"dummy\" POSTGRES__DATABASE_REPLICA_HOST=\"dummy\" RELEASE_SHA=$RAILWAY_GIT_COMMIT_SHA SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN SECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile" did not complete successfully: exit code: 12

We've since deployed a change that will add chmod +X to bin (more details to come)

Solved

15 Replies

myxoh
PROOP

3 months ago

After adding +X one of our services (background workers) started working, another one - for seemingly no good reason - started failing to deploy:

bin/rails aborted!

TypeError: no implicit conversion of nil into String (TypeError)

Parser.parse(source, opts)

This came from reading a configuration file relying on the RAILS_MASTER_KEY that's definetely available on that (and other services) - as nothing had changed.

Confusingly enough this only happens to our web server.

So the situation is:

- Background job service 1: Has never experienced any problem (build or deploy)

- Background job service 2: Experienced a problem on build, that got fixed after chmod +X

  • Web server: Experienced a problem on build, and after chmod +X started experiencing a deploy problem as it looks like some env variables are not making it through.

3 months ago

This is a long shot but: Instead of adding a chmod +X, add this env var: "RAILWAY_RUN_UID=0" and tell me how it goes.


myxoh
PROOP

3 months ago

I'll give that a go it'll take me about ~18 mins with our CI so will let you know


myxoh
PROOP

3 months ago

Nope ☹ - after adding that ENV and removing the chmod I'm back to the original issue:

RUN POSTGRES__DATABASE_HOST="dummy" POSTGRES__DATABASE_REPLICA_HOST="dummy" RELEASE_SHA=REDACTED SENTRY_AUTH_TOKEN=REDACTED SECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile

165ms

/bin/sh: 1: ./bin/rails: Permission denied

Dockerfile:65

-------------------

64 | # Precompiling assets for production without requiring secret RAILS_MASTER_KEY

65 | >>> RUN POSTGRES__DATABASE_HOST="dummy" POSTGRES__DATABASE_REPLICA_HOST="dummy" RELEASE_SHA=$RAILWAY_GIT_COMMIT_SHA \

66 | >>> SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN SECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile

67 |

-------------------

ERROR: failed to build: failed to solve: process "/bin/sh -c POSTGRES__DATABASE_HOST=\"dummy\" POSTGRES__DATABASE_REPLICA_HOST=\"dummy\" RELEASE_SHA=$RAILWAY_GIT_COMMIT_SHA SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN SECRET_KEY_BASE_DUMMY=1 SKIP_REDIS=true ./bin/rails assets:precompile" did not complete successfully: exit code: 126


myxoh
PROOP

3 months ago

Any other ideas?


myxoh
PROOP

3 months ago

@medim ?


3 months ago

Also having this exact issue out of nowhere. Old commits work. There are no code changes that would've caused this. Already had "RAILWAY_RUN_UID=0" and still not working. Following to see what the solution ends up being for you because I'm at a loss 👀


jkogara
PRO

3 months ago

Just to clarify on this one -https://station.railway.com/questions/bin-bash-line-1-bin-rails-permission-2994729e#5jcp - when we have the execs chmodded the deploy step that's failing is a pre-deploy. It appears as though env variables are missing in the pre-deploy but not in deploy


shxkm
PRO

3 months ago

I'm getting almost the exact same error: "/bin/sh: 1: ../run: Permission denied". No recent changes to code that would've caused those, nor am I trying to deploy any code remotely related to the error.


abreu
PRO

3 months ago

I’m facing the same issue. No changes on the deploy config or relevant code changes that could impact on that.


jkogara
PRO

3 months ago

So switching to "Metal" builds "fixed" this for us.


abreu
PRO

3 months ago

Thanks, jkogara. I also switched to "metal" and solved the issue.


eastraining
PRO

3 months ago

Same for me, thanks guys.


3 months ago

Hello,

Thank you for reporting this. We are going to be looking into this.


Status changed to Awaiting User Response Railway 3 months ago


sam-a
EMPLOYEE

3 months ago

This should be fixed. Let us know if you still have issues.


Status changed to Solved sam-a 3 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...