PHP was not working for me as I was encountering this libpng issue, so I reinstalled a new version with Homebrew.
However, I\'m getting a similar error with
As proposed by @jirson-tavera in the homebrew-php repo issue, this can be fixed without overriding your brew installation:
wget -c http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar xzf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure
make
cp ./.libs/libjpeg.8.dylib /usr/local/opt/jpeg/lib
I had the same problem and I solved it by downloading the libjpeg tarball manuallu from here and running:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a #Optionally
brew switch libjpeg 8d
Valet - mac with php7.1
Following command worked for me.
brew switch libjpeg 8d
Even though the solution in the accepted answer works, it's not the right way to fix the problem. It violates brew's metadata integrity.
The issue is that Homebrew's jpeg
formula has been upgraded to v9 but the existing "bottled" PHP formula is still built and linked against the previous version, v8, which is no longer exists on your system.
You have a few options to fix the issue.
phpxx
formula from source (highly recommended)Uninstall your php formula, and rebuild it from the source instead of using the bottled version. This way, php will use and link against the currently installed version of jpeg
. Assuming that you're dealing with php71
:
brew reinstall php71 --build-from-source
jpeg
formula the right way (preferred over recompiling it manually)If you haven't run brew cleanup
, you already got the previous jpeg
version in your brew's cellar, switch to it:
brew switch jpeg 8d
If you get a jpeg does not have a version "8d" in the Cellar.
error, you need to first restore it by reverting the history:
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout b231469
HOMEBREW_NO_AUTO_UPDATE=1 brew install jpeg
git checkout master
brew switch jpeg 8d
You can find out the commit hash by using brew log jpeg
and going through the commit messages.
The downside is that there might be other formulas that require the newer version to work properly, e.g. imagemagick
. If you face such incompatibility issues, check the first solution above.
jpeg
by manually recompiling (not recommended)Fetch the source, compile and overwrite brew's version. Refer to Denis' answer for details.
This is not recommended because it violates the integrity of your brew metadata. Brew thinks that it has the 8b version, however, you manually compiled 9b and overwrote the files.
Do not manually symlink the leftover libjpeg.8.dylib
. If the file is there, you can just brew switch
to it as mentioned in the second solution above.
It's just the worst hack you can do here.
Such issues will be eventually fixed.
As @lifecom notes, this is fixed with homebrew's php70 update, but you might still run into the problem if brew upgrade
is trying to update other packages before upgrading php70.
Fix this by manually updating php70 first with brew upgrade php70
and you then should be able to run brew upgrade
no problem (or, well, at least without this problem).