GNU bug report logs -
#19151
24.4; Batch mode doesn't call package-initialize, can't find packages
Previous Next
Reported by: Gary Oberbrunner <garyo <at> oberbrunner.com>
Date: Sat, 22 Nov 2014 22:32:02 UTC
Severity: minor
Tags: fixed, patch
Found in version 24.4
Fixed in version 25.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19151 in the body.
You can then email your comments to 19151 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sat, 22 Nov 2014 22:32:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gary Oberbrunner <garyo <at> oberbrunner.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 22 Nov 2014 22:32:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sun, 23 Nov 2014 11:27:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Sat, 22 Nov 2014 17:24:25 -0500 Gary Oberbrunner <garyo <at> oberbrunner.com> wrote:
GO> In batch mode, emacs doesn't load installed packages, although the doc
GO> implies that it should. If you want to eval forms that require packages,
GO> you have to call (package-initialize) explicitly.
...
GO> The documentation at
GO> http://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html
GO> is not totally clear on this, but it implies that packages should be loaded.
I see this in the docs at (info "(elisp) Startup Summary")
15. If ‘package-enable-at-startup’ is non-‘nil’, it calls the function
‘package-initialize’ to activate any optional Emacs Lisp package
that has been installed. *Note Packaging Basics::.
Seems pretty clear to me. We could use a command-line argument to make
--batch more useful, though. Something like
--package-initialize, -p Set `package-enable-at-startup' so packages are initialized
WDYT?
Ted
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sun, 23 Nov 2014 16:30:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 19151 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 22 Nov 2014 17:24:25 -0500
> From: Gary Oberbrunner <garyo <at> oberbrunner.com>
>
> 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.
I think this is a documentation bug. package-initialize is not
invoked under -q (which I Think makes sense), and -batch implies -q.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sat, 02 Jul 2016 01:25:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 19151 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 19151 patch
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
>> 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.
>
> I think this is a documentation bug. package-initialize is not
> invoked under -q (which I Think makes sense), and -batch implies -q.
Other items nearby explicitly talk about those options, here's a patch
to add it for package-initialize as well. Looks ok?
[v1-0001-Explain-when-package-initialize-isn-t-called.patch (text/x-diff, inline)]
From a656d3ce526fc475a3067599f09b85771ea39ba0 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Fri, 1 Jul 2016 21:15:28 -0400
Subject: [PATCH v1] Explain when package-initialize isn't called
* doc/lispref/os.texi (Startup Summary): Explain that package-initialize
is not called when options -q, -Q, or --batch were passed (Bug #19151).
---
doc/lispref/os.texi | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 5f189b9..e15eec7 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -155,9 +155,11 @@ Startup Summary
option @samp{--batch} was specified.
@item
-If @code{package-enable-at-startup} is non-@code{nil}, it calls the
-function @code{package-initialize} to activate any optional Emacs Lisp
-package that has been installed. @xref{Packaging Basics}.
+It calls the function @code{package-initialize} to activate any
+optional Emacs Lisp package that has been installed. @xref{Packaging
+Basics}. This is not done if @code{package-enable-at-startup} is
+@code{nil}, nor if the options @samp{-q}, @samp{-Q}, or @samp{--batch}
+were specified.
@vindex after-init-time
@item
--
2.8.0
Added tag(s) patch.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 02 Jul 2016 01:25:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sat, 02 Jul 2016 08:01:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 19151 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> users.sourceforge.net
> Cc: Gary Oberbrunner <garyo <at> oberbrunner.com>, 19151 <at> debbugs.gnu.org
> Date: Fri, 01 Jul 2016 21:24:45 -0400
>
> >From a656d3ce526fc475a3067599f09b85771ea39ba0 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Fri, 1 Jul 2016 21:15:28 -0400
> Subject: [PATCH v1] Explain when package-initialize isn't called
>
> * doc/lispref/os.texi (Startup Summary): Explain that package-initialize
> is not called when options -q, -Q, or --batch were passed (Bug #19151).
> ---
> doc/lispref/os.texi | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
> index 5f189b9..e15eec7 100644
> --- a/doc/lispref/os.texi
> +++ b/doc/lispref/os.texi
> @@ -155,9 +155,11 @@ Startup Summary
> option @samp{--batch} was specified.
>
> @item
> -If @code{package-enable-at-startup} is non-@code{nil}, it calls the
> -function @code{package-initialize} to activate any optional Emacs Lisp
> -package that has been installed. @xref{Packaging Basics}.
> +It calls the function @code{package-initialize} to activate any
> +optional Emacs Lisp package that has been installed. @xref{Packaging
> +Basics}. This is not done if @code{package-enable-at-startup} is
> +@code{nil}, nor if the options @samp{-q}, @samp{-Q}, or @samp{--batch}
> +were specified.
I would rephrase the last sentence:
However, when @code{package-enable-at-startup} is @code{nil}, Emacs
doesn't initialize packages. When Emacs is started with one of the
options @samp{-q}, @samp{-Q}, or @samp{--batch},
@code{package-enable-at-startup} is @code{nil} by default; to
initialize packages in that case, explicitly set that variable to a
non-@code{nil} value (e.g., via the @samp{--eval} option).
The reason is that the additional explicit information about how to
initialize packages in this case is IMO valuable, and also we should
avoid passive tense as much as possible.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sat, 02 Jul 2016 20:51:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 19151 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> +It calls the function @code{package-initialize} to activate any
>> +optional Emacs Lisp package that has been installed. @xref{Packaging
>> +Basics}. This is not done if @code{package-enable-at-startup} is
>> +@code{nil}, nor if the options @samp{-q}, @samp{-Q}, or @samp{--batch}
>> +were specified.
>
> I would rephrase the last sentence:
>
> However, when @code{package-enable-at-startup} is @code{nil}, Emacs
> doesn't initialize packages. When Emacs is started with one of the
> options @samp{-q}, @samp{-Q}, or @samp{--batch},
> @code{package-enable-at-startup} is @code{nil} by default; to
> initialize packages in that case, explicitly set that variable to a
> non-@code{nil} value (e.g., via the @samp{--eval} option).
Phrasing is alright, but it's factually inaccurate. In startup.el we
have
;; If any package directory exists, initialize the package system.
(and user-init-file
package-enable-at-startup
...[lots more file searching]
(package-initialize))
The -q option sets user-init-file to nil. I guess we needn't mention
user-init-file by name in the docs as it's an internal detail. Here's a
new patch:
[v2-0001-Explain-when-package-initialize-isn-t-called.patch (text/x-diff, inline)]
From b1d2cf2c2ca86151c25d1c59c7eb210179086be2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Fri, 1 Jul 2016 21:15:28 -0400
Subject: [PATCH v2] Explain when package-initialize isn't called
* doc/lispref/os.texi (Startup Summary): Explain that package-initialize
is not called when options -q, -Q, or --batch were passed (Bug #19151).
---
doc/lispref/os.texi | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 5f189b9..ec14b01 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -155,9 +155,13 @@ Startup Summary
option @samp{--batch} was specified.
@item
-If @code{package-enable-at-startup} is non-@code{nil}, it calls the
-function @code{package-initialize} to activate any optional Emacs Lisp
-package that has been installed. @xref{Packaging Basics}.
+It calls the function @code{package-initialize} to activate any
+optional Emacs Lisp package that has been installed. @xref{Packaging
+Basics}. However, Emacs doesn't initialize packages when
+@code{package-enable-at-startup} is @code{nil} or when it's started
+with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To
+initialize packages in the latter case, @code{package-initialize}
+should be called explicitly (e.g., via the @samp{--funcall} option).
@vindex after-init-time
@item
--
2.8.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sun, 03 Jul 2016 04:16:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 19151 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> users.sourceforge.net
> Cc: 19151 <at> debbugs.gnu.org, garyo <at> oberbrunner.com
> Date: Sat, 02 Jul 2016 16:50:42 -0400
>
> >From b1d2cf2c2ca86151c25d1c59c7eb210179086be2 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Fri, 1 Jul 2016 21:15:28 -0400
> Subject: [PATCH v2] Explain when package-initialize isn't called
>
> * doc/lispref/os.texi (Startup Summary): Explain that package-initialize
> is not called when options -q, -Q, or --batch were passed (Bug #19151).
> ---
> doc/lispref/os.texi | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
> index 5f189b9..ec14b01 100644
> --- a/doc/lispref/os.texi
> +++ b/doc/lispref/os.texi
> @@ -155,9 +155,13 @@ Startup Summary
> option @samp{--batch} was specified.
>
> @item
> -If @code{package-enable-at-startup} is non-@code{nil}, it calls the
> -function @code{package-initialize} to activate any optional Emacs Lisp
> -package that has been installed. @xref{Packaging Basics}.
> +It calls the function @code{package-initialize} to activate any
> +optional Emacs Lisp package that has been installed. @xref{Packaging
> +Basics}. However, Emacs doesn't initialize packages when
> +@code{package-enable-at-startup} is @code{nil} or when it's started
> +with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To
> +initialize packages in the latter case, @code{package-initialize}
> +should be called explicitly (e.g., via the @samp{--funcall} option).
>
> @vindex after-init-time
> @item
> --
> 2.8.0
Fine with me, thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19151
; Package
emacs
.
(Sun, 03 Jul 2016 13:22:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 19151 <at> debbugs.gnu.org (full text, mbox):
tags 19151 fixed
close 19151 25.1
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
>
> Fine with me, thanks.
Pushed as dec75675
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sun, 03 Jul 2016 13:22:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 25.1, send any further explanations to
19151 <at> debbugs.gnu.org and Gary Oberbrunner <garyo <at> oberbrunner.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sun, 03 Jul 2016 13:22:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 01 Aug 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 15 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.