5

I am trying to use sudo emacs with no luck so far. When I run with --debug-init I get the following.

Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory "web-mode")

Why would it be different when I am using sudo emacs? Regular emacs runs fine.

3
  • 6
    Consider running Emacs as a regular user, and editing files which require root permissions with TRAMP.
    – PythonNut
    Apr 6 '16 at 1:17
  • Awesome, I'll check it out - thanks! Apr 6 '16 at 4:34
  • Other options are using sudo -e and sudo -E.
    – wasamasa
    Apr 6 '16 at 6:05
9

sudo emacs runs as the root user. One consequence is Emacs won't look for your .emacs in the home directory of your normal user, it will look in root's home directory instead. So none of your config will be loaded, and you don't have access to any packages installed by your normal user.

As mentioned in a comment, you should run Emacs as your normal user, and use tramp to open files as root. If you're trying something more arcane, we'll need more info to help you.

1
-1

What worked to me after upgrading Ubuntu from 16 to 20:

  1. make sure variable package-user-dir is pointing to place with elpa packages (smth like "~/.emacs.d/elpa" or wherever it is) and make sure is set in user's ~/.emacs file

  2. make symlinks in root home dir

sudo ln -s ~/.emacs /root
sudo ln -s ~/.emacs.d /root/
  1. make sure ~/.emacs.d/ directory and children has "read" rights to non-user (like chmod 755) After that running sudo emacs seems to read all configs right

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.