unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
@ 2013-03-12  1:35 Robert Prije
  2013-03-12  3:43 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Prije @ 2013-03-12  1:35 UTC (permalink / raw)
  To: 13930

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

If emacs can't reach or create .emacs.d it gets into a sort of half-loaded
state.

Here's an example of how this causes problems for me:

I often have processes spawn emacs for me using sudo.

My home directory has 700 permissions and exists on a root-squashed NFS
share. Consequently root can't reach it.

As a result, whenever I run sudo emacs on a file, it throws the error:

"Creating directory: Permission denied, /home/rprije/.emacs.d/"

in my minibuffer. It fails to load my file and I have to do C-x C-f on the
file to open it manually. If it's a temporarily created file, it often
loses the file completely and I can't regain it.

I'd have expected running with -Q or -q would help but it sadly makes no
difference.

$ emacs --version
GNU Emacs 23.2.1

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

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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12  1:35 bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d Robert Prije
@ 2013-03-12  3:43 ` Stefan Monnier
  2013-03-12  3:52   ` Robert Prije
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2013-03-12  3:43 UTC (permalink / raw)
  To: Robert Prije; +Cc: 13930

> As a result, whenever I run sudo emacs on a file, it throws the error:
> "Creating directory: Permission denied, /home/rprije/.emacs.d/"

Can you run with --debug-init to hopefully get a backtrace showing in
which context this error is signaled?


        Stefan





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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12  3:43 ` Stefan Monnier
@ 2013-03-12  3:52   ` Robert Prije
  2013-03-12  5:11     ` Stefan Monnier
  2013-03-12 16:10     ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Robert Prije @ 2013-03-12  3:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13930

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

It does exactly the same thing with --debug-init (says "creating directory:
permission denied...") and supplies no further information.

I think --debug-init is for debugging an init file, right? It's not getting
as far as loading the init file so it won't be able to debug it.



On Tue, Mar 12, 2013 at 11:43 AM, Stefan Monnier
<monnier@iro.umontreal.ca>wrote:

> > As a result, whenever I run sudo emacs on a file, it throws the error:
> > "Creating directory: Permission denied, /home/rprije/.emacs.d/"
>
> Can you run with --debug-init to hopefully get a backtrace showing in
> which context this error is signaled?
>
>
>         Stefan
>

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

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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12  3:52   ` Robert Prije
@ 2013-03-12  5:11     ` Stefan Monnier
  2013-03-12  9:01       ` Robert Prije
  2013-03-12 16:10     ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2013-03-12  5:11 UTC (permalink / raw)
  To: Robert Prije; +Cc: 13930

