Rails 5.2.3 windows 10 error: ‘ruby\r’: No such file or directory

Hi, need a little help deploying a Ruby on Rails App here.
Getting this error after running “flyctl deploy”

=> CACHED [stage-3 4/7] COPY --from=gems /usr/local/bundle /usr/local/bundle                                 0.0s
 => CACHED [stage-3 5/7] COPY . .                                                                             0.0s 
 => CACHED [stage-3 6/7] RUN chmod +x /app/bin/* &&     sed -i 's/ruby.exe/ruby/' /app/bin/* &&     sed -i '  0.0s 
 => ERROR [stage-3 7/7] RUN bin/rails fly:build                                                               0.3s 
 > [stage-3 7/7] RUN bin/rails fly:build:
#20 0.315 /usr/bin/env: ‘ruby\r’: No such file or directory
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -o pipefail -c ${BUILD_COMMAND}]: exit code: 127

Try changing that to:

sed -i 's/ruby.exe\r*/ruby/'

If that works for you, I’ll fix flyctl launch for future users.

Hi, thanks for your help. Unfortunately getting the same error.

 => CACHED [stage-3 4/7] COPY --from=gems /usr/local/bundle /usr/local/bundle                      0.0s 
 => [stage-3 5/7] COPY . .                                                                         0.3s 
 => [stage-3 6/7] RUN chmod +x /app/bin/* &&     sed -i 's/ruby.exe\r*/ruby/' /app/bin/* &&     s  0.3s 
 => ERROR [stage-3 7/7] RUN bin/rails fly:build                                                    0.4s 
 > [stage-3 7/7] RUN bin/rails fly:build:
#20 0.346 /usr/bin/env: ‘ruby\r’: No such file or directory

While I am using Windows 11, I can deploy a Rails app from there. Can you try the following command so we can see the contents of your bin\rails file?

ruby -e "p File.open('bin/rails', 'rb') {|file| file.read}"

Here’s what I get:

PS C:\Users\rubys\welcome> ruby -e "p File.open('bin/rails', 'rb') {|file| file.read}"
"#!/usr/bin/env ruby.exe\nAPP_PATH = File.expand_path(\"../config/application\", __dir__)\nrequire_relative \"../config/boot\"\nrequire \"rails/commands\"\n"

I’m having the same error on Windows 11:
/usr/bin/env: ‘ruby\r’: No such file or directory

@paulosiqueira can you run the following command and tell me what you see?

ruby -e "p File.open('bin/rails', 'rb') {|file| file.read}"

Try change

sed -i 's/ruby.exe/ruby/' /app/bin/* && \

or (if you have latest dockerfile, which has updated recently)

sed -i 's/ruby.exe\r*/ruby/' /app/bin/* && \


sed -i 's/ruby\r/ruby/' /app/bin/* && \

inside your docker file

I also encountered this error

‘ruby\r’: No such file or directory

I used this command and uploaded successfully

sed -i 's/ruby.exe\r*/ruby/'

Thank you!