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

`addons:refresh` does not work under Windows (with fix) #1169

Closed
rrelmy opened this Issue Dec 22, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@rrelmy

rrelmy commented Dec 22, 2016

Expected behaviour

Running php please addons:refresh should work as expected

Actual behaviour

The composer.json file gets written but the command can not be invoked.

Steps to reproduce

  1. Add an addon which has a dependency (Example: https://github.com/edalzell/iCal)
  2. Run php please addons:refresh from command line
  3. Look at the error, make a sad face and visit apple.com to buy a Mac

Server configuration

Operating system: Windows 10
PHP version: 7.1.0
Statamic version: 2.1.18

Logs

If any logs (browser, server, or Statamic) are appropriate...

mystatamicsite master % = $ php please addons:refresh
Adding packages: lesaff/useragent
Please wait while dependencies are updated via Composer. This may take a while.
The command "php composer.phar update lesaff/useragent --prefer-dist --no-dev --optimize-autoloader" failed.
Exit Code: 1(General error)

Output:
================

Error Output:
================
Der Befehl "php" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

Dependencies updated!

The error means php could not be found

@rrelmy

This comment has been minimized.

rrelmy commented Dec 22, 2016

First workaround replace the call inside Statamic\Extend\Management\ComposerManager on line 95

Incomplete fix

        $process = new Process($command, $this->path(), [
            'COMPOSER_HOME' => local_path('composer'),
            'PATH' => getenv('PATH'),
            'TEMP' => getenv('TEMP'),
            'PHP_INI_SCAN_DIR' => getenv('PHP_INI_SCAN_DIR'),
        ]);

PATH needs to be passed to share the same paths and find the php executable.
TEMP needs to be passed because else, composer tries to write to C:/WINDOWS which fails
I have a PHP_INI_SCAN_DIR which also need to be passed or PHP wan't load the necessary extensions

Does it now work? No :-(

[Composer\Downloader\TransportException]                                                                                       

The "https://api.github.com/repos/statamic/laravel-search" file could not be downloaded: php_network_getaddresses: getaddrinfo failed:
Der angegebene Host ist unbekannt.

failed to open stream: php_network_getaddresses: getaddrinfo failed:
Der angegebene Host ist unbekannt.

Translation: host is unknown

@rrelmy

This comment has been minimized.

rrelmy commented Dec 22, 2016

Passing all the environment variables, as described here http://php.net/manual/en/function.proc-open.php#117912, works

Working fix

        $process = new Process(
            $command,
            $this->path(),
            array_merge($_SERVER, ['COMPOSER_HOME' => local_path('composer')])
        );

Please don't ask me which individual variable is responsive to get the networking running 😨

@rrelmy rrelmy changed the title from `addons:refresh` does not work under Windows to `addons:refresh` does not work under Windows (with fix) Dec 22, 2016

@edalzell

This comment has been minimized.

edalzell commented Dec 22, 2016

With @rrelmy's fix, it still works on macOS Sierra, PHP 7.0, so that's great.

@jackmcdade jackmcdade self-assigned this Mar 16, 2017

@jasonvarga jasonvarga closed this Mar 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment