GNU bug report logs - #16406
load prefers directories rather than searching load-path

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Fri, 10 Jan 2014 05:25:01 UTC

Severity: normal

Tags: fixed, patch

Found in version 24.3

Fixed in version 26.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 16406 in the body.
You can then email your comments to 16406 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Fri, 10 Jan 2014 05:25:02 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: load prefers directories rather than searching load-path
Date: Fri, 10 Jan 2014 00:23:57 -0500
Package: emacs
Version: 24.3

From the Emacs source directory, wanting to load the standard info.el library:

./src/emacs -Q -l info

  Cannot open load file: is a directory, /tmp/emacs/trunk/info

It seems dumb for load prefer a directory.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Fri, 10 Jan 2014 14:47:02 GMT) Full text and rfc822 format available.

Message #6 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Fri, 10 Jan 2014 09:46:38 -0500
> It seems dumb for load prefer a directory.

You have just insulted Emacs.  Pay $50 to each player.


        Stefan "sorry, too much Monopoly lately"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sun, 21 Aug 2016 16:36:02 GMT) Full text and rfc822 format available.

Message #9 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Glenn Morris <rgm <at> gnu.org>
Cc: 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sun, 21 Aug 2016 12:35:22 -0400
[Message part 1 (text/plain, inline)]
tags 16406 patch
quit

Glenn Morris <rgm <at> gnu.org> writes:

> Package: emacs
> Version: 24.3
>
> From the Emacs source directory, wanting to load the standard info.el library:
>
> ./src/emacs -Q -l info
>
>   Cannot open load file: is a directory, /tmp/emacs/trunk/info
>
> It seems dumb for load prefer a directory.

Seems simple enough to fix, here is a patch (this also covers #17848
"add suffix search to -l even when directory part in argument"):

[v1-0001-Improvements-to-load-argument-handling.patch (text/plain, inline)]
From 38faf8846f7738b533aa29622fd7f78a8c6c81cd Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 21 Aug 2016 10:51:38 -0400
Subject: [PATCH v1] Improvements to --load argument handling

* lisp/startup.el (command-line-1): Search for files with load-suffixes
in default dir (Bug #17484).  Only pass normal files that were found,
since `load' doesn't handle directories (Bug #16406).
---
 lisp/startup.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index fcdc376..9134604 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2392,8 +2392,9 @@ command-line-1
                                    (or argval (pop command-line-args-left))))
                             ;; Take file from default dir if it exists there;
                             ;; otherwise let `load' search for it.
-                            (file-ex (expand-file-name file)))
-                       (when (file-exists-p file-ex)
+                            (file-ex (locate-file file (list default-directory)
+                                                  load-suffixes)))
+                       (when (and file-ex (file-regular-p file-ex))
                          (setq file file-ex))
                        (load file nil t)))
 
-- 
2.9.2


Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 21 Aug 2016 16:36:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 16:44:01 GMT) Full text and rfc822 format available.

Message #14 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Glenn Morris <rgm <at> gnu.org>
Cc: 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 12:43:29 -0400
[Message part 1 (text/plain, inline)]
npostavs <at> users.sourceforge.net writes:

>
> Seems simple enough to fix, here is a patch (this also covers #17848
> "add suffix search to -l even when directory part in argument"):

That one broke normal loading.  Here's a new patch.

[v2-0001-Improvements-to-load-argument-handling.patch (text/plain, inline)]
From 38e48fb4bc3b6f949659d528fcaaa78d903be1db Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 21 Aug 2016 10:51:38 -0400
Subject: [PATCH v2] Improvements to --load argument handling

* lisp/startup.el (command-line-1): Search for files with load-suffixes
in default dir (Bug #17848).  Only pass normal files that were found,
since `load' doesn't handle directories (Bug #16406).
---
 lisp/startup.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index fcdc376..01e6d85 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2392,8 +2392,11 @@ command-line-1
                                    (or argval (pop command-line-args-left))))
                             ;; Take file from default dir if it exists there;
                             ;; otherwise let `load' search for it.
-                            (file-ex (expand-file-name file)))
-                       (when (file-exists-p file-ex)
+                            (file-ex (locate-file
+                                      file (list default-directory)
+                                      (append (get-load-suffixes)
+                                              load-file-rep-suffixes))))
+                       (when (and file-ex (file-regular-p file-ex))
                          (setq file file-ex))
                        (load file nil t)))
 
