5

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.
mattwallace
  • 4,132
  • 6
  • 43
  • 77

3 Answers3

3

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'
mattwallace
  • 4,132
  • 6
  • 43
  • 77
3

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
},
Jan Pedryc
  • 391
  • 4
  • 10
  • Seems like they changed it that you need to use docker now: The "separate-vendor" option is deprecated. Please use Docker based deployments instead: https://docs.vapor.build/1.0/projects/environments.html#runtime – Thomas Jul 25 '21 at 16:20
2

As our team also face this issue, and we need to use in multiple projects, we made a command that is accessible in a package. Just install and do simple setup will do

https://packagist.org/packages/stephenkhoo/laravel-vapor-deploy-helper

composer require stephenkhoo/laravel-vapor-deploy-helper

Update your vapor.yml from

build:
    - 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'

to

build:
    - 'php artisan build:composer-mirror'
    - 'composer install --no-dev'