I tried to have some Emacs packages from MELPA installed system-wide, following suggestions from this question. I want to have these packages installed under /usr/local/share/emacs/site-lisp/elpa, so as root user, I've created minimal ~/.emacs as follows:
(package-initialize) (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) (setq package-user-dir "/usr/local/share/emacs/site-lisp/elpa")
Then, I started Emacs as root, and installed packages as usual, everything seemed fine. Then, I've added following at the beggining of ~/.emacs file of an ordinary user:
(package-initialize) (push "/usr/local/share/emacs/site-lisp/elpa" package-directory-list)
However, this doesn't work, in the sense that neither root user nor ordinary user could use installed packages. For example if I run following command in the scratch buffer of Emacs run as root user (I installed use-package among other packages):
following error is reported:
Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" "use-package") require(use-package) eval((require 'use-package) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp)
On the other side, if last line in the root user ~/.emacs file changed to:
(setq package-user-dir "/usr/share/emacs/site-lisp/elpa")
and also the last line in the ordinary user ~/.emacs file deleted, then everything works fine and both users could use installed packages (note that directory /usr/share/emacs/site-lisp/elpa is in package-directory-list by default).
Any hint what could be the problem here? It's not big deal, but I'd just like to keep packages installed this way under /usr/local, since as far as I remember it, according to FHS this would be the right place for packages installed this way.