Subject: 24.4; Batch mode doesn't call package-initialize, can't find packages

From: Gary Oberbrunner <[email-masked]>
Date: Sat, 22 Nov 2014 17:24:25 -0500

In batch mode, emacs doesn't load installed packages, although the doc
implies that it should.  If you want to eval forms that require packages,
you have to call (package-initialize) explicitly.

For instance, from a shell:

% emacs -batch -eval '(progn (message "%s" package-directory-list))'
Symbol's value as variable is void: package-directory-list
% emacs -batch -eval '(progn (package-initialize) (message "%s"
package-directory-list))'
(c:/emacs/emacs/share/emacs/24.4/site-lisp/elpa
c:/emacs/emacs/share/emacs/site-lisp/elpa)

Or, since I have the 'dash' package installed in my ~/.emacs.d/elpa:

% emacs -batch -eval "(progn (require 'dash))"
Cannot open load file: no such file or directory, dash
% emacs -batch -eval "(progn (package-initialize) (require 'dash))"
%

The documentation at
http://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html
is not totally clear on this, but it implies that packages should be loaded.

In GNU Emacs 24.4.1 (i686-pc-mingw32)
 of 2014-10-24 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr'

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Apropos

-- 
Gary