4

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.

Community
  • 1
  • 1

3 Answers3

2

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).

Ryan Endacott
  • 7,376
  • 4
  • 24
  • 39
1

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.

Kevin Panko
  • 7,844
  • 19
  • 46
  • 58
cookem
  • 33
  • 5
  • Thank you for posting this. I couldn't figure out what was going on and then saw your comment and that solved my problem. I had downloaded a repo that was created on a Windows machine apparently. – Blimey85 Jun 24 '17 at 16:35
0

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.

Nitzan Shaked
  • 12,530
  • 5
  • 42
  • 54