Search code examples
ruby-on-railsheroku

`heroku open` and `heroku run rake db:migrate` not working ("No such file or directory")


I have a Rails 7 app and as of my most recent commit, the entire Heroku production site errors regardless of what page I'm trying to access.

Of course, I tried to do heroku logs -t to figure out what happened but when I try to do command line commands for heroku (such as heroku logs, heroku open, or heroku run rake db:migrate) I am met with the following error:

/usr/local/Cellar/heroku/8.5.0/lib/client/bin/heroku: line 16: /usr/local/Cellar/heroku/8.5.0/lib/client/bin/../8.7.1-3f5e369/bin/heroku: No such file or directory

As recommended in posts like this, I have tried rake rails:update:bin, but it errors and recommends Did you mean? app:update:bin...which does run successfully but does not fix my heroku error.

Has anyone else had this problem? I'm not sure what changes I could have made that caused it so suddenly because the push in question didn't change any config variables or settings other than normal content update stuff.

I would check my Heroku logs or see if I could run heroku run rails c....but I can't because I get the same error....

EDIT: If I rollback my most recent update I am able to actually see my Heroku site without the entire thing throwing an error, but I still can't run any command line heroku commands and any subsequent pushes break the entire production site again.


Solution

  • The error is not happening at your repo level, but within the script file on your local machine that executes when you call heroku from the command line. I encountered something similar yesterday after accessing Heroku for the first time in a while.

    The script is trying to locate a local directory where all its resources are stored; it decides everything should be in a particular location, but there's nothing there when it goes to look.

    I executed the following commands, after which everything was back to normal:

    brew uninstall heroku
    brew cleanup # this may not be necessary, but I don't have a record of what would happen if I hadn't run it
    brew install heroku
    heroku auth:login # to re-authenticate with heroku