Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valet isolate does not work for linked sites with a different name to the folder #1206

Closed
adrianspacely opened this issue Mar 16, 2022 · 7 comments · Fixed by #1212
Closed
Labels

Comments

@adrianspacely
Copy link

adrianspacely commented Mar 16, 2022

  • Valet Version: 3.0.0-alpha
  • PHP Version: 8.1.3

Description:

valet isolate does not work for linked sites with a different name to the folder.

For example, the ~/Code/backend project is linked with the name company-name.

The command does not have an option to specify the site name. Suggestion:

  • What if you're in another folder? The command would benefit from a site option
  • If a site option is not given, the site name should be identified using the absolute path as a lookup for the site name vs. using the base path (folder name) as the site name.

Steps To Reproduce:

> cd ~/Code/backend
> valet isolate php7.4

In PhpFpm.php line 209:
                                                               
  The [backend] site could not be found in Valet's site list.
> valet links

+----------------+-----+-----------------------------+----------------------------------------+
| Site           | SSL | URL                         | Path                                   |
+----------------+-----+-----------------------------+----------------------------------------+
| company-name   |     | http://company-name.test    | /Users/adrianbrown/Code/backend        |
+----------------+-----+-----------------------------+----------------------------------------+

Diagnosis

sw_vers
ProductName:	macOS
ProductVersion:	12.2
BuildVersion:	21D49
valet --version
Laravel Valet 2.18.10
cat ~/.config/valet/config.json
{
    "tld": "test",
    "loopback": "127.0.0.1",
    "paths": [
        "/Users/adrianbrown/.config/valet/Sites"
    ]
}
cat ~/.composer/composer.json
{
    "require": {
        "friendsofphp/php-cs-fixer": "^2.16",
        "laravel/forge-cli": "^1.3",
        "laravel/installer": "^4.0",
        "laravel/valet": "^3.0-alpha",
        "laravel/vapor-cli": "^1.11",
        "statamic/cli": "^2.1",
        "tightenco/takeout": "^1.1",
        "tightenco/tlint": "^5.0"
    }
}
composer global diagnose
Changed current directory to /Users/adrianbrown/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Composer version: 2.1.14
PHP version: 8.1.3
PHP binary path: /opt/homebrew/Cellar/php/8.1.3.reinstall/bin/php
OpenSSL version: OpenSSL 1.1.1m  14 Dec 2021
cURL version: 7.81.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1m
zip: extension present, unzip present, 7-Zip not available
composer global outdated
Changed current directory to /Users/adrianbrown/.composer
Info from https://repo.packagist.org: �[37;44m#StandWith�[30;43mUkraine�[0m
Legend:
! patch or minor release available - update recommended
~ major release available - update possible
composer/pcre             1.0.1   ~ 3.0.0  PCRE wrapping library that offers...
composer/xdebug-handler   2.0.5   ~ 3.0.3  Restarts a process without Xdebug.
friendsofphp/php-cs-fixer v2.19.3 ~ v3.7.0 A tool to automatically fix PHP c...
guzzlehttp/psr7           1.8.3   ~ 2.1.0  PSR-7 message implementation that...
illuminate/bus            v8.83.5 ~ v9.5.1 The Illuminate Bus package.
illuminate/collections    v8.83.5 ~ v9.5.1 The Illuminate Collections package.
illuminate/container      v8.83.5 ~ v9.5.1 The Illuminate Container package.
illuminate/contracts      v8.83.5 ~ v9.5.1 The Illuminate Contracts package.
illuminate/events         v8.83.5 ~ v9.5.1 The Illuminate Events package.
illuminate/filesystem     v8.83.5 ~ v9.5.1 The Illuminate Filesystem package.
illuminate/macroable      v8.83.5 ~ v9.5.1 The Illuminate Macroable package.
illuminate/pipeline       v8.83.5 ~ v9.5.1 The Illuminate Pipeline package.
illuminate/support        v8.83.5 ~ v9.5.1 The Illuminate Support package.
illuminate/view           v8.83.5 ~ v9.5.1 The Illuminate View package.
php-cs-fixer/diff         v1.3.1  ~ v2.0.2 sebastian/diff v2 backport suppor...
psr/container             1.1.2   ~ 2.0.2  Common Container Interface (PHP F...
psr/log                   2.0.0   ~ 3.0.0  Common interface for logging libr...
psr/simple-cache          1.0.1   ~ 3.0.0  Common interfaces for simple caching
symfony/console           v5.4.5  ~ v6.0.5 Eases the creation of beautiful a...
symfony/event-dispatcher  v5.4.3  ~ v6.0.3 Provides tools that allow your ap...
symfony/filesystem        v5.4.6  ~ v6.0.6 Provides basic utilities for the ...
symfony/finder            v5.4.3  ~ v6.0.3 Finds files and directories via a...
symfony/options-resolver  v5.4.3  ~ v6.0.3 Provides an improved replacement ...
symfony/process           v5.4.5  ~ v6.0.5 Executes commands in sub-processes
symfony/service-contracts v2.4.1  ~ v3.0.0 Generic abstractions related to w...
symfony/stopwatch         v5.4.5  ~ v6.0.5 Provides a way to profile code
tightenco/collect         v8.83.2 ~ v9.2.0 Collect - Illuminate Collections ...
tightenco/takeout         v1.8.13 ~ v2.0.4 Manage your dev dependencies with...
tightenco/tlint           v5.0.16 ~ v6.2.1 Tighten linter for Laravel conven...
voku/portable-ascii       1.6.1   ~ 2.0.1  Portable ASCII library - performa...
ls -al /etc/sudoers.d/
total 8
drwxr-xr-x  4 root wheel  128 Feb  2 09:36 .
drwxr-xr-x 82 root wheel 2624 Feb 21 09:59 ..
-rw-r--r--  1 root wheel   83 Feb 21 10:28 brew
-rw-r--r--  1 root wheel   86 Feb 21 10:28 valet
brew config
HOMEBREW_VERSION: 3.4.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: fed93bb934b4a5d10b68865795970a993de31b14
Last commit: 5 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 1a75a991700df19530dcaa80799ea7de02648652
Core tap last commit: 4 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 13.1.6 build 1316
Git: 2.35.1 => /opt/homebrew/bin/git
Curl: 7.77.0 => /usr/bin/curl
macOS: 12.2-arm64
CLT: 13.3.0.0.1.1645755326
Xcode: N/A
Rosetta 2: false
brew services list
Name          Status User File
dnsmasq       none            root 
nginx         none            root 
php           none            root 
[email protected]       none                 
[email protected]       none                 
postgresql@13 none                 
unbound       none
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.86
nginx 1.21.6
[email protected] 1.1.1m
php 8.1.3.reinstall
[email protected] 7.4.28.reinstall
[email protected] 8.0.16.reinstall
brew outdated
aom
awscli
bat
boost
composer
curl
fb303
fbthrift
fizz
folly
git-delta
guile
icu4c
libgcrypt
libnghttp2
libusb
libuv
nginx
node
postgresql@13
ruby
sqlite
unbound
vim
wangle
watchman
wget
phpmon
brew tap
buo/cask-upgrade
homebrew/bundle
homebrew/cask
homebrew/cask-drivers
homebrew/cask-fonts
homebrew/cask-versions
homebrew/core
homebrew/services
nicoverbruggen/cask
teamookla/speedtest
php -v
PHP 8.1.3 (cli) (built: Feb 18 2022 09:12:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
which -a php
/opt/homebrew/bin/php
/opt/homebrew/bin/php
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.1
Loaded Configuration File:         /opt/homebrew/etc/php/8.1/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.1/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.1/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.21.6
curl --version
curl 7.77.0 (x86_64-apple-darwin21.0) libcurl/7.77.0 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.42.0
Release-Date: 2021-05-26
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.81.0
Age => 9
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => arm-apple-darwin21.1.0
SSL Version => (SecureTransport) OpenSSL/1.1.1m
ZLib Version => 1.2.11
libSSH Version => libssh2/1.10.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value

~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.40
~/.composer/vendor/laravel/valet/bin/ngrok-arm version
ngrok version 2.3.40
ls -al ~/.ngrok2
ls: cannot access '/Users/adrianbrown/.ngrok2': No such file or directory
brew info nginx
nginx: stable 1.21.6 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/opt/homebrew/Cellar/nginx/1.21.6 (26 files, 2.2MB) *
  Poured from bottle on 2022-02-01 at 10:08:25
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: [email protected], pcre2
==> Options
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /opt/homebrew/var/www

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

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
brew services restart nginx
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/nginx/bin/nginx -g daemon off;
==> Analytics
install: 42,924 (30 days), 115,913 (90 days), 493,307 (365 days)
install-on-request: 42,855 (30 days), 115,724 (90 days), 492,273 (365 days)
build-error: 107 (30 days)

brew info php
php: stable 8.1.3 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/opt/homebrew/Cellar/php/8.1.3.reinstall (514 files, 81.6MB) *
  Poured from bottle on 2022-02-21 at 09:42:29
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, openldap, [email protected], pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
	Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.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:
/opt/homebrew/etc/php/8.1/

To restart php after an upgrade:
brew services restart php
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 132,204 (30 days), 343,484 (90 days), 904,202 (365 days)
install-on-request: 109,796 (30 days), 280,406 (90 days), 797,263 (365 days)
build-error: 83 (30 days)

brew info openssl
openssl@3: stable 3.0.2 (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: Apache-2.0
==> Dependencies
Required: ca-certificates
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/openssl@3/certs

and run
/opt/homebrew/opt/openssl@3/bin/c_rehash

openssl@3 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

==> Analytics
install: 99,310 (30 days), 310,213 (90 days), 553,909 (365 days)
install-on-request: 78,424 (30 days), 234,386 (90 days), 433,751 (365 days)
build-error: 5,174 (30 days)

openssl version -a
LibreSSL 2.8.3
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"
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
sudo nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
which -a php-fpm
/opt/homebrew/sbin/php-fpm
/opt/homebrew/sbin/php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
PHP 8.1.3 (fpm-fcgi) (built: Feb 18 2022 09:12:42)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.1/php-fpm.conf --test
[16-Mar-2022 11:16:46] NOTICE: configuration file /opt/homebrew/etc/php/8.1/php-fpm.conf test is successful
ls -al ~/Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--  1 root admin  602 Feb 21 18:57 homebrew.mxcl.dnsmasq.plist
-rw-r--r--  1 root admin  490 Mar 16 11:01 homebrew.mxcl.nginx.plist
-rw-r--r--  1 root admin  586 Mar 16 11:01 homebrew.mxcl.php.plist
-rw-r--r--  1 root admin  594 Nov 10 08:04 [email protected]
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x 1 0 0 22 Jan 22 18:42 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search lan
nameserver 192.168.86.1
ifconfig lo0
lo0: flags=8049 mtu 16384
	options=1203
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=201
sh -c 'echo "------\n/opt/homebrew/etc/nginx/valet/valet.conf\n---\n"; cat /opt/homebrew/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
------
/opt/homebrew/etc/nginx/valet/valet.conf
---

3: #listen VALET_LOOPBACK:80; # valet loopback

------

sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
------
~/.config/valet/dnsmasq.d/tld-test.conf
---

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

------

...
@driesvints driesvints added the bug label Mar 16, 2022
@mattstauffer
Copy link
Collaborator

Ahhh... so I tested this in a circumstance where it was linked both as the folder's name and as another name, and that worked for me.

Just to make sure I'm right, could you test linking backend also as backend, and then run the isolation?

I'll have to think a bit about a solution for this so getting the results of your test will help a bit. Thanks!

@adrianspacely
Copy link
Author

adrianspacely commented Mar 17, 2022

That works (thank you!)

Sounds like you understand that's a workaround: isolating the linked site name would be best. For example, if I needed PHP version isolation for two different repos called app, they can't both be linked to app.test.

@adrianspacely
Copy link
Author

Quick Thought: What would be the best way to run composer/artisan/tests on the site's PHP version?

Could Valet put a php7.4 binary in the path like Forge does, and/or could there be a valet php ... command for when you don't want to keep track of which PHP version to use?

@mattstauffer
Copy link
Collaborator

Yah.. I know this is a workaround, I'm just not 100% sure how to solve it, because the entire implementation right now is based on the directory being mapped to the linked site, so i'll probably have to add a flag that allows you to override it automatically reading the directory.

Something like:

valet isolate php@7.4 --site=backend

@mattstauffer
Copy link
Collaborator

@adrianb93 I've just merged what I think is a fix into the master branch. Are you willing to test that out for me, or would it be easier if I released a tag?

Thanks!

@mattstauffer
Copy link
Collaborator

Gonna just tag a release :)

@adrianspacely
Copy link
Author

Hey, sorry. Had a busy few days. The --site option worked for me 👍

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

Successfully merging a pull request may close this issue.

3 participants