-- 
2.9.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 17:33:02 GMT) Full text and rfc822 format available.

Message #17 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 20:32:14 +0300
> From: npostavs <at> users.sourceforge.net
> Date: Sat, 03 Sep 2016 12:43:29 -0400
> Cc: 16406 <at> debbugs.gnu.org
> 
> > Seems simple enough to fix, here is a patch (this also covers #17848
> > "add suffix search to -l even when directory part in argument"):
> 
> That one broke normal loading.  Here's a new patch.

Instead of doing the search by hand, wouldn't it be better to teach
'load' to ignore directories?  Or do we have a use case where finding
a directory in 'load' would make sense?

IOW, isn't "'load' prefers directories" the actual problem we should
fix, rather than only fixing the startup problem?

I do agree that the file-exists-p test in command-line-1 should be
replaced with a test that doesn't let directories through.  But I
don't understand why using locate-file here is a good idea.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 18:44:01 GMT) Full text and rfc822 format available.

Message #20 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 14:43:53 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: npostavs <at> users.sourceforge.net
>> Date: Sat, 03 Sep 2016 12:43:29 -0400
>> Cc: 16406 <at> debbugs.gnu.org
>> 
>> > Seems simple enough to fix, here is a patch (this also covers #17848
>> > "add suffix search to -l even when directory part in argument"):
>> 
>> That one broke normal loading.  Here's a new patch.
>
> Instead of doing the search by hand, wouldn't it be better to teach
> 'load' to ignore directories?  Or do we have a use case where finding
> a directory in 'load' would make sense?
>
> IOW, isn't "'load' prefers directories" the actual problem we should
> fix, rather than only fixing the startup problem?
>
> I do agree that the file-exists-p test in command-line-1 should be
> replaced with a test that doesn't let directories through.  But I
> don't understand why using locate-file here is a good idea.

Hmm, I seem to have confused things by trying to combine the fix for
16406 and 17848.  Just replacing the file-exists-p test, as in the patch
below, is enough to fix this bug.  Let's look at 17848 separately.

[v3-0001-Don-t-load-directories.patch (text/plain, inline)]
From ba8ddc2e039fe982bdfa46519c003808be9ddff3 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 21 Aug 2016 10:51:38 -0400
Subject: [PATCH v3] Don't --load directories

* lisp/startup.el (command-line-1): Only pass expanded FILENAME argument
of --load when it refers to a normal file, since `load' doesn't handle
directories (Bug #16406).
---
 lisp/startup.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index fcdc376..45beefb 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2393,7 +2393,7 @@ command-line-1
                             ;; Take file from default dir if it exists there;
                             ;; otherwise let `load' search for it.
                             (file-ex (expand-file-name file)))
-                       (when (file-exists-p file-ex)
+                       (when (and file-ex (file-regular-p file-ex))
                          (setq file file-ex))
                        (load file nil t)))
 
-- 
2.9.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 19:01:02 GMT) Full text and rfc822 format available.

Message #23 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 22:00:42 +0300
> From: npostavs <at> users.sourceforge.net
> Cc: 16406 <at> debbugs.gnu.org,  rgm <at> gnu.org
> Date: Sat, 03 Sep 2016 14:43:53 -0400
> 
> > I do agree that the file-exists-p test in command-line-1 should be
> > replaced with a test that doesn't let directories through.  But I
> > don't understand why using locate-file here is a good idea.
> 
> Hmm, I seem to have confused things by trying to combine the fix for
> 16406 and 17848.  Just replacing the file-exists-p test, as in the patch
> below, is enough to fix this bug.  Let's look at 17848 separately.
> 
> >From ba8ddc2e039fe982bdfa46519c003808be9ddff3 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Sun, 21 Aug 2016 10:51:38 -0400
> Subject: [PATCH v3] Don't --load directories
> 
> * lisp/startup.el (command-line-1): Only pass expanded FILENAME argument
> of --load when it refers to a normal file, since `load' doesn't handle
> directories (Bug #16406).
> ---
>  lisp/startup.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/startup.el b/lisp/startup.el
> index fcdc376..45beefb 100644
> --- a/lisp/startup.el
> +++ b/lisp/startup.el
> @@ -2393,7 +2393,7 @@ command-line-1
>                              ;; Take file from default dir if it exists there;
>                              ;; otherwise let `load' search for it.
>                              (file-ex (expand-file-name file)))
> -                       (when (file-exists-p file-ex)
> +                       (when (and file-ex (file-regular-p file-ex))
>                           (setq file file-ex))
>                         (load file nil t)))

OK.  But isn't the "and file-ex" test unnecessary?  It wasn't required
for file-exists-p, so why is it for file-regular-p?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 19:13:02 GMT) Full text and rfc822 format available.

Message #26 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 15:12:49 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> 
>> Hmm, I seem to have confused things by trying to combine the fix for
>> 16406 and 17848.  Just replacing the file-exists-p test, as in the patch
>> below, is enough to fix this bug.  Let's look at 17848 separately.
>> 
>>                              (file-ex (expand-file-name file)))
>> -                       (when (file-exists-p file-ex)
>> +                       (when (and file-ex (file-regular-p file-ex))
>
> OK.  But isn't the "and file-ex" test unnecessary?  It wasn't required
> for file-exists-p, so why is it for file-regular-p?

Indeed, not required. It's just leftover confusion.

[v4-0001-Don-t-load-directories.patch (text/plain, inline)]
From 72ac37f50068af39aebc200b812cb901e0dcd176 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 21 Aug 2016 10:51:38 -0400
Subject: [PATCH v4] Don't --load directories

* lisp/startup.el (command-line-1): Only pass expanded FILENAME argument
of --load when it refers to a normal file, since `load' doesn't handle
directories (Bug #16406).
---
 lisp/startup.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index fcdc376..d5225bd 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2393,7 +2393,7 @@ command-line-1
                             ;; Take file from default dir if it exists there;
                             ;; otherwise let `load' search for it.
                             (file-ex (expand-file-name file)))
-                       (when (file-exists-p file-ex)
+                       (when (file-regular-p file-ex)
                          (setq file file-ex))
                        (load file nil t)))
 
-- 
2.9.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Sat, 03 Sep 2016 19:28:01 GMT) Full text and rfc822 format available.

Message #29 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Sat, 03 Sep 2016 22:27:03 +0300
> From: npostavs <at> users.sourceforge.net
> Cc: 16406 <at> debbugs.gnu.org,  rgm <at> gnu.org
> Date: Sat, 03 Sep 2016 15:12:49 -0400
> 
> > OK.  But isn't the "and file-ex" test unnecessary?  It wasn't required
> > for file-exists-p, so why is it for file-regular-p?
> 
> Indeed, not required. It's just leftover confusion.
> 
> >From 72ac37f50068af39aebc200b812cb901e0dcd176 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Sun, 21 Aug 2016 10:51:38 -0400
> Subject: [PATCH v4] Don't --load directories
> 
> * lisp/startup.el (command-line-1): Only pass expanded FILENAME argument
> of --load when it refers to a normal file, since `load' doesn't handle
> directories (Bug #16406).
> ---
>  lisp/startup.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/startup.el b/lisp/startup.el
> index fcdc376..d5225bd 100644
> --- a/lisp/startup.el
> +++ b/lisp/startup.el
> @@ -2393,7 +2393,7 @@ command-line-1
>                              ;; Take file from default dir if it exists there;
>                              ;; otherwise let `load' search for it.
>                              (file-ex (expand-file-name file)))
> -                       (when (file-exists-p file-ex)
> +                       (when (file-regular-p file-ex)
>                           (setq file file-ex))
>                         (load file nil t)))
>  
> -- 
> 2.9.3

Thanks, LGTM.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16406; Package emacs. (Wed, 07 Sep 2016 23:28:01 GMT) Full text and rfc822 format available.

Message #32 received at 16406 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rgm <at> gnu.org, 16406 <at> debbugs.gnu.org
Subject: Re: bug#16406: load prefers directories rather than searching
 load-path
Date: Wed, 07 Sep 2016 19:27:49 -0400
tags 16406 fixed
close 16406 25.2
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, LGTM.

Pushed as a08ce41e




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 07 Sep 2016 23:28:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 25.2, send any further explanations to 16406 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 07 Sep 2016 23:28:03 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. (Thu, 06 Oct 2016 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:04 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 26.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:04 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 25.2. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:04 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. (Sun, 01 Jan 2017 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 172 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.