> It does exactly the same thing with --debug-init (says "creating directory:
> permission denied...") and supplies no further information.
> I think --debug-init is for debugging an init file, right?  It's not getting
> as far as loading the init file so it won't be able to debug it.

Can you try it with a more recent Emacs?  E.g. 24.2 or 24.3?
I remember we fixed some bugs at some point that caused creation of
.emacs.d before there's a real need for it.


        Stefan





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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12  5:11     ` Stefan Monnier
@ 2013-03-12  9:01       ` Robert Prije
  0 siblings, 0 replies; 13+ messages in thread
From: Robert Prije @ 2013-03-12  9:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13930

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

I built and reproduced the same problem with:

$ ./src/emacs --version
GNU Emacs 24.2.1



On Tue, Mar 12, 2013 at 1:11 PM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > It does exactly the same thing with --debug-init (says "creating
> directory:
> > permission denied...") and supplies no further information.
> > I think --debug-init is for debugging an init file, right?  It's not
> getting
> > as far as loading the init file so it won't be able to debug it.
>
> Can you try it with a more recent Emacs?  E.g. 24.2 or 24.3?
> I remember we fixed some bugs at some point that caused creation of
> .emacs.d before there's a real need for it.
>
>
>         Stefan
>

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

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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12  3:52   ` Robert Prije
  2013-03-12  5:11     ` Stefan Monnier
@ 2013-03-12 16:10     ` Eli Zaretskii
  2013-03-12 16:29       ` Glenn Morris
  2013-03-12 16:32       ` Sven Joachim
  1 sibling, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2013-03-12 16:10 UTC (permalink / raw)
  To: Robert Prije; +Cc: 13930

> Date: Tue, 12 Mar 2013 11:52:08 +0800
> From: Robert Prije <rprije@janestreet.com>
> Cc: 13930@debbugs.gnu.org
> 
> It does exactly the same thing with --debug-init (says "creating directory:
> permission denied...") and supplies no further information.

How about running it under GDB with a breakpoint on report_file_error
and on xsignal?  If you start GDB from the src directory of the Emacs
sources, the .gdbinit file there defines a command xbacktrace which
will produce a Lisp-level backtrace in addition to the C-level
backtrace produced by the "bt" command of GDB.






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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12 16:10     ` Eli Zaretskii
@ 2013-03-12 16:29       ` Glenn Morris
  2013-03-12 16:48         ` Eli Zaretskii
  2013-03-12 16:32       ` Sven Joachim
  1 sibling, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2013-03-12 16:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Prije, 13930

Eli Zaretskii wrote:

>> It does exactly the same thing with --debug-init (says "creating directory:
>> permission denied...") and supplies no further information.
>
> How about running it under GDB with a breakpoint on report_file_error
> and on xsignal?  If you start GDB from the src directory of the Emacs
> sources, the .gdbinit file there defines a command xbacktrace which
> will produce a Lisp-level backtrace in addition to the C-level
> backtrace produced by the "bt" command of GDB.

Why do we need to jump through such hoops, when locate-user-emacs-file,
which Stefan has just added all over the place, says:

  Else return NEW-NAME in `user-emacs-directory', creating the
  directory if it does not exist.





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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12 16:10     ` Eli Zaretskii
  2013-03-12 16:29       ` Glenn Morris
@ 2013-03-12 16:32       ` Sven Joachim
  2013-05-12 23:33         ` Robert Prije
  1 sibling, 1 reply; 13+ messages in thread
From: Sven Joachim @ 2013-03-12 16:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Prije, 13930

On 2013-03-12 17:10 +0100, Eli Zaretskii wrote:

>> Date: Tue, 12 Mar 2013 11:52:08 +0800
>> From: Robert Prije <rprije@janestreet.com>
>> Cc: 13930@debbugs.gnu.org
>> 
>> It does exactly the same thing with --debug-init (says "creating directory:
>> permission denied...") and supplies no further information.

FWIW, this can be reproduced by creating ~/.emacs.d as a file rather
than a directory:

touch /tmp/.emacs.d
HOME=/tmp emacs --no-init-file

Than the error is "File exists: /tmp/.emacs.d/".

> How about running it under GDB with a breakpoint on report_file_error
> and on xsignal?  If you start GDB from the src directory of the Emacs
> sources, the .gdbinit file there defines a command xbacktrace which
> will produce a Lisp-level backtrace in addition to the C-level
> backtrace produced by the "bt" command of GDB.

Done that and found out that locate-user-emacs-file tries to create the
directory:

,----
| (gdb) xbacktrace
| "make-directory-internal" (0xffffca98)
| "make-directory" (0xffffcc1c)
| "locate-user-emacs-file" (0xffffcd98)
| 0x82d3208 PVEC_COMPILED
| "funcall" (0xffffcf10)
| "eval" (0xffffd080)
| "custom-reevaluate-setting" (0xffffd1fc)
| "mapc" (0xffffd308)
| "command-line" (0xffffd4bc)
| "normal-top-level" (0xffffd5d0)
| (gdb)
`----

Cheers,
       Sven





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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12 16:29       ` Glenn Morris
@ 2013-03-12 16:48         ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2013-03-12 16:48 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rprije, 13930

> From: Glenn Morris <rgm@gnu.org>
> Cc: Robert Prije <rprije@janestreet.com>,  13930@debbugs.gnu.org
> Date: Tue, 12 Mar 2013 12:29:23 -0400
> 
> Eli Zaretskii wrote:
> 
> >> It does exactly the same thing with --debug-init (says "creating directory:
> >> permission denied...") and supplies no further information.
> >
> > How about running it under GDB with a breakpoint on report_file_error
> > and on xsignal?  If you start GDB from the src directory of the Emacs
> > sources, the .gdbinit file there defines a command xbacktrace which
> > will produce a Lisp-level backtrace in addition to the C-level
> > backtrace produced by the "bt" command of GDB.
> 
> Why do we need to jump through such hoops, when locate-user-emacs-file,
> which Stefan has just added all over the place, says:
> 
>   Else return NEW-NAME in `user-emacs-directory', creating the
>   directory if it does not exist.

If you mean that remembering this was all you needed to deduce that
locate-user-emacs-file is the culprit, then good for you.  I never
remember such details (and this one I think I never knew about in the
first place).  A debugger will show the truth even if the problem is
in some other place, so it is (IMO) a more efficient way of finding
the root cause.

IOW, more often than not I find that "jumping through hoops" is the
shortest and most reliable way to solution.





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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-03-12 16:32       ` Sven Joachim
@ 2013-05-12 23:33         ` Robert Prije
  2013-05-14  7:30           ` Glenn Morris
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Prije @ 2013-05-12 23:33 UTC (permalink / raw)
  To: Sven Joachim; +Cc: 13930

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

Hi, just checking what the status of this bug is?

Thanks.


On Wed, Mar 13, 2013 at 12:32 AM, Sven Joachim <svenjoac@gmx.de> wrote:

> On 2013-03-12 17:10 +0100, Eli Zaretskii wrote:
>
> >> Date: Tue, 12 Mar 2013 11:52:08 +0800
> >> From: Robert Prije <rprije@janestreet.com>
> >> Cc: 13930@debbugs.gnu.org
> >>
> >> It does exactly the same thing with --debug-init (says "creating
> directory:
> >> permission denied...") and supplies no further information.
>
> FWIW, this can be reproduced by creating ~/.emacs.d as a file rather
> than a directory:
>
> touch /tmp/.emacs.d
> HOME=/tmp emacs --no-init-file
>
> Than the error is "File exists: /tmp/.emacs.d/".
>
> > How about running it under GDB with a breakpoint on report_file_error
> > and on xsignal?  If you start GDB from the src directory of the Emacs
> > sources, the .gdbinit file there defines a command xbacktrace which
> > will produce a Lisp-level backtrace in addition to the C-level
> > backtrace produced by the "bt" command of GDB.
>
> Done that and found out that locate-user-emacs-file tries to create the
> directory:
>
> ,----
> | (gdb) xbacktrace
> | "make-directory-internal" (0xffffca98)
> | "make-directory" (0xffffcc1c)
> | "locate-user-emacs-file" (0xffffcd98)
> | 0x82d3208 PVEC_COMPILED
> | "funcall" (0xffffcf10)
> | "eval" (0xffffd080)
> | "custom-reevaluate-setting" (0xffffd1fc)
> | "mapc" (0xffffd308)
> | "command-line" (0xffffd4bc)
> | "normal-top-level" (0xffffd5d0)
> | (gdb)
> `----
>
> Cheers,
>        Sven
>

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

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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-05-12 23:33         ` Robert Prije
@ 2013-05-14  7:30           ` Glenn Morris
  2013-05-14  8:46             ` Robert Prije
  0 siblings, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2013-05-14  7:30 UTC (permalink / raw)
  To: Robert Prije; +Cc: 13930


Does this patch work for you?

*** lisp/subr.el	2013-04-27 21:12:17 +0000
--- lisp/subr.el	2013-05-14 07:27:31 +0000
***************
*** 2643,2648 ****
--- 2643,2655 ----
  Note that this should end with a directory separator.
  See also `locate-user-emacs-file'.")
  
+ (custom-declare-variable-early 'user-emacs-directory-warning t
+   "Non-nil means warn if cannot access `user-emacs-directory'.
+ Set this to nil at your own risk..."
+   :type 'boolean
+   :group 'initialization
+   :version "24.4")
+ 
  (defun locate-user-emacs-file (new-name &optional old-name)
    "Return an absolute per-user Emacs-specific file name.
  If NEW-NAME exists in `user-emacs-directory', return it.
***************
*** 2658,2674 ****
                (file-readable-p at-home))
  	 at-home
         ;; Make sure `user-emacs-directory' exists,
!        ;; unless we're in batch mode or dumping Emacs
         (or noninteractive
  	   purify-flag
! 	   (file-accessible-directory-p
! 	    (directory-file-name user-emacs-directory))
  	   (let ((umask (default-file-modes)))
  	     (unwind-protect
  		 (progn
  		   (set-default-file-modes ?\700)
! 		   (make-directory user-emacs-directory))
  	       (set-default-file-modes umask))))
         bestname))))
  \f
  ;;;; Misc. useful functions.
--- 2665,2697 ----
                (file-readable-p at-home))
  	 at-home
         ;; Make sure `user-emacs-directory' exists,
!        ;; unless we're in batch mode or dumping Emacs.
         (or noninteractive
  	   purify-flag
! 	   (let (errtype)
! 	     (if (file-directory-p user-emacs-directory)
! 		 (or (file-accessible-directory-p user-emacs-directory)
! 		     (setq errtype "access"))
  	       (let ((umask (default-file-modes)))
  		 (unwind-protect
  		     (progn
  		       (set-default-file-modes ?\700)
! 		       (condition-case nil
! 			   (make-directory user-emacs-directory)
! 			 (error (setq errtype "create"))))
  		   (set-default-file-modes umask))))
+ 	     (when (and errtype
+ 			user-emacs-directory-warning
+ 			(not (get 'user-emacs-directory-warning 'this-session)))
+ 	       ;; Only warn once per Emacs session.
+ 	       (put 'user-emacs-directory-warning 'this-session t)
+ 	       (display-warning 'initialization
+ 				(format "\
+ Unable to %s `user-emacs-directory' (%s).
+ Any data that would normally be written there may be lost!
+ If you never want to see this message again,
+ customize the variable `user-emacs-directory-warning'."
+ 					errtype user-emacs-directory)))))
         bestname))))
  \f
  ;;;; Misc. useful functions.






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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-05-14  7:30           ` Glenn Morris
@ 2013-05-14  8:46             ` Robert Prije
  2013-05-14 16:01               ` Glenn Morris
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Prije @ 2013-05-14  8:46 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13930

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

