The command "COMPOSER_MIRROR_PATH_REPOS=1 composer install" failed error when running laravel vapor deploy

Viewed 2191

I'm developing an application using the latest Laravel 7 along with deploying to AWS using Vapor. I'm on Windows 10 environment.

When running the following command to deploy to staging vendor/bin/vapor deploy I get the following error.

In Process.php line 252:

  The command "COMPOSER_MIRROR_PATH_REPOS=1 composer install" failed.

  Exit Code: 1(General error)

  Working directory: C:\Users\Matthew Wallace\Development\web\615ioDemos/.vap
  or/build/app

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


  Error Output:
  ================
  'COMPOSER_MIRROR_PATH_REPOS' is not recognized as an internal or external c
  ommand,
  operable program or batch file.
2 Answers

The solution for this problem was to open the vapor.yml and modify the composer install lines in the build: sections for staging and production by removing 'COMPOSER_MIRROR_PATH_REPOS=1'

This is what my build section looks like now.

build:
    - 'composer install'
    - 'php artisan event:cache'
    - 'npm ci && npm run dev && rm -rf node_modules'

The answer above is just partly a fix. (answ by @mattwallace)

The whole story:

  1. Remove COMPOSER_MIRROR_PATH_REPOS=1 in vapor.yml
  2. Add in composer.json under config: "COMPOSER_MIRROR_PATH_REPOS": true

More details:

You'll probably run into problems while attaching a database to your app while working on Win (at least I did :P).

The issue is with the strategy of resolving paths. By default the strategy is set to "symlink" - I assume the more appropriate way would be to set this to "mirror", as we build the project locally and move the content on a different host (filesystem structure etc.).

The error above is just the terminal/powershell not knowing how to handle the first param in the command line - COMPOSER_MIRROR_PATH_REPOS - it still needs to be set up.

More about the param here.

In the docs you can find:

You can set a number of environment variables that override certain settings. Whenever possible it is recommended to specify these settings in the config section of composer.json instead.

There you go:

"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true,
    "COMPOSER_MIRROR_PATH_REPOS": true
},
Related