henkrehorst / homebrew-php

brewtap for valet plus
42 stars 29 forks source link

Installing fails with error at make stage #158

Open chrisgan opened 2 years ago

chrisgan commented 2 years ago

I am running on M1 Mac on Monterey. I've tried a few different ways of installing valet-php

brew install valet-php@7.3 brew install valet-php@7.4

And with the --build-from-source option as well. All fail with an error at the 'make' stage

`/opt/homebrew/Cellar/icu4c/70.1/include/unicode/brkiter.h:127:18: note: overridden virtual function is here virtual bool operator==(const BreakIterator&) const = 0;


1 error generated.
make: *** [ext/intl/breakiterator/breakiterator_class.lo] Error 1
make: *** Waiting for unfinished jobs....
In file included from /private/tmp/valet-phpA7.3-20220304-15107-1pzh3ic/php-7.3.27/ext/intl/breakiterator/breakiterator_methods.cpp:22:
/private/tmp/valet-phpA7.3-20220304-15107-1pzh3ic/php-7.3.27/ext/intl/breakiterator/codepointiterator_internal.h:42:17: error: virtual function 'operator==' has a different return type ('UBool' (aka 'signed char')) than the function it overrides (which has return type 'bool')
                virtual UBool operator==(const BreakIterator& that) const;
                        ~~~~~ ^
/opt/homebrew/Cellar/icu4c/70.1/include/unicode/brkiter.h:127:18: note: overridden virtual function is here
    virtual bool operator==(const BreakIterator&) const = 0;
            ~~~~ ^
1 error generated.
make: *** [ext/intl/breakiterator/breakiterator_methods.lo] Error 1`
sammykrich commented 2 years ago

It's related to this: https://github.com/php/php-src/pull/7596

brew edit valet-php@7.4 - If I update to use PHP 7.4.28, installation is successful.

url "https://www.php.net/distributions/php-7.4.28.tar.xz" sha256 "9cc3b6f6217b60582f78566b3814532c4b71d517876c25013ae51811e65d8fce"

The latest version of 7.3 doesn't have the fix so updating it won't help.

alexryans commented 2 years ago

Does anyone know what the best URL and SHAs are to use with PHP 5.6, 7.0 and 7.1? I need to support some legacy projects on these PHP versions which are also exhibiting the above error on make, but the PHP website currently (and understandably) only lists PHP 7.4, 8.0 and 8.1.

nickolasburr commented 2 years ago

For those who need php/php-src#7596 backported to an older version, I've put together patches for 7.2 & 7.3.

valet-php@7.2-icu.patch valet-php@7.3-icu.patch

If you're using Homebrew, you can brew edit valet-php@7.3 and add the following lines to the beginning of the formula install method:

 system "/usr/bin/curl", "-fsLO", "https://gist.githubusercontent.com/nickolasburr/d24481ded3dcf19d5fc45ccb9892b0cd/raw/8e39f300b24c984183fc24fbc68a6608bf33f832/valet-php@7.3-icu.patch"
 system "/usr/bin/git", "apply", "-v", "valet-php\@7.3-icu.patch"

Then run brew install --build-from-source valet-php@7.3

laconica-roma commented 2 years ago

Does anyone know what the best URL and SHAs are to use with PHP 5.6, 7.0 and 7.1? I need to support some legacy projects on these PHP versions which are also exhibiting the above error on make, but the PHP website currently (and understandably) only lists PHP 7.4, 8.0 and 8.1.

same question

PieterCappelle commented 2 years ago

To fix this for valet-php@8.0 use the following command brew edit valet-php@8.0. Afterwards edit the URL to https://www.php.net/distributions/php-8.0.17.tar.xz and the sha256 to 4e7d94bb3d144412cb8b2adeb599fb1c6c1d7b357b0d0d0478dc5ef53532ebc5

All info on this page > https://www.php.net/downloads.php.

alexryans commented 2 years ago

Sorry to bump this, but I don't suppose there are any patches for PHP 5.6, 7.0 and 7.1 yet, are there? I'm trying to support some legacy projects using Valet+ and can't switch to anything below 7.2 at the minute, which is causing considerable issues.

Maksold commented 2 years ago

For those who need 7.0, 7.1, 7.2 or 7.3.

7.0 Run brew edit valet-php@7.0

Add the following lines before def install:

patch :p0 do
  url "https://gist.githubusercontent.com/Maksold/ea0c8d4d4fb15e2586d28886062e8a42/raw/251857d54a4fba1d9357996026619cee815ba804/php70-icu70.patch"
  sha256 "7f3b8d3a907b135dce2a21957ada5b191d1be89cbe2e36955b14b7429a3f2649"
end

Then run brew install --build-from-source valet-php@7.0

7.1 Run brew edit valet-php@7.1

Add the following lines before def install:

patch do
  url "https://gist.githubusercontent.com/Maksold/90d4b47ae8285c586b18ba7979e3252a/raw/9359fcdcf2bf6879c89778c276a04e7bde668dfe/php71-icu70.patch"
  sha256 "b273efbe4910bdeebb863f79151b340a821f189ac444b783534243321b009c43"
end

Then run brew install --build-from-source valet-php@7.1

7.2 Run brew edit valet-php@7.2

Add the following lines before def install:

patch do
  url "https://gist.githubusercontent.com/Maksold/b83ff5ae970433d5e5cc2e0b0c766935/raw/f837f63d5661e77e6b2d11c14cc8f0f0fb64affb/php72-icu70.patch"
  sha256 "443320beed5c141784dedd7f0be746225de3968b2b6e73fafe79f5c0f566187a"
end

Then run brew install --build-from-source valet-php@7.2

7.3 Run brew edit valet-php@7.3

Add the following lines before def install:

patch do
  url "https://gist.githubusercontent.com/Maksold/5e4c520269977c47d8775edc44ee8b65/raw/44aa7ca46a9f3aee0be125af234e5e5170f37fd2/php73-icu70.patch"
  sha256 "3cfcdaebea1a78a2123682f46587b327d0a0c907be33f47d8e8b0a3751081aa3"
end

Then run brew install --build-from-source valet-php@7.3

Patches are taken from https://github.com/henkrehorst/homebrew-php/pull/160. Very big thanks to @osrecio!

thomascharbit commented 2 years ago

I had to fork the patches and add an empty line at the end of the files to make it work, if you get an error complaining about a malformed patch

elburro1887 commented 1 year ago

@Maksold Thanks for the writeup! Your SHA256 hash for 7.2 seems to be wrong however.

Check: curl https://gist.githubusercontent.com/Maksold/b83ff5ae970433d5e5cc2e0b0c766935/raw/f837f63d5661e77e6b2d11c14cc8f0f0fb64affb/php72-icu70.patch | sha256sum

Output: 443320beed5c141784dedd7f0be746225de3968b2b6e73fafe79f5c0f566187a

So here is the correct one:

PHP 7.2

patch do
  url "https://gist.githubusercontent.com/Maksold/b83ff5ae970433d5e5cc2e0b0c766935/raw/f837f63d5661e77e6b2d11c14cc8f0f0fb64affb/php72-icu70.patch"
  sha256 "443320beed5c141784dedd7f0be746225de3968b2b6e73fafe79f5c0f566187a"
end
Maksold commented 1 year ago

Thanks, @elburro1887! Updated the SHA256 hash for 7.2 in my previous comment.