laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.48k stars 690 forks source link

valet start dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 #778

Closed brothman01 closed 4 years ago

brothman01 commented 5 years ago

I have been using valet for several years but this week it won't start and gives me errors that I am unable to fix after trying everything I could think of.

The first thing I did after seeing that I was unable to access my site was check the running brew processes:

$ brew services list
Name    Status  User     Plist
dnsmasq started root     /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mailhog started ben /Users/kotlin/Library/LaunchAgents/homebrew.mxcl.mailhog.plist
mariadb started ben /Users/kotlin/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   started root     /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started ben /Users/kotlin/Library/LaunchAgents/homebrew.mxcl.php.plist
php@7.1 started root     /Library/LaunchDaemons/homebrew.mxcl.php@7.1.plist

everything is there except for valet so I tried starting valet manually:

$ valet start
dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

I tried reinstalling things, unlinking and linking things, I made sure that php 7.1 was in fact the version version of php being used but I still got the same errors when I tried to start valet. Does anyone know how I can get valet started?

drbyte commented 5 years ago

Debugging this will require first determining where these error messages are actually being triggered.

You said you "tried reinstalling things". Does that include running any other valet commands other than valet start after which you posted the error messages? Did the other valet commands give the same messages? It would be helpful to know which commands don't trigger the same messages vs which ones might trigger different messages.

When you run valet without any parameters, does the error appear? AND what version of Valet does it report?

Can you provide the output from each of these commands?

sw_vers
which php
which -a php
php -v
nginx -v
openssl version
cat ~/.config/valet/config.json
ls -al /etc/sudoers.d/
openssl ciphers
brew config
brew doctor
brew info openssl
brew info nginx
brew info php

and a quick sanity test of your nginx configs: sudo nginx -t

Also, what's the history of your Mac this week? What updates did you install that might have broken something that was working fine previously? Based on a bunch of googling, the suspects which seem to most often report dyld: symbol not found are xcode and npm/node. But they're usually reporting different symbols in the google results.

Given that the errors are all related to openssl and look like they might be ssl ciphers, maybe you've got something broken in your nginx configuration? Perhaps some old server definitions wanting the cipher mentioned in the error messages but no longer installed on your Mac? You might try a global search for _EVP_aes_128_cbc_hmac_sha256 in all text files found in your ~/.config and /usr/local/etc directories and subdirs.

brothman01 commented 5 years ago

hello, thank you for answering: valet and valet -v both give the 4 errors below, prompt me for root password and then give 4 more errors that are tacked on to the end of the first 4 with some kind of output at the end:

  1. Run the command
    
    $ valet -v
    dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
    Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
    Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

2. I am prompted for higher access then when I give the password It shows four more errors:

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

/Users/ben/.composer/vendor/bin/valet: line 54: 79380 Abort trap: 6 php "$DIR/cli/valet.php" "$@"


outputs for requested commands:

$ sw_vers ProductName: Mac OS X ProductVersion: 10.14.4 BuildVersion: 18E226 $ which php /usr/local/bin/php $ which -a php /usr/local/bin/php /usr/bin/php /usr/local/bin/php $ php -v dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

Abort trap: 6 $ nginx -v nginx version: nginx/1.15.12 $ openssl version LibreSSL 2.6.5 $ cat ~/.config/valet/config.json cat: /Users/ben/.config/valet/config.json: No such file or directory $ ls -al /etc/sudoers.d/ total 0 drwxr-xr-x 2 root wheel 64 Aug 17 2018 . drwxr-xr-x 123 root wheel 3936 May 12 11:46 .. $ openssl ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:EDH-RSA-DES-CBC-SHA:DES-CBC-SHA $ brew config HOMEBREW_VERSION: 2.1.2 ORIGIN: https://github.com/Homebrew/brew HEAD: 4025eadc2c3b9b71aa7029d7ddc6ede1cb88d482 Last commit: 7 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 5b7e4b07dd386f270c9a5efb2980185bd408b6c9 Core tap last commit: 8 hours ago HOMEBREW_PREFIX: /usr/local CPU: quad-core 64-bit haswell Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Clang: 10.0 build 1001 Git: 2.20.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git Curl: 7.54.0 => /usr/bin/curl Java: 1.8.0_141 macOS: 10.14.4-x86_64 CLT: N/A Xcode: 10.2 $ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have the following deprecated, official taps tapped: Homebrew/homebrew-php Untap them with brew untap.

Warning: "config" scripts exist outside your system or Homebrew directories. ./configure scripts often look for *-config scripts to determine if software packages are installed, and which additional flags to use when compiling and linking.

Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew-provided script of the same name. We found the following "config" scripts: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config /Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config

