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

Composer install does not create the user config folder with the correct permissions #10765

Closed
b-hayes opened this issue May 6, 2022 · 4 comments
Labels

Comments

@b-hayes
Copy link

b-hayes commented May 6, 2022

My composer.json:

not relevent

Output of composer diagnose:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.3.5
PHP version: 7.2.24
PHP binary path: /usr/bin/php7.2
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
cURL version: 7.58.0 libz 1.2.11 ssl OpenSSL/1.1.1
zip: extension present, unzip present, 7-Zip not available

When I run this command:

First I installed composer

          php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
          sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
          php -r "unlink('composer-setup.php');"

Then I tried to configure it:

composer --global config process-timeout 2000

I get the following output:

In ConfigCommand.php line 195:
                                                                                                    
  touch(): Unable to create file /home/brad/.config/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] [--source] [--] [<setting-key> [<setting-value>...]]

And I expected this to happen:
These two steps are part of a script I use to setup a new machine and usually works fine to run a config command directly after installing

@b-hayes
Copy link
Author

b-hayes commented May 6, 2022

ps , permissions for the folder are drwxr-xr-x 2 root root

@Seldaek
Copy link
Member

Seldaek commented May 11, 2022

The installer creates the composer home (~/.config/composer) so I'm thinking if you use sudo there you probably want to pass -H to ensure HOME is set to root's home and not your user's home.

That way you don't have dirs created with root permissions in your user's home dir.

@b-hayes
Copy link
Author

b-hayes commented May 12, 2022

yeah makes sense any reason why this would have worked in the past and not now?
AFAIK ~ or $HOME should be the same whether or not sudo is used.

> echo $HOME
/home/brad
> sudo echo $HOME
[sudo] password for brad:
/home/brad

@Seldaek
Copy link
Member

Seldaek commented May 12, 2022

Yes but that's exactly the problem, it creates a dir in /home/brad/... with the root user as owner.

If you use sudo -H $HOME will be set to /root and you won't have that problem.

I don't know how it could have worked before.. You can also run the installer as your user and then sudo mv composer.phar /usr/bin/composer which is IMO better as it allows your user to run self-update then, and won't cause issues with the installer creating things as root. That's what we advise you do on https://getcomposer.org/download/ btw

@Seldaek Seldaek closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants