heroku /usr/bin/env: ‘ruby.exe\\r’: No such file o

2020-03-30 04:41发布

问题:

So I have been deploying my app to the same heroku server for the past few weeks and it has been working great.

I just tried to deploy my latest code and got this error when trying to run:

heroku run rails db:migrate

The error I got was this:

/usr/bin/env: ‘ruby.exe\r’: No such file or directory problem

I have looked at many other threads concerning this problem and taken their advice.

The most common answer was to change the first line of the bin/bundle, bin/rails and bin/rake folders from this:

#!/usr/bin/env ruby.exe

To this:

#!/usr/bin/env ruby

However did this not work for me and I keep getting the same error

Any other possible solutions to this problem?

I am running on a windows machine

回答1:

I had the same issue here, running Rails 5 . Though I am not 100% sure, I believe it happened because of a problem with the line endings on the bin/ files.

I altered the global seeting on Git, dealing with line endings:

$ git config --global core.autocrlf true

And then updated the bin files, with:

rails app:update:bin

(on previous rails versions it goes by rake rails:update:bin)

More on how Git deals with this issue (and how to refresh a repository, if necessary) here: https://help.github.com/articles/dealing-with-line-endings/