Search code examples
emacselpa

Emacs packages, installing globally versus locally with elpa


I run linux and use different user names to segment different activities. Using elpa, there are some packages that I would like to install so that they get loaded no matter who the user, there are packages that I would like to be loaded for only one user.

Org-mode for example is something I would want to be loaded by every user. C++ related packages I might want for user client1, but not ruby packages. I might want ruby related packages for user client2, but not C++ packages. There might be a new package for C++ programming that I do not want to include in serious work but want to play with using user experimental.

It used to be that global stuff you put in site lisp and local stuff you put someplace in ~, but that doesn't seem to work with elpa.


Solution

  • package.el looks for installed packages along the package-directory-list path (additionally to package-user-dir which is where packages get installed).

    So I'd recommend you arrange to have a "global" user. And then change all other users to include

    (require 'package)
    (push "/home/globaluser/.emacs.d/elpa" package-directory-list)
    

    in their ~/.emacs. This way, any package that you want to install for all users should be installed by globaluser.

    BTW, another way to attack the vector is to distinguish "installed" and "enabled". I.e. always install your packages globally, and then have each user tweak its package-load-list in order to disable specific packages.

    Finally any package whose mere installation&enabling (where "enabling" means to load the package's own -autoloads.el) ends up interfering with normal work is a bug (in my book), so yet another solution is to just install and enable all packages globally. And if the C++-using-user gets annoyed by some ruby-related packages, then file a bug report to the maintainer of the ruby-related package.