Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Cannot install php@7.1 on macOS Catalina #27

Closed
claudiu-cristea opened this issue Aug 19, 2020 · 8 comments
Closed

Cannot install php@7.1 on macOS Catalina #27

claudiu-cristea opened this issue Aug 19, 2020 · 8 comments

Comments

@claudiu-cristea
Copy link

claudiu-cristea commented Aug 19, 2020

macOS Catalina 10.15.6 (19G2021

Homebrew 2.4.12
Homebrew/homebrew-core (git revision 0d797; last commit 2020-08-19)
Homebrew/homebrew-cask (git revision c5765; last commit 2020-08-19)

I tried:

$ brew brew install php@7.1

This shows the error:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/Cellar/php@7.1/7.1.33/bin/php
  Reason: image not found
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall exolnet/deprecated/php@7.1`

The suggested fix brew postinstall exolnet/deprecated/php@7.1 didn't work either

Then I tried to install from source:

$ brew reinstall --build-from-source php@7.1

This crashes with:

==> Downloading https://www.php.net/distributions/php-7.1.33.tar.xz
Already downloaded: /Users/clau/Library/Caches/Homebrew/downloads/947253863d40b36e7d22cab588e833b5b73e03f7f17fb3c5cce4531750d09e99--php-7.1.33.tar.xz
==> Reinstalling exolnet/deprecated/php@7.1
==> Patching
patching file acinclude.m4
Hunk #1 succeeded at 444 (offset 3 lines).
Hunk #2 succeeded at 459 (offset 3 lines).
Hunk #3 succeeded at 494 (offset 3 lines).
Hunk #4 succeeded at 506 (offset 3 lines).
Hunk #5 succeeded at 2541 (offset 122 lines).
==> ./buildconf --force
==> ./configure --prefix=/usr/local/Cellar/php@7.1/7.1.33 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.1 --with-config-file-path=/u
==> make
Last 15 lines from /Users/clau/Library/Logs/Homebrew/php@7.1/03.make:
int zend_sprintf(char *buffer, const char *format, ...);
    ^
In file included from /private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/ext/intl/dateformat/dateformat_format_object.cpp:32:
In file included from /private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/ext/date/php_date.h:24:
In file included from /private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/ext/date/lib/timelib.h:28:
In file included from /private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/ext/date/lib/timelib_structs.h:29:
In file included from /private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/ext/date/lib/timelib_config.h:4:
/private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/main/php_config.h:2513:5: error: declaration of 'zend_sprintf' has a different language linkage
int zend_sprintf(char *buffer, const char *format, ...);
    ^
/private/tmp/php@7.1-20200819-30111-1yhcpzk/php-7.1.33/main/php_config.h:2513:5: note: previous declaration is here
int zend_sprintf(char *buffer, const char *format, ...);
    ^
4 errors generated.
make: *** [ext/intl/dateformat/dateformat_format_object.lo] Error 1

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/exolnet/homebrew-deprecated/issues

These open issues may also help:
'Library not loaded' for PHP@7.1 https://github.com/eXolnet/homebrew-deprecated/issues/24
PHP 7.1 - configure: error: Cannot find zlib https://github.com/eXolnet/homebrew-deprecated/issues/16
PHP 7.1 - Undefined symbols for architecture x86_64: "_tidyLibraryVersion" https://github.com/eXolnet/homebrew-deprecated/issues/18

Any idea?

@moby18
Copy link

moby18 commented Sep 21, 2020

Hi @claudiu-cristea
Today I have been struggling with the same error.
I used this manual - https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions.
Good manual, but it doesn't work for me in case of installation of PHP 7.1.

  1. I start with brew reinstall --build-from-source php@7.1
% brew reinstall --build-from-source php@7.1
==> Downloading https://homebrew.bintray.com/bottles/icu4c-67.1.catalina.bottle.tar.gz
Already downloaded: /Users/apetrash/Library/Caches/Homebrew/downloads/e045a709e2e21df31e66144a637f0c77dfc154f60183c89e6b04afa2fbda28ba--icu4c-67.1.catalina.bottle.tar.gz
==> Downloading https://www.php.net/distributions/php-7.1.33.tar.xz
Already downloaded: /Users/apetrash/Library/Caches/Homebrew/downloads/947253863d40b36e7d22cab588e833b5b73e03f7f17fb3c5cce4531750d09e99--php-7.1.33.tar.xz
==> Reinstalling exolnet/deprecated/php@7.1 
==> Installing dependencies for exolnet/deprecated/php@7.1: icu4c
==> Installing exolnet/deprecated/php@7.1 dependency: icu4c
==> Pouring icu4c-67.1.catalina.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/icu4c/67.1: 258 files, 71.2MB
==> Installing exolnet/deprecated/php@7.1
==> Patching
==> ./buildconf --force
==> ./configure --prefix=/usr/local/Cellar/php@7.1/7.1.33 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.1 --with-config-file-path=/usr/loca
==> make
Last 15 lines from /Users/apetrash/Library/Logs/Homebrew/php@7.1/03.make:
In file included from /private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/ext/intl/timezone/timezone_methods.cpp:36:
In file included from /private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/ext/date/php_date.h:24:
In file included from /private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/ext/date/lib/timelib.h:28:
In file included from /private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/ext/date/lib/timelib_structs.h:29:
In file included from /private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/ext/date/lib/timelib_config.h:4:
/private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/main/php_config.h:2513:5: error: declaration of 'zend_sprintf' has a different language linkage
int zend_sprintf(char *buffer, const char *format, ...);
    ^
/private/tmp/php@7.1-20200921-34530-1wqy11/php-7.1.33/main/php_config.h:2513:5: note: previous declaration is here
int zend_sprintf(char *buffer, const char *format, ...);
    ^
4 errors generated.
make: *** [ext/intl/timezone/timezone_class.lo] Error 1
4 errors generated.
make: *** [ext/intl/timezone/timezone_methods.lo] Error 1

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/exolnet/homebrew-deprecated/issues

These open issues may also help:
Cannot install php@7.1 on macOS Catalina https://github.com/eXolnet/homebrew-deprecated/issues/27
'Library not loaded' for PHP@7.1 https://github.com/eXolnet/homebrew-deprecated/issues/24
PHP 7.1 - configure: error: Cannot find zlib https://github.com/eXolnet/homebrew-deprecated/issues/16
PHP 7.1 - Undefined symbols for architecture x86_64: "_tidyLibraryVersion" https://github.com/eXolnet/homebrew-deprecated/issues/18
  1. Then I have tried

brew install php@7.1

% brew install php@7.1                   
==> Installing php@7.1 from exolnet/deprecated
==> Downloading https://dl.bintray.com/exolnet/bottles-deprecated/php%407.1-7.1.33.catalina.bottle.1.tar.gz
Already downloaded: /Users/apetrash/Library/Caches/Homebrew/downloads/f8a63db8b82614f57691f6a803a7a64b916376175a61ce4dcd41f9e1622a9099--php@7.1-7.1.33.catalina.bottle.1.tar.gz
==> Pouring php@7.1-7.1.33.catalina.bottle.1.tar.gz
==> /usr/local/Cellar/php@7.1/7.1.33/bin/pear config-set php_ini /usr/local/etc/php/7.1/php.ini system
Last 15 lines from /Users/apetrash/Library/Logs/Homebrew/php@7.1/post_install.01.pear:
2020-09-21 16:27:05 +0300

/usr/local/Cellar/php@7.1/7.1.33/bin/pear
config-set
php_ini
/usr/local/etc/php/7.1/php.ini
system

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/Cellar/php@7.1/7.1.33/bin/php
  Reason: image not found
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall exolnet/deprecated/php@7.1`
  1. dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib - error means that it could not find the file libicui18n.64.dylib. It's means that PHP needs extension ico4c version 64.

  2. Using this comment https://stackoverflow.com/a/55828190 I installed ico4c version 64.2 with brew.

  3. Now when I run

% brew list --versions icu4c
icu4c 64.2 67.1

I had two versions of icu4c are installed.

  1. So I have to run **brew switch icu4c 64.2** to switch version to 64.2.

  2. Then I run

% brew install php@7.1                     
Warning: exolnet/deprecated/php@7.1 7.1.33 is already installed and up-to-date
To reinstall 7.1.33, run `brew reinstall php@7.1`

Because I had been trying to install it before.

  1. brew reinstall php@7.1 - and all works.

@ningkexin
Copy link

I also met here

@mmpedicone
Copy link

mmpedicone commented Oct 3, 2020

@claudiu-cristea I'm not sure if you've resolved for your needs, but in case you found a similar issue as me (after experiencing the issues both in #24 and #27 here), described as:

  • Was following the instructions above from @moby18 comment (which was amazingly helpful, as well), but ran into issue with step # 3 from the answer in the linked comment in @moby18 's step # 4

  • I had executed git log --follow icu4c.rb in step 2 and gotten a log that didn't back up all the way to the 64.2 bottle update

  • So when I attempted to execute git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7 as in the instruction, I received "fatal: reference is not a tree"

  • I went to Homebrew/homebrew-core, found the icu4c.rb file, looked into commit history, and found the commit 896d1018c7a4906f2c3fa1386aaf283497db60a2 for the 64.2 bottle version (which is the version specified in the initial error from issue 'Library not loaded' for PHP@7.1 #24 , updating the command to use this commit return the same fatal error. I git pull, git fetch, and attempted again to still receive the fatal error.

  • After running git fetch in the Formula working directory, I re-ran the git log --follow icu4c.rb command and got a more complete log.

  • Luckily, the very last log now in the list was for commit 2a369a82c7f5b3b2ab2704ff0796635514aae955 , just before the icu4c 66.1 bottle update commit

  • I replaced this into the step # 3 from linked article : git checkout -b icu4c-64 2a369a82c7f5b3b2ab2704ff0796635514aae955

  • Then just needed to do step # 4 : brew reinstall ./icu4c.rb (I didn't need to switch versions or checkout master after this)

  • I resumed steps here in this issue's answer from moby: brew list --versions icu4c to confirm I updated to 64.2

  • Then brew reinstall php@7.1 (because I also attempted before)

And finally after two days of struggle I could continue on with my original project.

Thank you @claudiu-cristea and @moby18 for asking and answering these questions. Saved my sanity.

@johnkary
Copy link

johnkary commented Nov 3, 2020

Thank you everyone posting above. I hope this post brings all the info above into one place.

At one point I installed PHP 7.4 with Homebrew when working on another project, but wanted to go back to 7.1. This meant I had an even newer version of icu4c that had to be switched out.

# Reinstall icu4c 64.2 (required by PHP 7.1) using its old Homebrew formula
$ cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
$ git checkout 2a369a82c7f5b3b2ab2704ff0796635514aae955
$ brew reinstall ./icu4c.rb

# Force Homebrew to use icu4c 64.2 even if other versions are installed
$ brew switch icu4c 64.2

# Reinstall PHP 7.1
$ brew reinstall php@7.1

# Ensure PHP 7.1 is present in /usr/local/bin/php
$ brew link php@7.1

# Verify which PHP is found according to your $PATH, it should output /usr/local/bin/php
$ which php
/usr/local/bin/php

# Verify PHP is using 7.1 from Homebrew
$ php -v
PHP 7.1.33 (cli) (built: Dec 19 2019 11:01:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

@ammmze
Copy link

ammmze commented Nov 11, 2020

I would recommend checking out https://github.com/shivammathur/homebrew-php. I just found out about it but it as of now is actively maintained unlike exolnet's version here.

@Chrisedmo
Copy link

I'm stuck with similar issues - and like @moby18 When i run brew list --versions icu4c i get:
icu4c 64.2 67.1
But when i try brew switch icu4c 64.2 I get :
Error: Calling `brew switch` is disabled! Use `brew link` @-versioned formulae instead.

this is a real pain!

@sergeyjsgpop
Copy link

@Chrisedmo did you solve it?

@pgrenaud
Copy link
Contributor

Hi!

Thank you for your interest in this repository. Unfortunately, this repository will now be archived with no further actions. We are sorry for the inconvenience.

Why are we closing this repository? This repository was only meant as a temporary measure, not a permanent one. Its only purpose was to ease the transition, considering that formulae from the homebrew-core tap are removed almost the day they became unsupported by the vendor. We needed a few more months to allow us to upgrade the code base of the various projects we have. But it was always with the intention of doing those upgrades, not by relying on a repository to keep old php versions artificially alive. We do not condone the use of deprecated software that could lead to serious security vulnerabilities.

Why are we not redirecting to another repository? Redirecting to another repository could be interpreted as an endorsement of said repository. If we were to do such a thing, we would not do it without vetting it first. And we do not wish to put the time and energy required in a vetting process of a third party repository. As the reason why a vetting process would be required, consider this. Before installing a software library on all our developer computers from an untrusted source, we would need to make sure that this software library is free from any malicious code (Trojan, ransomware, etc.), both in the repository itself and in the packaged binaries (the homebrew bottles, if any).

Thank you for your understanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants