phive
phive copied to clipboard
Better Error handling for non existing home directory
When trying to install phploc v2.1.3 it gives error about creating "U:" directory while there is no such drive/directory available on the system. Below is the command I'm running and error I'm getting.
D:\>php phive-0.12.0.phar install phploc@~2.1.3
Phive 0.12.0 - Copyright (C) 2015-2018 by Arne Blankerts, Sebastian Heuer and Contributors
[ERROR] An error occurred while processing your request:
Creating directory "U:\" failed.
#0 har://D:/phive-0.12.0.phar/vendor/phar-io/filesystem/src/Directory.php(100)
#1 har://D:/phive-0.12.0.phar/vendor/phar-io/filesystem/src/Directory.php(24): PharIo\FileSystem\Directory->ensureExists()
#2 har://D:/phive-0.12.0.phar/src/shared/environment/WindowsEnvironment.php(24): PharIo\FileSystem\Directory->__construct()
#3 har://D:/phive-0.12.0.phar/src/shared/config/Config.php(49): PharIo\Phive\WindowsEnvironment->getHomeDirectory()
#4 har://D:/phive-0.12.0.phar/src/Factory.php(382): PharIo\Phive\Config->getHomeDirectory()
#5 har://D:/phive-0.12.0.phar/src/Factory.php(279): PharIo\Phive\Factory->getPharRegistry()
#6 har://D:/phive-0.12.0.phar/src/Factory.php(127): PharIo\Phive\Factory->getInstallService()
#7 har://D:/phive-0.12.0.phar/src/commands/CommandLocator.php(40): PharIo\Phive\Factory->getInstallCommand()
#8 har://D:/phive-0.12.0.phar/src/shared/cli/Runner.php(211): PharIo\Phive\CommandLocator->getCommand()
#9 har://D:/phive-0.12.0.phar/src/shared/cli/Runner.php(70): PharIo\Phive\Cli\Runner->execute()
#10 :\phive-0.12.0.phar(306): PharIo\Phive\Cli\Runner->run()
#11 {main}
Environment: PHP 7.1.14
Phive Version: 0.12.0
This should not have happened and is most likely a bug.
Please report it at https://github.com/phar-io/phive/issues, make sure you include
the full output of this error message. Thank you!
I also tried below but to no use: D:>php phive-0.12.0.phar install [email protected]
While I agree that phive
shouldn't crash on this, the problem is a broken environment setup on your end.
The HOME directory in your terminal session is set to "U:", which obviously doesn't exist and for obvious reasons can not be created either.
How come HOME directory is set to something that doesn't exist and how to fix it? Appreciate your help.
I'm not sure we/I can help here as that's a configuration on your windows system.
Traditionally, on operating systems that work with drive letters (like windows) use the drive letter U: for network based home directories - potentially having picked U for User. That of course only works when actually being connected to the network.
From within Phive, we only read the HOME directory setting from the environment. In windows this are HOMEDRIVE and HOMEPATH environment variables. Code can be found here and here. We do not have any control over these values.
i wasn't willing to accept a hard-coded internal path setup inside the phar code.
For what it's worth (keeping in mind it's 4am)...
i'm using Windows, and i worked my way around the HOME*
variables within a .bat file (attached, just switch .txt
to .bat
). Temporarily changing the variables Phive assumes will attempt to install the packages there.
Unfortunately, #208 is preventing me from getting any packages successfully installed to confirm if this actually works, but i do see the .phive
and tools
directories get created in the intended target, so that's a good sign.
Another benefit is you can add the BAT's directory to %PATH%
and call phive ...
as a typical command.
i follow this pattern for several other phar tools (composer, pear/pecl, phpcs, etc.) and so far so good, as brittle as my BAT code is... Should be easy enough to build parallels for a Linux environment.
You realize you can just as well specify an alternative home directory by simply suppling --home
as a parameter to phive, right?
I'm not sure though, what you are trying to fix here?
@theseer that doesn't work sadly :
evs@XSA-LT2020003:~/sites/dlk_upgrade/current/qa (preview/staging3) $ p81 phive.phar --home /tmp
[ERROR] An error occurred while processing your request:
Creating directory "/home/dockeruser/.phive" failed.
#0 vendor/phar-io/filesystem/src/Directory.php(67)
#1 src/shared/config/Config.php(64): PharIo\FileSystem\Directory->ensureExists()
#2 src/services/migration/HomePharsXmlMigration.php(24): PharIo\Phive\Config->getHomeDirectory()
#3 src/services/migration/MigrationFactory.php(30): PharIo\Phive\HomePharsXmlMigration->__construct()
#4 src/services/migration/MigrationService.php(28): PharIo\Phive\MigrationFactory->getMigrations()
#5 src/shared/cli/Runner.php(198): PharIo\Phive\MigrationService->ensureFitness()
#6 src/shared/cli/Runner.php(93): PharIo\Phive\Cli\Runner->ensureFitness()
#7 (354): PharIo\Phive\Cli\Runner->run()
#8 {main}
Environment: PHP 8.1.1 (on Linux 5.13.0-51-generic)
Phive Version: 0.15.1
This should not have happened and is most likely a bug.
Please report it at https://github.com/phar-io/phive/issues, make sure you include
the full output of this error message. Thank you!