asdf-community / asdf-php

PHP plugin for the asdf version manager
https://github.com/asdf-vm/asdf
Apache License 2.0
221 stars 102 forks source link

MacOS: Unable to find the wrapper "https" #163

Open tylerlwsmith opened 10 months ago

tylerlwsmith commented 10 months ago

Provide environment information

OS:
Darwin My-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:33:00 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6031 arm64

SHELL:
zsh 5.9 (x86_64-apple-darwin23.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
v0.13.1-0586b37

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/tyler/.asdf
ASDF_DIR=/Users/tyler/.asdf
ASDF_CONFIG_FILE=/Users/tyler/.asdfrc

ASDF INSTALLED PLUGINS:
elixir                       https://github.com/asdf-vm/asdf-elixir.git master a4c42e1
erlang                       https://github.com/asdf-vm/asdf-erlang.git master aaa3ee7
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c5b7c40
php                          https://github.com/asdf-community/asdf-php.git master 1eaf4de
ruby                         https://github.com/asdf-vm/asdf-ruby.git master b3d44de

To Reproduce

Run asdf install php 8.3.1 or PHP_WITHOUT_PEAR=yes asdf install php 8.3.1.

Describe the Bug

Installation appears to error out when trying to install pear or composer because https is not enabled in php.ini during the installation.

When running asdf install php 8.3.1, I get the following errors:

Warning: fopen(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /private/var/folders/5_/jsnsc2s51wl08b_htp4xrctr0000gn/T/php-src-php-8.3.1/pear/fetch.php on line 66

Warning: fopen(https://pear.php.net/install-pear-nozlib.phar): Failed to open stream: No such file or directory in /private/var/folders/5_/jsnsc2s51wl08b_htp4xrctr0000gn/T/php-src-php-8.3.1/pear/fetch.php on line 66

Error..
fopen(https://pear.php.net/install-pear-nozlib.phar): Failed to open stream: No such file or directory
make: *** [install-pear] Error 1

When running PHP_WITHOUT_PEAR=yes asdf install php 8.3.1, I get the following errors:

Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

Warning: copy(https://getcomposer.org/installer): Failed to open stream: No such file or directory in Command line code on line 1

Warning: hash_file(composer-setup.php): Failed to open stream: No such file or directory in Command line code on line 1
Installer corrupt
Warning: unlink(composer-setup.php): No such file or directory in Command line code on line 1

Could not open input file: composer-setup.php
tyler@My-MacBook-Pro installs %

Expected Behaviour

PHP successfully installs, or fails in a way that indicates a missing dependency before the installation fails on an https request.

tylerlwsmith commented 10 months ago

I've been able to work around this issue in two ways:

  1. Install OpenSSL on my MacBook using brew install openssl@1.1
  2. Update both instances of homebrew_package_path openssl@1.1 to homebrew_package_path openssl in the install file.
watsonarw commented 10 months ago

@tylerlwsmith Thank you for the workaround! I was pulling my hair out wondering why it wasn't working on my newer machine, but was fine on an older one.

It seems like openssl@1.1 is an undocumented dependency on MacOS, it might be helpful if it were explicitly documented/installed in the Github actions workflow.

yoonwaiyan commented 9 months ago

I changed the install file to point to openssl without specifying version 1.1 and it worked.

tangrufus commented 9 months ago

Continue @tylerlwsmith's awesome workaround but without editing files:

$ brew install openssl@1.1

### If you have openssl v3 installed (you most likely do)
$ brew unlink openssl@3
Unlinking /opt/homebrew/Cellar/openssl@3/3.2.1... 5867 symlinks removed.

$ brew link openssl@1.1
Linking /opt/homebrew/Cellar/openssl@1.1/1.1.1w... 3999 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

$ openssl version
OpenSSL 1.1.1w  11 Sep 2023

$ asdf install php xxx

### Restore openssl version to v3
$ brew unlink openssl@1.1
Unlinking /opt/homebrew/Cellar/openssl@1.1/1.1.1w... 3999 symlinks removed.

$ brew link openssl@3
Linking /opt/homebrew/Cellar/openssl@3/3.2.1... 5867 symlinks created.

$ openssl version
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)
tristanjahier commented 9 months ago

Oddly enough, after installing OpenSSL 1.1 via Homebrew and installing PHP 8.3, I did not need to switch to OpenSSL 1.1 to install other versions of PHP. I even tried to re-install PHP 8.3 with OpenSSL 3 linked and it worked properly. The build output shows that it actually uses openssl@1.1. Maybe we just need to have openssl@1.1 installed?

cameronmurphy commented 8 months ago

OpenSSL 1.1 reached end of life on September 11, 2023, and as such I get this warning when installing openssl@1.1 from Homebrew:

Warning: openssl@1.1 has been deprecated because it is not supported upstream!

Probably naive question: PHP 8.1 added support for OpenSSL 3.0 - can compile against that instead?

godbout commented 7 months ago

for those on macOS who want openssl 3 with PHP:

orthodoX commented 3 months ago

Oddly enough, after installing OpenSSL 1.1 via Homebrew and installing PHP 8.3, I did not need to switch to OpenSSL 1.1 to install other versions of PHP. I even tried to re-install PHP 8.3 with OpenSSL 3 linked and it worked properly. The build output shows that it actually uses openssl@1.1. Maybe we just need to have openssl@1.1 installed?

You are correct. I just installed openssl@1.1 and retried the installation and it worked, no need to switch versions or meddle with installation files

jhclouse commented 3 months ago

For the benefit of future storm-tossed mariners driven onto the rocky shore, I had to add --with-openssl=$(brew --prefix openssl) to PHP_CONFIGURE_OPTIONS to make it work. I also had to add --with-iconv. Based on manually executing the lines in the install script that search for packages, both of those should have worked out of the box. So I'm not sure what's going on there.