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

Self-hosted runners fail composer setup if not root user #477

Closed
3 of 5 tasks
lucasmdrs opened this issue Jul 21, 2021 · 1 comment
Closed
3 of 5 tasks

Self-hosted runners fail composer setup if not root user #477

lucasmdrs opened this issue Jul 21, 2021 · 1 comment
Assignees
Labels
bug Something isn't working self-hosted

Comments

@lucasmdrs
Copy link

When using the setup-action on a self-hosted runner, the composer setup fails (without exiting) due to lack of permission.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems

Docker/Ubuntu

PHP versions

Tested with 8.0.8, probably happening with every version

To Reproduce

Try to setup-php in a self-hosted agent without root user:

- name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.0"
          ini-values: memory_limit=-1
          tools: composer:v2
          extensions: apcu, mongodb, redis, sockets, sodium

Expected behavior

Setup composer properly


==> Setup PHP
✓ PHP Installed PHP 8.0.8

==> Setup Tools
✓ composer Added composer 2.1.3

==> Setup Extensions
✓ apcu Enabled
✓ mongodb Enabled
✓ redis Enabled
✓ sockets Enabled
✓ sodium Enabled

==> Add php.ini values
✓ memory_limit=-1 Added to php.ini

==> Support this project
✓ setup-php https://setup-php.com/support

Screenshots/Logs


==> Setup PHP
✓ PHP Installed PHP 8.0.8

==> Setup Tools
tee: /home/runner/.composer/composer.json: Permission denied
chmod: cannot access '/home/runner/.composer/composer.json': No such file or directory

                                                                                               
  [ErrorException]                                                                             
  touch(): Unable to create file /home/runner/.composer/config.json because Permission denied  
                                                                                               

config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--] [<setting-key>] [<setting-value>]...

✓ composer Added composer 2.1.3

==> Setup Extensions
✓ apcu Enabled
✓ mongodb Enabled
✓ redis Enabled
✓ sockets Enabled
✓ sodium Enabled

==> Add php.ini values
✓ memory_limit=-1 Added to php.ini

==> Support this project
✓ setup-php https://setup-php.com/support

Additional context

There's a missing sudo in the tee command on commons.sh

if ! [ -e "$composer_json" ]; then
sudo mkdir -p "$(dirname "$composer_json")"
echo '{}' | tee "$composer_json" >/dev/null
sudo chmod 644 "$composer_json"

But that might not solve the problem, not using sudo at all or ensuring that the folder is accessible by the current user would be a better approach.

Are you willing to submit a PR?

Yes, once agreed with one of the suggestions above.

@lucasmdrs lucasmdrs added the bug Something isn't working label Jul 21, 2021
@shivammathur
Copy link
Owner

@lucasmdrs
Fixed in 36cb9fb
Now the composer's home directory will be owned by the current user, and that should fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working self-hosted
Projects
None yet
Development

No branches or pull requests

2 participants