Skip to content

Bug: Installing a third-party tool results in an empty auth.json file (and a composer failure). #980

@PedroTroller

Description

@PedroTroller

Describe the bug

In order to use composer-normalize, I am using your action to install PHP and composer-normalize on my self-hosted runner. Until yesterday, everything was working perfectly (well done, by the way, it's great 👏), but since yesterday (and version 2.35) I've been having a problem.

First, this job fails when the action is executed, I get a JQ error, then composer tells me that the JSON file auth.json is invalid (it is indeed completely empty).

I want to point out that when I revert to version 2.34.1 of your action, everything works perfectly again (this is the workaround we have implemented).

Version

  • v2
  • v1

Runners

Self Hosted

Operating systems

Ubuntu 24.04.2

PHP versions

8.3.23

To Reproduce

jobs:
  composer:
    steps:
      - name: Setup PHP and normalize
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
          tools: ergebnis/composer-normalize

Expected behavior

Run shivammathur/[email protected]
/usr/bin/bash /data/runner/_actions/shivammathur/setup-php/2.34.1/src/scripts/run.sh

==> Setup PHP
✓ PHP Found PHP 8.3.23

==> Setup Tools
✓ composer Added composer 2.8.10
✓ composer-normalize Added composer-normalize 2.47.0

==> Sponsor setup-php
✓ setup-php https://setup-php.com/sponsor
$ composer --working-dir="image-magick" normalize --dry-run --diff
Running ergebnis/composer-normalize by Andreas Möller and contributors.

./composer.json is already normalized.

Screenshots/Logs

Run shivammathur/setup-php@v2
/usr/bin/bash /data/runner/_actions/shivammathur/setup-php/v2/src/scripts/run.sh

==> Setup PHP
✓ PHP Installed PHP 8.3.23

==> Setup Tools
jq: invalid JSON text passed to --argjson
Use jq --help for help with command-line options,
or see the jq manpage, or online docs  at https://jqlang.github.io/jq
✓ composer Added composer 2.8.10
✗ composer-normalize Could not setup composer-normalize

==> Sponsor setup-php
✓ setup-php https://setup-php.com/sponsor
$ composer --working-dir="php" normalize --dry-run --diff
Error: "/home/runner/.composer/auth.json" does not contain valid JSON
Parse error on line 1:

^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

In JsonFile.php line 381:
                                                                          
  "/home/runner/.composer/auth.json" does not contain valid JSON          
  Parse error on line 1:                                                  
                                                                          
  ^                                                                       
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['  
                                                                          

Error: Process completed with exit code 1.

Additional context

The test was run on a blank runner; there is no auth.json file on the file system. After running the job, an empty auth.json file was created, causing composer to fail completely (see the invalid json error message).

The version of JQ installed is the one officially supported by Ubuntu 24.04, i.e. 1.7, and this package was installed this morning at 5:30 AM CEST.

Are you willing to submit a PR?

No

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions