unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
@ 2014-11-22 22:24 Gary Oberbrunner
  2014-11-23 11:26 ` Ted Zlatanov
  2014-11-23 16:29 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Gary Oberbrunner @ 2014-11-22 22:24 UTC (permalink / raw)
  To: 19151

[-- Attachment #1: Type: text/plain, Size: 1238 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1883 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2014-11-22 22:24 bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages Gary Oberbrunner
@ 2014-11-23 11:26 ` Ted Zlatanov
  2014-11-23 16:29 ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Ted Zlatanov @ 2014-11-23 11:26 UTC (permalink / raw)
  To: 19151

On Sat, 22 Nov 2014 17:24:25 -0500 Gary Oberbrunner <garyo@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






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2014-11-22 22:24 bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages Gary Oberbrunner
  2014-11-23 11:26 ` Ted Zlatanov
@ 2014-11-23 16:29 ` Eli Zaretskii
  2016-07-02  1:24   ` npostavs
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2014-11-23 16:29 UTC (permalink / raw)
  To: Gary Oberbrunner; +Cc: 19151

> Date: Sat, 22 Nov 2014 17:24:25 -0500
> From: Gary Oberbrunner <garyo@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.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2014-11-23 16:29 ` Eli Zaretskii
@ 2016-07-02  1:24   ` npostavs
  2016-07-02  8:00     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2016-07-02  1:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Gary Oberbrunner, 19151

[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

tags 19151 patch
quit

Eli Zaretskii <eliz@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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1208 bytes --]

From a656d3ce526fc475a3067599f09b85771ea39ba0 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2016-07-02  1:24   ` npostavs
@ 2016-07-02  8:00     ` Eli Zaretskii
  2016-07-02 20:50       ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2016-07-02  8:00 UTC (permalink / raw)
  To: npostavs; +Cc: garyo, 19151

> From: npostavs@users.sourceforge.net
> Cc: Gary Oberbrunner <garyo@oberbrunner.com>,  19151@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@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.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2016-07-02  8:00     ` Eli Zaretskii
@ 2016-07-02 20:50       ` npostavs
  2016-07-03  4:14         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2016-07-02 20:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: garyo, 19151

[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]

Eli Zaretskii <eliz@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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch2 --]
[-- Type: text/x-diff, Size: 1390 bytes --]

From b1d2cf2c2ca86151c25d1c59c7eb210179086be2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2016-07-02 20:50       ` npostavs
@ 2016-07-03  4:14         ` Eli Zaretskii
  2016-07-03 13:21           ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2016-07-03  4:14 UTC (permalink / raw)
  To: npostavs; +Cc: garyo, 19151

> From: npostavs@users.sourceforge.net
> Cc: 19151@debbugs.gnu.org,  garyo@oberbrunner.com
> Date: Sat, 02 Jul 2016 16:50:42 -0400
> 
> >From b1d2cf2c2ca86151c25d1c59c7eb210179086be2 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs@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.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages
  2016-07-03  4:14         ` Eli Zaretskii
@ 2016-07-03 13:21           ` npostavs
  0 siblings, 0 replies; 8+ messages in thread
From: npostavs @ 2016-07-03 13:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: garyo, 19151

tags 19151 fixed
close 19151 25.1
quit

Eli Zaretskii <eliz@gnu.org> writes:
>
> Fine with me, thanks.

Pushed as dec75675





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-07-03 13:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-22 22:24 bug#19151: 24.4; Batch mode doesn't call package-initialize, can't find packages Gary Oberbrunner
2014-11-23 11:26 ` Ted Zlatanov
2014-11-23 16:29 ` Eli Zaretskii
2016-07-02  1:24   ` npostavs
2016-07-02  8:00     ` Eli Zaretskii
2016-07-02 20:50       ` npostavs
2016-07-03  4:14         ` Eli Zaretskii
2016-07-03 13:21           ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).