Warning: Unbrewed dylibs were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected dylibs: /usr/local/lib/libsstp_api-0.dylib

Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run brew link on these: python php php@5.6 libevent

Warning: Some installed formulae are not readable: php72-xdebug: cannot load such file -- /usr/local/opt/php72-xdebug/Abstract/abstract-php-extension

php@5.6: "cxx11" is not a recognized standard

Warning: Homebrew's sbin was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin. Consider setting the PATH for example like so: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

Warning: Your Xcode (10.2) is outdated. Please update to Xcode 10.2.1 (or delete it). Xcode can be updated from the App Store.

$ brew info openssl openssl: stable 1.0.2r (bottled) [keg-only] SSL/TLS cryptography library https://openssl.org/ /usr/local/Cellar/openssl/1.0.2r (1,796 files, 12.4MB) Poured from bottle on 2019-04-06 at 21:42:34 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs

and run /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

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

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

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

==> Analytics install: 545,662 (30 days), 1,725,067 (90 days), 6,347,508 (365 days) install_on_request: 71,160 (30 days), 235,460 (90 days), 884,841 (365 days) build_error: 0 (30 days) $ brew info nginx nginx: stable 1.15.12 (bottled), HEAD HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server https://nginx.org/ /usr/local/Cellar/nginx/1.15.12 (25 files, 2MB) * Poured from bottle on 2019-04-17 at 18:29:04 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb ==> Dependencies Required: openssl ✔, pcre ✔ ==> Options --HEAD Install HEAD version ==> Caveats Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login: brew services start nginx Or, if you don't want/need a background service you can just run: nginx ==> Analytics install: 39,299 (30 days), 111,812 (90 days), 430,418 (365 days) install_on_request: 36,775 (30 days), 104,975 (90 days), 396,212 (365 days) build_error: 0 (30 days) $ brew info php php: stable 7.3.5 (bottled) General-purpose scripting language https://secure.php.net/ /usr/local/Cellar/php/7.3.5 (522 files, 77.0MB) Poured from bottle on 2019-05-12 at 11:55:56 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/php.rb ==> Dependencies Build: httpd ✘, pkg-config ✔ Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl-openssl ✔, freetds ✔, freetype ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, jpeg ✔, libpng ✔, libpq ✔, libsodium ✔, libzip ✔, openldap ✔, openssl ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔, webp ✔ ==> Caveats To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in: /usr/local/etc/php/7.3/

To have launchd start php now and restart at login: brew services start php Or, if you don't want/need a background service you can just run: php-fpm ==> Analytics install: 39,445 (30 days), 107,294 (90 days), 453,080 (365 days) install_on_request: 35,667 (30 days), 96,919 (90 days), 408,007 (365 days) build_error: 0 (30 days)


santity test:

$ sudo nginx -t Password: dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

Abort trap: 6



I did not install anything this week, and earlier today (after this problem) I even reinstalled node because I saw that too and then I also tried reinstalling openssl.

`$ grep -r "_EVP_aes_128_cbc_hmac_sha256" ~/.config/`
no results

`$ grep -r "_EVP_aes_128_cbc_hmac_sha256" /usr/local/etc`
no results

hmm I didn't install anything this week... maybe something openssl communicates with was updated?
drbyte commented 5 years ago

When it's saying "symbol not found" it's essentially saying the same as "class/object not found" in a PHP application. But in this case it's referring to things about openssl. And it's likely calling for them because of config settings (php.ini or conf.d things would be first guess).

Observations:

  1. Homebrew says your PATH doesn't include the sbin dir where some of your binaries are found.

    Warning: Homebrew's sbin was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin.
    Consider setting the PATH for example like so:
    echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
  2. I wonder if there are inconsistencies with where/whether your opt dir is used/populated. For example, the output of this command should be as shown: ls -al /usr/local/opt/php lrwxr-xr-x 1 yourname admin 19 May 4 22:41 /usr/local/opt/php -> ../Cellar/php/7.3.5

  3. Does php -i | grep ssl report any paths for openssl that don't exist on your computer? Particularly expecting the following to be shown, and refer to valid paths: --with-curl=/usr/local/opt/curl-openssl --with-openssl=/usr/local/opt/openssl Openssl default config => /usr/local/etc/openssl/openssl.cnf

  4. I wonder if reinstalling openssl (brew reinstall openssl) might at least ensure the binaries and configs are set right?

  5. I wonder if your php.ini and other ini files (and conf.d files) for PHP contain directives to things that are no longer valid because of things deleted or moved? /usr/local/etc/php/7.3

  6. Did you relocate any system files/packages, particularly homebrew-related (/usr/local and subdirs).

  7. It's interesting that running nginx -v vs sudo nginx -t does and doesn't give the errors, respectively. But running php -v (not sudo) does (and so does running valet on its own, which is a bash script which invokes php for execution).

