composer-install
composer-install copied to clipboard
Misleading error message when validate_composer fails due to missing HOME/COMPOSER_HOME
Description
If neither HOME
nor COMPOSER_HOME
env vars are set, validate_composer will exit with non-zero but the error message is redirected to /dev/null
.
I had to fork the repo, remove the output redirection to see the issue:
Error: The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly
My suggestion would be to either add a check for HOME/COMPOSER_HOME being set and adding a targeted error message if not or to show the output of composer validate in case it fails.
The latter would also help with future issues composer validate might have.
Steps to reproduce
- Ensure composer.json is valid by running
composer validate
locally. - Run composer-install in an env where HOME/COMPOSER_HOME are not set (e.g. in a self-hosted runner or maybe by unsetting them via
env: [HOME: '', COMPOSER_HOME: '']
) - See the action fail.
Expected behavior
composer-install finishes successfully.
Output
Run ${GITHUB_ACTION_PATH}/bin/composer_paths.sh \
Error: The composer.json file at './composer.json' does not validate; run 'composer validate' to check for errors
Error: Process completed with exit code 1.
Environment details
- version of this package: 2.2.0
- PHP version: 8.0, 8.1, 8.2
- OS: Self-hosted runner with Linux x64 (Ubuntu 22.04 LTS)
Additional context
Complete tests.yaml
name: tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
tests:
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
dependency-versions: ['lowest', 'highest']
runs-on: [ self-hosted ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
uses: researchgate/composer-install@v2
with:
dependency-versions: ${{ matrix.dependency-versions }}
- name: Run test suite
run: vendor/bin/phpunit
Thank you for the very good description on how to reproduce. I'll look into this.