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
sudo composer self-update changes owner to root for current user composer cache dir #6602
Comments
|
Agreed that this should never occur. |
|
You run composer with sudo, so I am not sure why you expect any different results? |
|
@alcohol it reassigned cache ownership for the current user to root, with mode 755. He cannot delete his own cache anymore. |
|
Then he should not use sudo. Depending on your local setup, sudo can inherit the |
|
|
Yup, without -H the HOME dir is not set as root's, so composer will behave as usual but with your user's home dir. I agree that for self-update and well in general it should not change the ownership though. Are you sure that if the dir already exists it changes it to be root owned? If it does not exist yet I can see that it would create it as root, and I don't know if we wanna fix that, but an existing one should not be changed. |
That's the core point, all the rest is logical. edit: looking at TS again it seems to be first run though. In that case it makes sense that it's happening. We may however want to 777 the caches and/or detect the |
Will recheck it again, but afraid that it changes owner when directory already exists. |
|
Can we reopen this issue with DX label and low priority? We can improve DX a little bit by adding additional checks. For example
We can inform user and ask prompt for confirm possible destructive actions. |
|
Right a more verbose warning sounds reasonable. |
|
hello, I'd like to contribute to Composer and go deeper in my knowledge of PHP, if not, please propose me an alternative one, |
|
Assuming you have proper knowledge of Unix file permissions and a clear idea on how to solve the issue. If in doubt I'd recommend sharing your plans first and asking for feedback, I'll be happy to comment if pinged as I wrote some sudo-related parts of Composer. In all honesty though the Composer codebase is not exactly "simple". I'm not sure where you are now if you wish to "go deeper" but contributing to this project is not something I'd recommend right away to someone without 3+ years of solid PHP knowledge. This issue may be a "Good First Issue" but Composer is not really a "Good First Project" ;) |
|
I'll do that! To propose an implementation before starting to do it. I work with PHP since 5 years and I've been using Linux daily since 8+ years, |
|
There is already a warning message when the home directory owner is different from the user caller of the check is done here: I tried many different combinations ( @Koc can you please try to see if you still get the error in the current version? Thank you! |
|
Is this still an active issue? |
|
No idea, but closing as IMO not really a big issue. We warn on sudo usage already. |
When I run this command:
I get the following output:
And I expected this to happen:
sudo chown dev:dev -R ~/.composerfixes the problem but I need call it after eachsudo composer self-updateThe text was updated successfully, but these errors were encountered: