Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku CLI psql command no longer works

All of my Heroku commands appear to be working except the one to get to a command line for my database.

Doing:

heroku pg:psql -a myapp

yields:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/psql
  Reason: image not found

I have had problems with this "readline" before. I'm not sure what it does, or why it is necessary, but how can I overcome this?

I'm running this on Mac OSX Sierra and I've installed Heroku with Homebrew.

heroku CLI version:

heroku/7.19.4 darwin-x64 node-v11.3.0
like image 907
AKWF Avatar asked Dec 06 '25 18:12

AKWF


2 Answers

Readline is a library that "for use by applications that allow users to edit command lines as they are typed in".

For me, brew updated the version of readline from 7 (as seen in the error message above) to 8. You can confirm this by listing the contents of the directory that psql is looking in: ls /usr/local/opt/readline/lib/

I fixed this by upgrading postgres: brew upgrade postgres. Note that this will upgrade the version of Postgres running on your system. This worked seamlessly for me (I'm now running psgl 11.1 with a DB server of 9.6.8) but be aware of what you are upgrading and make sure things work afterwards.

I found this blog post helpful.

https://medium.com/@limichelle21/rails-5-troubleshooting-database-migration-from-sqlite3-to-postgresql-45bcb2ff0cb9

See also this SO: Can't run psql command, keep getting the same error

like image 109
Neal Audenaert Avatar answered Dec 09 '25 22:12

Neal Audenaert


It looks like this issue is caused by psql not finding a necessary dependency it needs, in this case readline.

If you don't have the readline library dependency I'd try installing readline with Homebrew:

brew install readline

However, if you already have readline library installed perhaps the image got messed up somewhere along the line so I'd try reinstalling and linking the library:

brew remove readline
brew install readline
brew link readline --force

Hopefully that helps!

like image 36
Nathan Avatar answered Dec 09 '25 21:12

Nathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!