emacs tells me directory is write-protected

8,664

Wait, you're trying to save a file into the root directory? Are you sure you actually want to do that?

If you're sure, save it as /sudo::/filename instead. I don't know much about OSX, but as it's your own machine I'm assuming you have sudo permissions, in which case Emacs will prompt you for your password, and should then write the file.

Share:
8,664

Related videos on Youtube

benbyday
Author by

benbyday

Updated on September 18, 2022

Comments

  • benbyday
    benbyday over 1 year

    I have come up with an issue when I tried to save a file. I managed to write the intended file but then when I try to save it with the command Ctrl + x, Ctrl + s the message comes up Directory / write-protected How can I save the file?

  • Admin
    Admin about 11 years
    When I try to do that I get the message "Operation not permitted, /../.file"
  • choroba
    choroba about 11 years
    If you do not have the permission to create a file in a directory and you cannot change it, Emacs cannot do anything about it. Ask your system administrator.
  • Admin
    Admin about 11 years
    Also, how can I get the directory of a file I haven't saved yet?
  • Admin
    Admin about 11 years
    I am the system administrator. I'm just working on my laptop. How do I let emacs know that?
  • choroba
    choroba about 11 years
    @user1765835: As a system admin, you should be permitted to change permissions on directories. What OS are you running? Do you use ACL's?
  • choroba
    choroba about 11 years
    @user1765835: Emacs keeps a "current directory". If you do not specify otherwise, a new file is written to it.
  • Admin
    Admin about 11 years
    I'm on a MacBook Pro, OS 10.7.5 so that's Lion. I don't think I use any ACL's
  • benbyday
    benbyday about 11 years
    That's the weird thing! I'm not! It's possible I was before, but I changed the save location to a folder that is definitely fine to write in and emacs is still giving me strife.
  • phils
    phils about 11 years
    How about C-x C-w ~/filename RET to save into your home directory. Does that work?
  • yurisich
    yurisich over 9 years
    This is so useful for jumping into /etc/ without reverting to launching another session as sudo. Thanks!