brothman01 commented 5 years ago
  1. I added /usr/local/sbin to the path but it has no effect. When I run valet start I still get the errors:
    
    $ valet start
    dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
    Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
    Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

Password: dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

/Users/garfield/.composer/vendor/bin/valet: line 54: 15184 Abort trap: 6 php "$DIR/cli/valet.php" "$@"


2. The output for that command is exactly what you guessed it would be.

3. `php -i | grep ssl` actually returns nothing but errors, so this may give a clue as to what the problem is:

$ php -i | grep ssl dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256 Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Expected in: /opt/local/lib/libcrypto.1.0.0.dylib


4. I reinstalled openssl and tried unlink and link it but none of that fixed anything :(

5. php 7.1 is the version being used, and when I checked `/usr/local/etc/php/7.1` it was empty...

6. No, not me.

7. Maybe that means the problem is in php which is why when I try to run php or valet (which uses php) there are errors.  There are also two php services running php and php@7.1 maybe it is one of your ideas which was that there is a problem with one of the php config files, the problem is I do not know where to look or what to look for, haha
drbyte commented 5 years ago

I agree, the problem is likely in something with your PHP config.

I've been assuming that you've got php and php@7.1 and php@5.6 installed for an intentional reason. Is that true? If not, can we remove all PHP versions and their configs? (Keep in mind that it's quite complicated/nuanced to try to install/reinstall PHP 5.6 anymore, so if you really need to be able to have it, we should avoid messing with it.)

If you're okay removing all the old PHP stuff, I suspect you can do it with:

sudo brew services stop php@7.1 (because you've got it running as root)

brew services stop php
brew remove php@7.1
brew remove php@5.6   # (or skip if you're wanting to keep it for some reason)
brew remove php
rm -rf /usr/local/etc/php       # (or keep the 5.6 subdir, and instead remove the 7.1 and 7.3 dirs)
brew cleanup

You could run brew doctor again. You can ignore the python notes, and php@5.6 if you kept it.

In theory you shouldn't need a reboot, but no harm in doing one.

Then running which php should point to /usr/bin/php which is the OSX preinstalled version and running php -v should give no errors, but instead show v7.1.23 (likely, on Mojave)

Now you can either run valet install or ask Homebrew to brew install php and it should give you 7.3, and then valet install afterward, to install valet's php dependencies, and the other things it hasn't been able to do yet..

While this covers a lot of stuff, I suspect your /usr/local/etc/php/7.3 subdir has stuff in it that was asking for those openssl ciphers that were triggering errors, and deleting that dir might have been enough to clean it up. But guiding you through preserving defaults and reconfiguring it clean is complicated so a fresh Homebrew PHP install is the simplest way, before running valet install.

brothman01 commented 5 years ago

Damn, so close! I uninstalled the extraneous versions of php (not sure where they came from), removed /usr/local/etc/php then ran brew cleanup which removed 9 directories.

Then I ran brew doctor and got these errors:

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have the following deprecated, official taps tapped:
  Homebrew/homebrew-php
Untap them with `brew untap`.

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libsstp_api-0.dylib

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python
  libevent

Warning: Some installed formulae are not readable:
  php72-xdebug: cannot load such file -- /usr/local/opt/php72-xdebug/Abstract/abstract-php-extension

Warning: Your Xcode (10.2) is outdated.
Please update to Xcode 10.2.1 (or delete it).
Xcode can be updated from the App Store.

I know this got errors but I was still hopeful after this that this would work. (Btw I used to use xdebug but no longer do so if we have to delete that it is no problem for me. Actually I thought I deleted it but it appears not) Unfortunately valet still does not work so these errors became more relevant to me. Could this whole problem possibly be caused by the fact that apparently my xcode is out of date?

Anywayy, which php and php -v both had the normal outputs that you predicted, so I ran brew install php which gave the following errors:

$ brew install php
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
appstream-glib
==> Updated Formulae
freetds ✔                                lzip
amazon-ecs-cli                           mackup
azure-storage-cpp                        mailutils
babel                                    mbedtls
bartycrouch                              mdds
bee                                      mdk
cfr-decompiler                           memcached
chamber                                  mesa
cointop                                  mongoose
consul                                   mpck
convox                                   mpd
cromwell                                 mplayer
davix                                    mruby
dnscrypt-proxy                           msmtp
druid                                    mtools
efl                                      mupdf
elixir                                   mupdf-tools
erlang                                   ncdc
evince                                   ndpi
fibjs                                    netdata
fluxctl                                  nss
fn                                       ntl
fonttools                                nzbget
frpc                                     ocrmypdf
gcsfuse                                  ola
gdb                                      ompl
ghq                                      openapi-generator
gibo                                     opencc
glooctl                                  pari
gnunet                                   patchelf
golo                                     pcb
gosu                                     pdal
grakn                                    phoronix-test-suite
hbase                                    phpstan
jenkins                                  phpunit
joplin                                   prettier
jsdoc3                                   profanity
juju                                     protoc-gen-go
kibana                                   pulumi
kubeless                                 pypy
kubernetes-service-catalog-client        root
landscaper                               rust
libmtp                                   serve
libmwaw                                  serverless
libnfs                                   sourcekitten
libntlm                                  swi-prolog
libodfgen                                syncthing
libofx                                   teleport
libopenmpt                               terragrunt
libprotoident                            terrahub
libpsl                                   tile38
librsvg                                  topgrade
libtrace                                 util-linux
libvirt                                  vault-cli
libwpd                                   vegeta
libwpg                                   verilator
libxc                                    wiremock-standalone
==> Deleted Formulae
js-test-driver

==> Installing dependencies for php: freetds
==> Installing php dependency: freetds
==> Downloading https://homebrew.bintray.com/bottles/freetds-1.1.6.mojave.bottle
==> Downloading from https://akamai.bintray.com/50/501fc03b7af71fdc7dba603c95d7d
######################################################################## 100.0%
==> Pouring freetds-1.1.6.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/freetds/1.1.6: 2,141 files, 13.1MB
==> Installing php
==> Downloading https://homebrew.bintray.com/bottles/php-7.3.5.mojave.bottle.tar
Already downloaded: /Users/robert/Library/Caches/Homebrew/downloads/b8ae5d47a434c23588e1037efab7f198402659dec50f1724664b00e44872bd68--php-7.3.5.mojave.bottle.tar.gz
==> Pouring php-7.3.5.mojave.bottle.tar.gz
==> /usr/local/Cellar/php/7.3.5/bin/pear config-set php_ini /usr/local/etc/php/7
Last 15 lines from /Users/robert/Library/Logs/Homebrew/php/post_install.01.pear:

/usr/local/Cellar/php/7.3.5/bin/pear
config-set
php_ini
/usr/local/etc/php/7.3/php.ini
system

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php`
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.3/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Summary
🍺  /usr/local/Cellar/php/7.3.5: 522 files, 77.0MB
==> Caveats
==> php
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.3/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm

and then I ranvalet install and got the same errors that I used to get before uninstalling php:

$ valet install
dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: lazy symbol binding failed: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

dyld: Symbol not found: _EVP_aes_128_cbc_hmac_sha256
  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

and to make things worse, now I get errors when I run php -v. One of or both of the final two steps messed this up. I am seeing two possible sources for this problem: 1) php 2) xcode. maybe I should uninstall all versions of php again, upgrade xcode and then reinstall php then valet? Actually maybe I am wrong about the sources... What do you think?

drbyte commented 5 years ago

I'd go ahead with: brew untap Homebrew/homebrew-php brew remove php72-xdebug rm /usr/local/lib/libsstp_api-0.dylib

And if you're not needing it right now, uninstalling XCode would be an even cleaner spot to start, rather than upgrading it. And if XCode is indeed the issue, then a new install of it would be more efficient at fixing broken dependencies than an upgrade would anyway.

About the brew doctor concerns: Are you doing much with python? Since you've got a bunch of inconsistencies reported with it, I suspect it's unused, and maybe cleaning it up is a good idea too. I'm guessing that the following will work, at least as far as the concerns brew doctor is reporting. Granted, I'm only guessing about these, and if you're relying on things that need them you may want to investigate them on your own. In theory they shouldn't be interfering with PHP, but they "might" be interfering with your openssl stuff.

brew untap python
brew untap libevent
rm  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
rm  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
rm  /Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config

OpenSSL I'm a bit confused why the messages are referencing the /opt/ directory off the root.

  Referenced from: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Expected in: /opt/local/lib/libcrypto.1.0.0.dylib

This leads me to believe that maybe the files under /usr/local/opt/ (/usr/local/ is where Homebrew installs its stuff ...... or maybe you've got another tool that also puts stuff there?) there may be something unexpected going on. Earlier you said you ran brew reinstall openssl.
I wonder if it might be more thorough to forcefully remove it:

brew remove openssl
rm -rf /usr/local/opt/openssl 
rm -rf /usr/local/etc/openssl
brew install openssl

And then you'll need to brew reinstall php. You can of course test php -v at any time during all the above, but remember that homebrew failed to fully finish all its post-install scripts, so best to make sure those do run before treating it as resolved.

brothman01 commented 5 years ago

I ran the commands anyway, but what is /usr/local/lib/libsstp_api-0.dylib and why did I remove it?

but the uptap commands that you gave me returned errors because they are invalid taps and I was not able to find the tap names with a search:

$ brew untap python
Error: Invalid tap name 'python'
$ brew untap libevent
Error: Invalid tap name 'libevent'

but I did run those next 3 rm commands.

I don't think I am using openssl on purpose for anything aside from possibly valet, so if you are worried about preserving my other work, according to me openssl is definitely expendable. I am using python but not for anything special, I just write scripts so I there should not be any crazy addons for that, it is pretty vanilla python.

anyway I ran the commands to remove and then install openssl, then reinstalled php (brew reinstall php) but now when I run php -v I get one error (which is an improvement, because it was eight before):

$ php -v
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found
Abort trap: 6

when I saw that I ran brew services list and look at the php entry:

$ brew services list
Name    Status  User     Plist
dnsmasq started root     /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mailhog started rebeccag /Users/rebeccag/Library/LaunchAgents/homebrew.mxcl.mailhog.plist
mariadb started rebeccag /Users/rebeccag/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   started root     /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     stopped  

but when I try to start php I get the same error that I got with php -v:

$ php start
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found
Abort trap: 6

the errors are decreasing, I think we are zeroing in on the issue.

drbyte commented 5 years ago

Hmm, the tap names came from your brew doctor output. So was the libsstp_api dylib. Oh well, maybe they're immaterial here.

What's the output of openssl version -a? (The -a is new since previous time we ran this.)

More googling after your latest change in errors shows only a very old instance from 2015, before homebrew stopped linking openssl binaries due to osx preferring their own. But, in that discussion are a couple things to consider:

  1. A clean remove and reinstall of PHP may be in order after your recent cleanup. I'm thinking this because your error message is saying that the brew php is looking for the openssl crypto lib ... which is normal since the bottle was compiled with it as an expected dependency. I'm just curious about why it thinks it's not found. But maybe a full cleanup is in order now that we've got rid of some other junk. The following will remove and cleanup PHP configs and openssl and the (hopefully not installed) openssl@1.1 packages. (You may get errors about the 1.1 not being present, just ignore those.)
    
    brew remove php
    rm -rf /usr/local/etc/php
    brew remove openssl
    rm -rf /usr/local/opt/openssl 
    rm -rf /usr/local/etc/openssl
    brew remove openssl@1.1
    rm -rf /usr/local/opt/openssl@1.1
    rm -rf /usr/local/etc/openssl@1.1
    brew cleanup

brew install php

The install of php should auto-install openssl at the same time.

Then what happens with `php -v` ?

2. If the same libcrypto dylib error persists, try the following (unrecommended, but this is for testing) `brew link openssl --force`. I'm not sure if it'll even let you force it, but if it lets you, then test `php -v` again.
Strictly speaking homebrew recommends not linking its openssl binaries, so it's not ideal to leave it linked, but if that's the only way to get your php working then at least it'd be a short-term workaround. 
You could `brew unlink openssl` to put things back to normal. And test with `which openssl` - it should point to /usr/bin/openssl

3. If the problem continues at this stage, can you share the output of running `export`?  You might want to strip out anything sensitive in the output when posting it. Most of the content is safe, but some people use an environment variable for MYSQL_PWD or some ACCESS_KEYs or TOKENs. Just be cautious of posting those.
I'm asking just in order to do an extra sanity check about whether something environmental could be involved.

4. And if we get down this far and still have a problem, one more step, more aggressive, may be in order: recompile php directly for your machine. Homebrew provides for this, and if there's a legitimate issue with things being missing then the recompile will expose that as well.

brew remove php brew install php --force --build-from-source


Since the default compile config says to include openssl it should use the openssl already installed.
brothman01 commented 5 years ago

Just wanna start by sayin a quick thanks to you for putting all this time in, this issue has really been stopping a lot of work, so thanks for helping.

Anyway, I started by running the command:

$ openssl version -a
LibreSSL 2.6.5
built on: date not available
platform: information not available
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"

That output looks a little weird, but not weird in a way that I know what to do with. Next I did a clean remove and reinstall of php (and apparently openssl and openssl@1.1):

brew remove php
rm -rf /usr/local/etc/php
brew remove openssl
rm -rf /usr/local/opt/openssl 
rm -rf /usr/local/etc/openssl
brew remove openssl@1.1
rm -rf /usr/local/opt/openssl@1.1
rm -rf /usr/local/etc/openssl@1.1
brew cleanup

brew install php

at this point I ran a quick brew services list to see how I was doing:

$ brew services list
Name    Status  User     Plist
dnsmasq started root     /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mailhog started rebeccag /Users/rebeccag/Library/LaunchAgents/homebrew.mxcl.mailhog.plist
mariadb started rebeccag /Users/rebeccag/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   started root     /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     stopped 

hmm php is installed but stopped, I tried running php to start it up, but the terminal just hangs. The prompt on the next line never appears but nothing happens with php. BUT, for some reason php -v works perfectly and shows 7.3.5...

I tried to start php by editing and uncommenting the lineLoadModule php7_module libexec/apache2/libphp7.so and then running sudo apachectl restart which are apparently the two steps that I needed to run to start php but that changed nothing.

I know your list had more a one or two more things to try, but I think the fact that a newly installed version of php is stopped as a service and wont start is getting close to the issue.

drbyte commented 5 years ago

Ya, it sounds like getting closer. And cleaner.

Running php will open a command shell, so it may look like the terminal is hung. But CTRL+C exits it.

Have you rebooted today? If not, do.

What's the result of sudo brew services start php -vvv ?

If it starts PHP without failure, then what's the output of brew services list? Is php running as root?

If yes, then you're ready to run valet install.

If not, then read on ...


You mentioned apache. Valet doesn't use apache at all, and you don't have it installed with homebrew. How are you using apache in your workflow?

When you ran brew install php earlier, do you recall if it gave any errors that you captured?

I think at this point running a php built-from-source would reveal some things. So let's try that.

brew remove php && brew cleanup
brew install php --force --build-from-source

It'll take 5+ minutes to do the download/make/compile/install steps. Watch for errors/failures.

brothman01 commented 5 years ago

I feel like we are so close we can see the end! lol anyway, after running brew services start php -vvv (sudo was not needed) php is on the brew services list as started, and I was able to reinstall valet. Over right? Nope.

when I try to connect to my site, the browser says

This site can’t be reached test-site.test refused to connect.

I feel like its a smaller issue now. Some research showed that this might be a problem with dnsmasq not running or something, so I ran a quick $ ps aux | grep dnsmasq and got the following weird looking output:

nobody            3963   0.0  0.0  4287984   1104   ??  Ss    7:01PM   0:00.01 /usr/local/opt/dnsmasq/sbin/dnsmasq --keep-in-foreground -C /usr/local/etc/dnsmasq.conf
ben         13944   0.0  0.0  4277256    800 s000  S+    7:34PM   0:00.00 grep dnsmasq

'nobody' is literally the name of the user, I did not edit that. Why are there two instances of dnsmasq running on my computer? That would explain why valet is not working I think, but where did that second instance come from? Now what I want to do is stop that service, but I figured I should ask you first to see if that is supposed to be there or something.

drbyte commented 5 years ago

brew services list should show dnsmasq and php and nginx all running as root. (That's why I said to start php via sudo).

Your dnsmasq running as nobody is normal. To test dnsmasq, try dig foo.test.

If it's not working, you'll see something like:

dig foo.test

; <<>> DiG 9.10.6 <<>> foo.test
;; global options: +cmd
;; connection timed out; no servers could be reached

... in which case I'd go to MacOS system preferences, Networking, and add 127.0.0.1 as the first DNS resolver.

But if it's working, you'll see:

dig foo.test

; <<>> DiG 9.10.6 <<>> foo.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12313
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;foo.test.          IN  A

;; ANSWER SECTION:
foo.test.       0   IN  A   127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri May 17 20:06:20 EDT 2019
;; MSG SIZE  rcvd: 53

Your "refused to connect" is likely from nginx not running, or not configured.

brothman01 commented 5 years ago

I did run dig on a test domain, and there was output but it had no answer section. I have been using valet along with dnsmasq for a few years and I never had to add my local machine as a DNS resolver. I'm not sure I want to do that, lol I use opoendns and that seems to work as a DNS resolver and I don't want to mess that up because it allows other things I have to work. what other solution is there?

drbyte commented 5 years ago

I totally understand.

If the dig output isn't giving results, then maybe your dnsmasq config isn't right? Or needs some tweaking?

Of course, we weren't expecting the other parts besides PHP to be problematic as well. I'd rather not get drastic with reconfiguring dnsmasq and nginx, but the next steps do involve figuring out why either/both are not working right.

Again, reboots can fix a ton of things.

What's brew saying about nginx status?

You might want to explore custom-configuring dnsmasq by just customizing your ~/.config/valet/dnsmasq.conf and inserting the following. The file normally has just the first 2 lines. Will need to restart dnsmasq after changing the config:

address=/.test/127.0.0.1
listen-address=127.0.0.1

#ignore resolv.conf
no-resolv
no-poll

# The bind-interfaces directive instructs dnsmasq to bind only to the network interface specified in the listen-address directive, which is important for dnscrypt use
bind-interfaces
# dnscrypt-proxy is on port 53:
server=127.0.0.1#53

# The following directives prevent dnsmasq from forwarding plain names (without any dots) or addresses in the non-routed address space to the parent nameservers.
domain-needed
bogus-priv

# default is 150, or 0 = off
cache-size=0

# Logging
#log-facility=/Users/YOUR_USERNAME_HERE/Downloads/dnsmasq.log
#log-queries

# fallback servers to use if we can't resolve using our own rules
server=1.1.1.1
server=1.0.0.1
server=208.67.220.222
server=208.67.220.220
#server=4.4.4.4

#domain-needed This tells dnsmasq to never pass short names to the upstream DNS servers. If the name is not in the local /etc/hosts file then “not found” will be returned.
#bogus-priv All reverse IP (192.168.x.x) lookups that are not found in /etc/hosts will be returned as “no such domain” and not forwarded to the upstream servers.
#no-resolv Do not read resolv.conf to find the servers where to lookup dns.
#no-poll Do not poll resolv.conf for changes
#server=8.8.8.8 Set one or more DNS servers to use when addresses are not local. These are open DNS servers.
#local=/example.com/ Our local domain, queries in these domains are answered from /etc/hosts or the static-hosts files.
#address=/doubleclick.net/127.0.0.1 Use this force an address for the specified domains. e.g to block adverts force doubleclck.net to localhost
#no-hosts This options stops dnsmasq using the local /etc/hosts file as a source for lookups .
#addn-hosts=/etc/dnsmasq_static_hosts.conf Force dnsmasq to use this file for lookups. It is in the same format as /etc/hosts.
#expand_hosts So we can see our local hosts via our home domain without having to repeatedly specify the domain in our /etc/hosts file.

You could also uncomment the 2 logging settings above, and fix the path, and restart dnsmasq again, and inspect whether any errors are reported when it's trying to start.

brothman01 commented 5 years ago
  1. ok, first of all brew services list does show that nginx is "started" and the user is root. Pertinent line: dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist.

  2. I cannot edit the file ~/.config/valet/dnsmasq.conf and I also cannot create it with touch and then save contents to it with nano. I did try to create thatn dsmasq config file with the settings you included in your last answer but I cannot. Maybe that inability reveals what the problem is? or it might just be that there is no ~/.config/valet which I can make but I think the fact that valet did not create that on install is relevant so I don't want to just do that without saying anything. Now that you know about that, should I just make that file structure and file?

drbyte commented 5 years ago

Maybe you have a permissions problem on your.config/valet folder?

I’m pretty sure you want all its content owned and editable by your regular user, not sudo.

dnsmasq definitely requires that file else it doesn’t know to serve your .test domains.

brothman01 commented 5 years ago

nono what I'm saying is that there is no folder or anything at ~/.config/valet, meaning inside the ~/.config folder there is no valet folder even though I ran valet install yesterday or two days ago. Valet is also not listed as a brew service, so it looks like valet install did not work. I'll try composer global require laravel/valet (the way I installed valet way back when)

hmm

$ composer global require laravel/valet
Changed current directory to /Users/rebeccag/.composer
Using version ^2.3 for laravel/valet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.

  [ErrorException]                                                             
  "continue" targeting switch is equivalent to "break". Did you mean to use "  
  continue 2"?                                                                 

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

maybe composer is out of date or broken or something? I tried to update composer the standard way but I got errors:

$ composer global update
Changed current directory to /Users/rebeccar/.composer
Loading composer repositories with package information
Updating dependencies (including require-dev)

  [ErrorException]                                                             
  "continue" targeting switch is equivalent to "break". Did you mean to use "  
  continue 2"?                                                                 

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

so at this point it appears that I have to fix composer so that I can fix valet so that I can run valet install. Am I wrong about what needs to be done?

drbyte commented 5 years ago

I think your composer is outdated vs the newer PHP (7.3) version you're now using.

composer self-update

brothman01 commented 5 years ago

I ran composer self-update and composer updated with no errors.

I ran composer global require laravel/valet and it installed but with the error below:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - friendsofphp/php-cs-fixer v2.11.1 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.5) does not satisfy that requirement.
    - friendsofphp/php-cs-fixer v2.11.1 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.5) does not satisfy that requirement.
    - friendsofphp/php-cs-fixer v2.11.1 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.5) does not satisfy that requirement.
    - Installation request for friendsofphp/php-cs-fixer (locked at v2.11.1, required as ^2.9) -> satisfiable by friendsofphp/php-cs-fixer[v2.11.1].

Installation failed, reverting ./composer.json to its original content.

It will not be a problem if I have to remove php cs (I don't even know what friendsofphp.php-cs-fixer is) if I have to, but based on the errors it looks like I may need to install an older version of php? maybe php 7.0?

drbyte commented 5 years ago

What's in your ~/.composer/composer.json?

If you're comfortable with housecleaning a bit, I'd prune out anything you don't "want for certain" (or delete the file altogether if nothing important in there), and then rm -rf ~/.composer/vendor ~/.composer/cache

And then composer global require laravel/valet

brothman01 commented 5 years ago

we have progress! but no solution yet. I deleted ~/.composer/composer.json, ~/.composer/vendor and ~/.composer/cache (but obviously I saved backups of each one) and then ran composer global require laravel/valet. There were no errors in the console but the sites were still not loading. I downloaded php@7.1, switched brew to use that version of php and ran 'valet use php@7.1`, rebooted and now for the progress: The sites resolve host for about 20 seconds (pointing to a DNS issue) and THEN the site refuses to connect.

I ran dig test-site.test (that is one of my dev sites on valet):

; <<>> DiG 9.14.2 <<>> test-site.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 26737
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;test-site.test.            IN  A

;; AUTHORITY SECTION:
.           5400    IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2019051900 1800 900 604800 86400

;; Query time: 48 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun May 19 10:02:18 EDT 2019
;; MSG SIZE  rcvd: 118
drbyte commented 5 years ago

Ya, that suggests dnsmasq isn't being the "first" resolver.

In the conf file I posted earlier was mention of the cloudflare 1.1.1.1 server. Add that line into your dnsmasq.conf file (or whatever primary dns you want), and then (even if temporarily) put 127.0.0.1 in your MacOS network DNS, as first resolver. Let's see what that does.

brothman01 commented 5 years ago

ok I changed the file ~/.config/valet/dnsmasq.conf so that the address and the listen-address are both 1.1.1.1 and changed my network dns to 127.0.0.1.

When I did that two things happened: 1) I lost internet connectivity 2) The error shown on the browser when I try to access a valet site changed to:

This site can’t be reached
test-site.test’s server IP address could not be found.

when I reversed the put the DNS settings in System Prefs back to opendns the internet connectivity return and everything is behaving normally but the file is still changed and now the error is different (as shown above) maybe there is some other address to use in dnsmasq.conf?

drbyte commented 5 years ago

No, the address and listen-address need to be your .test and 127.0.0.1, like this:

dnsmasq.conf

address=/.test/127.0.0.1
listen-address=127.0.0.1

server=1.1.1.1

The address and listen-address are the things dnsmasq is supposed to "intercept and serve" for you, and the server=1.1.1.1 is where it's supposed to look when it receives a regular URL to resolve.

This means your NS lookups go like this, if your Mac is set to use 127.0.0.1 in its DNS:

  1. URL request happens, and gets sent to 127.0.0.1, port 53, where dnsmasq is listening (listen-address)
  2. If dnsmasq recognizes it as a domain it's supposed to serve (the address setting), then it serves it from the specified IP address ... ie: 127.0.0.1 but now it hits nginx, and serves your local site.
  3. If dnsmasq doesn't recognize it as something it's supposed to handle, it then proxies the request over to the server=1.1.1.1 nameserver for processing. So that means all non-local URLs are handled thru that. If you have more server= lines, like server=1.0.0.1, it will fallback to those if the first server= server doesn't respond.
brothman01 commented 5 years ago

I was really excited when I read this, I thought this was going to be the solution... Anyway I fixed the dnsmasq.conf file to contain what you posted above, and then changed the DNS server used by macos to be 127.0.0.1 I tried going to one of my dev sites and got this error from my browser:

Your connection was interrupted A network change was detected.

that looked like a weird error so I reloaded the page and got a different error:

This site can’t be reached test-site.test’s server IP address could not be found.
This does not make sense to me so I do not know what to try next.  I have no ideas.
brothman01 commented 5 years ago

@drbyte I think I found the problem!

$ sudo nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()

idk why it's checking 0.0.0.0, I thought it should be 127.0.0.1? Or is :80 the important part, should I change the port somehow?

drbyte commented 5 years ago

When I do that, with valet's services running already, I get the same (but with ports 80, 60, and 443, as expected).

One StackOverflow article suggests using the following to check what nginx services are running: ps ax -o pid,ppid,%cpu,vsz,wchan,command|egrep '(nginx|PID)' The idea being looking for non-homebrew versions, in case you've got another instance somewhere.

Also, for identifying what services are running on port 80: sudo lsof -i 4tcp:8080

drbyte commented 4 years ago

@brothman01 is this still a problem?

drbyte commented 4 years ago

Could this whole problem possibly be caused by the fact that apparently my xcode is out of date?

Homebrew says maybe yes: https://docs.brew.sh/Common-Issues

Another question: while it may not be related, since it's become an issue for valet share which attempts some other port bindings and such: Are you using Hyper? (as opposed to iTerm or terminal.app)

drbyte commented 4 years ago

@mattstauffer I think this can be closed.