Skip to content
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

Misleading error message when validate_composer fails due to missing HOME/COMPOSER_HOME #250

Open
mdio opened this issue Oct 27, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mdio
Copy link

mdio commented Oct 27, 2023

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

  1. Ensure composer.json is valid by running composer validate locally.
  2. 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: ''])
  3. 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
@mdio mdio added the bug Something isn't working label Oct 27, 2023
@ramsey
Copy link
Owner

ramsey commented Oct 27, 2023

Thank you for the very good description on how to reproduce. I'll look into this.

@ramsey ramsey self-assigned this Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants