4
votes

I'm brand new to Rails and am following this tutorial on how to make Rails applications. I can't get the database to migrate to my heroku apps.

I'm currently at the beginning of chapter 3, trying to set up an app to use for the rest of the course.

I've been following the tutorial perfectly, and, so far, I've already built two apps and deployed them to heroku and migrated the data just fine, but the third time it's not working.

I was able to make the heroku page and push the app to it, but I just can't migrate the data.

I typed:

heroku run rake db:migrate

and got this error:

/usr/bin/env: ruby.exe: No such file or directory.

I'm assuming this means it's looking for the file in that directory and not finding it. How do I change where it's looking?

I checked "windows heroku run rake db:migrate error “/usr/bin/env: ruby.exe: No such file or directory”" and did what the answers recommended, that is, change "ruby.exe" to "ruby" in bin/bundle, bin/rails, and bin/rake, but that didn't work.

Any other tips? I have been stuck on this for hours. Thank you so much in advance.

3
How did you install Ruby? Rails? The Heroku tools? Are you running under rvm? Rbenv? - Dave Newton
Does it say a filename that's causing this error? You probably have a bad shebang somewhere. - Alex Wayne
What is your operating system? What is your $PATH? Where is ruby.exe? On Linux it probably is just ruby! - Basile Starynkevitch
I installed Ruby, Rails, and the Heroku toolbelt. I installed ruby and rails via RailsInstaller. My operating system is Windows 7. - Artur Upton Renault
is ruby.exe located in a directory in your PATH environment variable? - rogerdpack

3 Answers

2
votes

The command is normally heroku run rake db:migrate. You should try that instead of heroku run rails db:migrate.

Make sure you've pushed your app to heroku. When it's pushing to heroku, make sure that it is also detected as a rails app. It's possible that heroku isn't detecting a rails app so the environment it sets up doesn't have ruby installed. But it may just be the error in the command name (rails instead of rake).

2
votes

I had a similar problem on a repository I had ported over from windows.

It turns out that several scripts in the app's bin directory still had a shebang lines (#!/usr/bin/env ruby.exe) to ruby.exe instead of ruby. Once I fixed these scripts the problem went away.

0
votes

On your local dev machine, before committing to git (and then pushing to Heroku), try changing the line endings to Unix line endings (rather than Windows line endings). On a *nix machine you'd do that by running dos2unix myfile.rb

If the line endings are wrong, the Linux loaded on Heroku will look for ruby^M and not for ruby, and will of course not find it, and give this exact error message.