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

Better permission error message #6

Closed
sindresorhus opened this issue Jun 28, 2013 · 6 comments
Closed

Better permission error message #6

sindresorhus opened this issue Jun 28, 2013 · 6 comments

Comments

@sindresorhus
Copy link
Member

In our attempt to make everything more userfriendly we should try to help the user out more if it encounters an permission error. I've seen many of these in the wild and there isn't a lot of documentation on how to fix if you don't know about chown/chmod.

return 'You don\'t have access to this file.';

We need to come up with a good error message on how they can fix the problem. Do you know any good guides we can link to? According to passy it could either be solved with chown or chmod, but in Windows I have like no idea. The text also needs to be easily understandable. This is not just for this module as we can reuse it.

You don't seem to have access to this file. This is unfortunately you, not me, so no need to open a ticket. You can fix it by doing...

@passy @stephenplusplus @btford @addyosmani

@stephenplusplus
Copy link

I don't know how helpful of a message can be provided, since each occurrence of the error would be very different from the last. Can we print out the current perms and ownership of the file and then a whoami? Might be able to check if the ownership matches the whoami result, and then know that permissions are the issue. Either way, displaying that to the user could be helpful. On the other hand, it could be dangerous as well, as they might just try chmodding the world 777 and setting wild chowns.

I would think ownership is more the issue than permissions, but that's just a guess. I don't know if a guide would be more helpful than just printing out how to chmod and chown a file, but we won't know what to recommend setting the permissions to. Maybe easiest is just pasting the link to google, prepopulated with a query that matches the error :-S

I'm typing on an iPad and losing my mind with back spacing, so I'm just going to leave on this note, just to throw something out there:

Hmm, permissions error? Do you know anything about this?
/user/blah/blah.txt - user:group - 600

We don't seem to have the permission to access this file. Can you give it to us?

Try chmod 755 /user/blah/blah.txt

@passy
Copy link
Member

passy commented Jun 29, 2013

On the other hand, it could be dangerous as well, as they might just try chmodding the world 777 and setting wild chowns.

That's a good point. Let's play it safe and include both commands:

We don't seem to have the permission to access this file. Can you give it to us?
Try:
chmod 750 /path/to/blah.txt
chown $USER:$(id -g -n $USER) /path/to/blah.txt

For the user configuration files 750 should be reasonable, right?

@sindresorhus
Copy link
Member Author

Hmm, let's search and see if we can find a good guide we can link to. I agree we should be careful about what we tell the user.

$USER:$(id -g -n $USER)

Why not just $USER? What's the second part?

For the user configuration files 750 should be reasonable, right?

Isn't 755 the norm?

@passy
Copy link
Member

passy commented Jun 30, 2013

Since user configs could contain sensitive data I don't see why it should be readable by others.

The second part of the chown statement sets it to the user's primary group. That could be useful if it was previously owned by root.

@sindresorhus
Copy link
Member Author

Since user configs could contain sensitive data I don't see why it should be readable by others.

Then why not 600?

The second part of the chown statement sets it to the user's primary group. That could be useful if it was previously owned by root.

k, cool. can be shortened to $USER:$(id -gn $USER)

@passy
Copy link
Member

passy commented Jun 30, 2013

Then why not 600?

Agreed. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants