getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.54k stars 1.41k forks source link

'C:\Program' is not recognized as an internal or external command #2868

Closed darmentrout closed 3 years ago

darmentrout commented 4 years ago

Following instructions for installing the admin plugin, I'm running into the following error:

$ bin/gpm version -f
Preparing to install vendor dependencies...

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

I'm running Windows and PHP is in the path. I'm using the Git for Windows Linux emulator.

$ php -v
PHP 7.2.7 (cli) (built: Jun 19 2018 23:44:15) ( NTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

I get the same results in PowerShell:

PS C:\inetpub\wwwroot\grav> php -v
PHP 7.2.7 (cli) (built: Jun 19 2018 23:44:15) ( NTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

PS C:\inetpub\wwwroot\grav> php bin\gpm version -f
Preparing to install vendor dependencies...

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
YuraL0ns commented 4 years ago

php bin/gpm version -f

YuraL0ns commented 4 years ago
D:\xamp\htdocs\dom.local>php bin\gpm version
You are running Grav v1.6.23
darmentrout commented 4 years ago

@YuraL0ns I get the same error when I append 'php' to the command.

YuraL0ns commented 4 years ago

@darmentrout I received an error yesterday, but I did not use php, but today I work with php and there are no errors.

pierrejoye commented 4 years ago

This is most likely due to bin/gpm not escaping the command returned by composer (can be tricky tho'

https://github.com/getgrav/grav/blob/develop/bin/gpm#L15

calling: https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Composer.php#L59

replacing that line 59 with: return $executor . escapeshellarg($composer);

and on line 46: $executor = escapeshellcmd(PHP_BINARY) . ' ';

should do it.

Also the same could happen on any platforms allowing spaces in paths btw.

pierrejoye commented 4 years ago

(btw, sorry for no PR yet, I am just starting to look at Grav and begin to like it, needed for one of my projects :)

ricardo118 commented 4 years ago

on windows if u have PATH php setup i run php bin/gpm install admin without PATH just run c:/pathtoyourphp/php.exe bin/gpm install admin