whisky
whisky copied to clipboard
[Bug] Can't run global `whisky install` on WAMP
Environment
- OS: Windows 10
- Shell: PowerShell, Batch, Bash(git - MINGW64)
- PHP version: 8.1
- Whisky version: 0.5.1
Step to reproduce
# install global
composer global require projektgopher/whisky
# new repo
mkdir test
cd test
git init
composer init -n --name=test/test --autoload=src/
echo /vendor/ >> .gitignore
git add .
git commit -m "first commit"
# install whisky.json using global package
whisky install
Error
In Filesystem.php line 59:
File does not exist at path C:/develop/projects/gepe/vendor/projektgopher/whisky/stubs/whisky.json.
Audit
| key | value |
|---|---|
| - Whisky - | |
| installed globally? | yes |
| running globally? | no |
| dogfooding? | no |
| base path | C:/develop/projects/test/vendor/projektgopher/whisky/ |
| bin path | C:/develop/projects/test/vendor/bin/whisky |
| - Platform - | |
| cwd | C:/develop/projects/test |
| getGlobalComposerHome | C:\Wamp.NET\bin.php\composerHome |
| getGlobalComposerBinDir | C:\Wamp.NET\bin.php\composerHome/vendor/bin |
| isWindows | yes |
| isNotWindows | no |
| gitIsInitialized | yes |
| gitIsNotInitialized | no |
| - global - | |
| base_path | phar://C:/Wamp.NET/bin/7-php_8.1.0_x64/composerHome/vendor/projektgopher/whisky/builds/whisky |
| normalized base_path | phar://C:/Wamp.NET/bin/7-php_8.1.0_x64/composerHome/vendor/projektgopher/whisky/builds/whisky |
Sorry, I don't have time to review it today, tomorrow I'll try to investigate more.
I see two issues here, we're not normalizing the composer paths in our code, and then the directory returned by composer global home/bin doesn't match where it's actually being executed from. Once of the directories in that path must be a symlink
I'm glad I added that audit command. This is so much easier to diagnose 💪
I wonder if the easier way to determine isRunningGlobally() is to just search the base_path for 'composerHome' | '.composer' instead of using str_starts_with and passing getGlobalComposerHome.
It seems like composerHome is a non-standard directory name.
https://github.com/composer/composer/blob/main/src/Composer/Factory.php#L45
Some comments:
- This package is not "Wamp", it is "Wamp.NET" (it has the same philosophy but it is another implementation).
- It effectively uses a symlink on Windows to quickly switch between different versions of PHP (each version of PHP has its own ComposerHome).
It seems like
composerHomeis a non-standard directory name.https://github.com/composer/composer/blob/main/src/Composer/Factory.php#L45
Exactly, Composer for Windows installs the data in C:\Users\(your user)\AppData\Roaming\Composer, and does not set the COMPOSER_HOME environment variable, if it is set that environment variable can be rewritten, but use default location