Error: [email protected] has been disabled because it is a versioned formula
Asked Answered
J

8

158

I try to install [email protected] using brew. But, it return error because it is versioned formula. What is it?

command: brew install [email protected]

result: Error: [email protected] has been disabled because it is a versioned formula!

Juno answered 20/12, 2021 at 4:26 Comment(1)
I imagine that PHP 7.3 has been delisted because it is no longer supported.Veronaveronese
A
307

You can only install supported versions of PHP with brew. However, there is the tap shivammathur/php which can be used to install unsupported version of PHP.

  1. brew tap shivammathur/php
  2. brew install shivammathur/php/[email protected]
  3. brew link [email protected]

The first step only needs to be done once. After adding the tap, you can install PHP version 5.6 - 8.2.

Averell answered 20/12, 2021 at 13:48 Comment(3)
This is correct but i needed to do a few more steps. Found in github.com/shivammathur/homebrew-php and THIS->github.com/shivammathur/homebrew-php/wiki/CleanupPsychoactive
I used brew to install python and it deprecated my php! wth! SO this sorted it. Thanks!Seeress
I used this but when I run command php -v it still shows the latest version.Barbirolli
M
80

I applied the same instructions given by @derhansen and worked very well for [email protected]:

brew tap shivammathur/php
brew install shivammathur/php/[email protected]
brew link [email protected]
Misdirection answered 19/12, 2022 at 21:15 Comment(3)
this is just duplicating info 98% of the content in the accepted answer. this should just be a comment to the original.Carbazole
And yet, I was happy to copy and paste this for php 7.4 /grin. I'm now smiling at the idea of making an answer now for [email protected], knowing that it will become useful to someone on Nov 27, 2023 (not really do it, but smiling at the thought)Cliffordclift
Well, this worked for me.Verve
M
69

You can also edit the formula and re-enable it. These steps worked for me in May 2023:

  1. brew edit [email protected]
  2. Look for disable! date: "2022-11-28", because: :versioned_formula. Change 2022 to 2024 (or later).
  3. HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source [email protected]

Notes:

  • A recent Homebrew change now requires the use of HOMEBREW_NO_INSTALL_FROM_API=1
  • Although the bottles still exist online, the binaries are broken due to being linked with an older version of icu4c (v71) than what Homebrew installs. So you must use --build-from-source and compile PHP yourself.
Monogenetic answered 30/12, 2022 at 23:47 Comment(3)
This didn't work for me, both editing the date and removing that disable line altogether still resulted in the same message.Sello
Try passing in the path to the edited file directly. E.g. brew install /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected]Silly
this does not workChiaroscuro
A
36

For anyone having this issue 2023 (and beyond)

The accepted answer is an unnessercery step.

@Mike's answer is the better one, but is missing one important step.

HOMEBREW_NO_INSTALL_FROM_API=1 brew install [email protected]

HOMEBREW_NO_INSTALL_FROM_API=1 brew install [email protected]

HOMEBREW_NO_INSTALL_FROM_API=1 brew install [email protected]

HOMEBREW_NO_INSTALL_FROM_API=1 brew install [email protected]

Brew tells you, when you edit the Formula:

Warning: Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
`brew install`, it will ignore your locally edited formula.
Editing /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected]
Warning: Using code because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.

This way, you still use the official formula. This of course, works for any formula.

So, just remove the following two lines from the formula:

  brew edit {{ formula }} // ex: brew edit [email protected]

  keg_only :versioned_formula

  disable! date: "2022-11-28", because: :versioned_formula
Alcaide answered 27/2, 2023 at 19:53 Comment(0)
L
9

When you are using homebrew to install PHP you need to know the versions that are been supported by homebrew. If you need to install an unsupported version you can do it by running these commands

brew tap shivammathur/php
brew install shivammathur/php/[email protected]
brew link [email protected]

And then if ypu need to check the current version and then shift between php version you can run

php -v
brew unlink php
brew link [email protected]

Listel answered 4/4, 2023 at 4:33 Comment(0)
C
1

BTW, brew install [email protected] gives out same warning, but does install php7, so this could be an option

Confiscate answered 8/7, 2022 at 4:29 Comment(2)
I get the same error on [email protected] now, because it too is now unsupported: php.net/supported-versions.php. There's this line in the [email protected] brew file: disable! date: "2022-11-28", because: :versioned_formulaFilefish
I wonder why did they put a timebomb instead of a warning. Unsupported software is not the end of the worldConfiscate
H
1

I was facing the same problem with Homebrew. The following steps resolved it, combining ideas from phpbrew#1249:

  1. Edit the formulae
    brew edit [email protected]
    
  2. Comment out or remove the date-based validation line, so that you can use the formula at all:
    disable! date: "2022-11-28", because: :versioned_formula
    
  3. Add the following lines after the block relating to "pkg-config" to make pkg-config find the compile headers of openssl v1.1.1 before the ones of v3 (which do not define RSA_SSLV23_PADDING):
    ENV["PKG_CONFIG_PATH"] = "#{Formula["[email protected]"].opt_prefix}/lib/pkgconfig:#{ENV["PKG_CONFIG_PATH"]}"
    system "echo", ENV["PKG_CONFIG_PATH"]
    
  4. Add OpenSSL flags directly afterwards:
    ENV["OPENSSL_CFLAGS"] = "-I#{Formula["[email protected]"].opt_include}"
    ENV["OPENSSL_LIBS"] = "-L#{Formula["[email protected]"].opt_prefix}/lib -lcrypto -lssl"
    
  5. In the args array for configure, replace --with-openssl with the following:
    --with-openssl=shared,#{Formula["[email protected]"].opt_prefix}
    
  6. Save and exit
  7. Reinstall PHP 7.4 from source using the locally edited formulae:
    HOMEBREW_NO_INSTALL_FROM_API=1 brew reinstall -s [email protected]
    
Hindsight answered 23/8, 2023 at 12:52 Comment(2)
HOMEBREW_NO_INSTALL_FROM_API=1 is no longer required as [email protected] has been deleted from the API now. Using this will just cause dependencies to re-downloadErysipeloid
This will install openssl as shared meaning you need to enable the extension in php.ini to use it (and you need a built extension to do that). Instead, add ENV["EXTRA_LIBS"] = "#{Formula["[email protected]"].opt_prefix}/lib/libssl.dylib #{Formula["[email protected]"].opt_prefix}/lib/libcrypto.dylib" and replace with --with-openssl=#{Formula["[email protected]"].opt_prefix} to get PHP to build with OpenSSLErysipeloid
H
1

On top of Anuga's answer, I would like to add a note.

If disable! date: "2022-11-28", because: :versioned_formula is not found, then look out for the depreciated or depreciate keyword while editing the formula. Proceed with the identical steps; it proved effective in my case!

Edit:

I encountered an additional challenge when attempting to install PHP, despite consulting various articles. Eventually, I identified that my Internet Service Provider (ISP), JIO, was blocking all requests to raw.githubusercontent.com.

This is a noteworthy consideration for individuals in India relying on JIO as their ISP.

Heretical answered 14/11, 2023 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.