Error: failed to spawn command: ./start.sh: Permission denied (os error 13)

Using Remix run receiving Error: failed to spawn command: ./start.sh: Permission denied (os error 13) upon building.

Any idea?

Hey @netdesignr! Have you double-checked that start.sh has execute permissions? Perhaps you’re running into the same thing as this thread.

The error persits

2023-05-01T19:27:24.513 app[3287d91a009085] otp [info] Starting init (commit: 15c0f38)...

2023-05-01T19:27:24.529 app[3287d91a009085] otp [info] Preparing to run: `./start.sh` as root

2023-05-01T19:27:24.534 app[3287d91a009085] otp [info] Error: failed to spawn command: ./start.sh: Exec format error (os error 8)

2023-05-01T19:27:24.534 app[3287d91a009085] otp [info] [ 0.100508] reboot: Restarting system

2023-05-01T19:27:24.586 app[3287d91a009085] otp [warn] Virtual machine exited abruptly

2023-05-01T19:27:25.483 runner[3287d91a009085] otp [info] machine exited with exit code 0, not restarting

2023-05-01T19:41:28.962 runner[e2861defeed486] otp [info] Pulling container image registry.fly.io/truckopedia-staging:deployment-01GZCD7D5SDDGY80G99QCK9BPY

2023-05-01T19:41:34.525 runner[e2861defeed486] otp [info] Unpacking image

2023-05-01T19:41:43.485 runner[e2861defeed486] otp [info] Successfully prepared image registry.fly.io/truckopedia-staging:deployment-01GZCD7D5SDDGY80G99QCK9BPY

2023-05-01T19:41:43.676 runner[e2861defeed486] otp [info] Configuring firecracker
Updating existing machines in 'truckopedia-staging' with rolling strategy
  [1/2] Waiting for e2861defeed486 [app] to have state: started
Error: timeout reached waiting for machine to started failed to wait for VM e2861defeed486 in started state: Get "https://api.machines.dev/v1/apps/truckopedia-staging/machines/e2861defeed486/wait?instance_id=01GZCDB5F4FTDG2SVWMYR37MTG&state=started&timeout=60": net/http: request canceled```

Would you feel comfortable your Dockerfile here? If not, you could always email it to support@fly.io and I could help you further through there.

Email sent, thank you!

Try adding the following line immediately prior to the line in your Dockerfile that starts with CMD:

RUN chmod +x ./start.sh

@rubys thanks for your reply but I don’t have a CMD: inside docker file also I do have WORKDIR /myapp

I’ve added RUN chmod +x /myapp/start.sh prior ENTRYPOINT [ "./start.sh" ] and it doesn’t work.

There’s definitely an issue upgrading to V2

==> Migrating truckopedia to the V2 platform

Locking app to prevent changes during the migration
Enabling machine creation on app
Creating an app release to register this migration
Starting machines

`failed while migrating: timeout reached waiting for machine to started failed to wait for VM 3d8de5dceexxxx in started state: Get “https://api.machines.dev/v1/apps/truckopedia/machines/3d8de5dceexxxx/wait?instance_id=01GZCVMZAZH3MH17ZJASJT37TY&state=started&timeout=60”: net/http: request canceled
==> (!) An error has occurred. Attempting to rollback changes…

Removing machines
Setting platform version to ‘nomad’
Successfully recovered
Unlocking application
Error: timeout reached waiting for machine to started failed to wait for VM 3d8de5dceexxxx in started state: Get “https://api.machines.dev/v1/apps/truckopedia/machines/3d8de5dceexxxx/wait?instance_id=01GZCVMZAZH3MH17ZJASJT37TY&state=started&timeout=60”: net/http: request canceled`

That tends to indicate that the “shebang” comment line in the script has a problem. Can you verify that your start.sh looks like the following:

OK, I’ve reproduced the problem. If you have Windows line endings on the shebang line, you will see this failure. The fix is to add an additional line to the RUN command, thus:

RUN chmod +x ./start.sh && \
    sed -i "s/\r$//g" ./start.sh

Note: this command will run relative to the working directory, so ./ is fine, but /myapp will work too.

1 Like

@rubys doing what you recommended literally fixed the issues.

One interesting fact is that if I was dong RUN chmod +x ./start.sh it worked to up to the point to upgrade to V2.

Doing the below solved the timeout I was receiving during the upgrade

RUN chmod +x ./start.sh && \
    sed -i "s/\r$//g" ./start.sh

Cool. I’m working on a new dockerfile generator for node, and I’ve created an issue to file this. I’m also working with the remix team to replace their dockerfile template with this generator.

I’ve managed to recreate the whole thing and now the application is back in stable mode, cheers @rubys

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.