Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php -v returns dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

Tags:

php

macos

I was trying to install Valet and for a mistake I uninstall php from brew, now I reinstall php, if I go to a phpinfo() file on apache I can see

PHP Version 7.1.23

but if I do php -v on console, or something other php command i get:

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

Im on Mac Os Sierra

like image 240
Pedro Avatar asked Mar 10 '19 23:03

Pedro


3 Answers

There's a couple of ways you could try to resolve this:

$ brew link readline

or perhaps:

$ brew link readline --force

If that doesn't work try:

$ cd /usr/local/opt/readline/lib/
$ ln -s libreadline.dylib libreadline.7.dylib

↳ Github Discussion : libreadline (image not found)

like image 91
l'L'l Avatar answered Nov 11 '22 19:11

l'L'l


For me, I had php 5.4 installed, but an upgrade to php 7.3 worked for me.

brew install [email protected]

Then you'll likely need to add the new php version in your path. This basically means that when you load up your shell it knows where find the path to the files that you are using. For me, since I'm using zshrc that command is:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For you, if you have all your path and aliases in bash profile then the command would be this instead:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile

Then, all you need to do is either source your zshrc or your bash_profile file, OR close that tab and open a new one. The source command basically says "hey, make sure you have an updated list of my aliases and path info". This naturally happens when you open a new shell, but you can force that with a command like:

source ~/.bash_profile

And then it worked for me. Good luck.

like image 25
Maximus Avatar answered Nov 11 '22 19:11

Maximus


Try this:

$ cd /usr/local/opt/readline/lib/
$ ln -s libreadline.dylib libreadline.7.dylib

Then :

brew unlink readline && brew link --force readline
like image 1
LimitlessV Avatar answered Nov 11 '22 21:11

LimitlessV