This is much better. I now get a separate window with the following error:

"Warning (initialization): Unable to create `user-emacs-directory'
(~/.emacs.d/).
Any data that would normally be written there may be lost!
If you never want to see this message again,
customize the variable `user-emacs-directory-warning'."

but the file I attempt to open still opens and I can edit it as usual. It
appears the patch works as intended. Which release is it likely to make it
to?

Thanks a bunch Glenn.



On Tue, May 14, 2013 at 3:30 PM, Glenn Morris <rgm@gnu.org> wrote:

>
> Does this patch work for you?
>
> *** lisp/subr.el        2013-04-27 21:12:17 +0000
> --- lisp/subr.el        2013-05-14 07:27:31 +0000
> ***************
> *** 2643,2648 ****
> --- 2643,2655 ----
>   Note that this should end with a directory separator.
>   See also `locate-user-emacs-file'.")
>
> + (custom-declare-variable-early 'user-emacs-directory-warning t
> +   "Non-nil means warn if cannot access `user-emacs-directory'.
> + Set this to nil at your own risk..."
> +   :type 'boolean
> +   :group 'initialization
> +   :version "24.4")
> +
>   (defun locate-user-emacs-file (new-name &optional old-name)
>     "Return an absolute per-user Emacs-specific file name.
>   If NEW-NAME exists in `user-emacs-directory', return it.
> ***************
> *** 2658,2674 ****
>                 (file-readable-p at-home))
>          at-home
>          ;; Make sure `user-emacs-directory' exists,
> !        ;; unless we're in batch mode or dumping Emacs
>          (or noninteractive
>            purify-flag
> !          (file-accessible-directory-p
> !           (directory-file-name user-emacs-directory))
>            (let ((umask (default-file-modes)))
>              (unwind-protect
>                  (progn
>                    (set-default-file-modes ?\700)
> !                  (make-directory user-emacs-directory))
>                (set-default-file-modes umask))))
>          bestname))))
>
>   ;;;; Misc. useful functions.
> --- 2665,2697 ----
>                 (file-readable-p at-home))
>          at-home
>          ;; Make sure `user-emacs-directory' exists,
> !        ;; unless we're in batch mode or dumping Emacs.
>          (or noninteractive
>            purify-flag
> !          (let (errtype)
> !            (if (file-directory-p user-emacs-directory)
> !                (or (file-accessible-directory-p user-emacs-directory)
> !                    (setq errtype "access"))
>                (let ((umask (default-file-modes)))
>                  (unwind-protect
>                      (progn
>                        (set-default-file-modes ?\700)
> !                      (condition-case nil
> !                          (make-directory user-emacs-directory)
> !                        (error (setq errtype "create"))))
>                    (set-default-file-modes umask))))
> +            (when (and errtype
> +                       user-emacs-directory-warning
> +                       (not (get 'user-emacs-directory-warning
> 'this-session)))
> +              ;; Only warn once per Emacs session.
> +              (put 'user-emacs-directory-warning 'this-session t)
> +              (display-warning 'initialization
> +                               (format "\
> + Unable to %s `user-emacs-directory' (%s).
> + Any data that would normally be written there may be lost!
> + If you never want to see this message again,
> + customize the variable `user-emacs-directory-warning'."
> +                                       errtype user-emacs-directory)))))
>          bestname))))
>
>   ;;;; Misc. useful functions.
>
>

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

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

* bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d
  2013-05-14  8:46             ` Robert Prije
@ 2013-05-14 16:01               ` Glenn Morris
  0 siblings, 0 replies; 13+ messages in thread
From: Glenn Morris @ 2013-05-14 16:01 UTC (permalink / raw)
  To: 13930-done

Version: 24.4

Thanks for testing, applied to trunk. Barring unexpected, should be in 24.4.





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

end of thread, other threads:[~2013-05-14 16:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12  1:35 bug#13930: Emacs doesn't cope well if it can't access/create .emacs.d Robert Prije
2013-03-12  3:43 ` Stefan Monnier
2013-03-12  3:52   ` Robert Prije
2013-03-12  5:11     ` Stefan Monnier
2013-03-12  9:01       ` Robert Prije
2013-03-12 16:10     ` Eli Zaretskii
2013-03-12 16:29       ` Glenn Morris
2013-03-12 16:48         ` Eli Zaretskii
2013-03-12 16:32       ` Sven Joachim
2013-05-12 23:33         ` Robert Prije
2013-05-14  7:30           ` Glenn Morris
2013-05-14  8:46             ` Robert Prije
2013-05-14 16:01               ` Glenn Morris

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).