GNU bug report logs - #16087
Setting HOME environment variable in Emacs on Windows has side effects

Previous Next

Package: emacs;

Reported by: SDS <sds.biz.main <at> gmail.com>

Date: Sun, 8 Dec 2013 07:12:02 UTC

Severity: minor

Tags: wontfix

Found in version 24.3.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 16087 in the body.
You can then email your comments to 16087 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#16087; Package emacs. (Sun, 08 Dec 2013 07:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to SDS <sds.biz.main <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 08 Dec 2013 07:12:03 GMT) Full text and rfc822 format available.

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

From: SDS <sds.biz.main <at> gmail.com>
To: submit <at> debbugs.gnu.org
Subject: Setting HOME environment variable in Emacs on Windows has side effects
Date: Sat, 07 Dec 2013 15:45:01 -0500
Package: emacs
Version: 24.3.1

When running "emacs.exe -Q" for precompiled Emacs binaries on Windows, 
and after setting the HOME environment variable to a path different than 
the registry's HKCU\SOFTWARE\GNU\Emacs\HOME, attempting to access the 
old HOME directory returns the new HOME directory.

The steps to reproduce the bug are as follows:
1) Set the registry key "HKCU\SOFTWARE\GNU\Emacs\HOME" to "C:\Old\Home"
2) Run "emacs.exe -Q"
3) In a scratch buffer, evaluate "(setenv "HOME" "C:/New/Home")"
4) Using Dired (C-x d), open "C:\Old\Home"
5) The directory in the new Dired buffer is "C:\New\Home"


Cheers,

SDS




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16087; Package emacs. (Sun, 08 Dec 2013 17:40:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: SDS <sds.biz.main <at> gmail.com>
Cc: 16087 <at> debbugs.gnu.org
Subject: Re: bug#16087: Setting HOME environment variable in Emacs on Windows
 has	side effects
Date: Sun, 08 Dec 2013 19:38:41 +0200
> Date: Sat, 07 Dec 2013 15:45:01 -0500
> From: SDS <sds.biz.main <at> gmail.com>
> 
> When running "emacs.exe -Q" for precompiled Emacs binaries on Windows, 
> and after setting the HOME environment variable to a path different than 
> the registry's HKCU\SOFTWARE\GNU\Emacs\HOME, attempting to access the 
> old HOME directory returns the new HOME directory.

This is in no way specific to Windows.  I tried similar steps on
GNU/Linux, and saw very similar signs of trouble.  Of course, there's
no registry on Unix, but it is enough to start with step #2.

> The steps to reproduce the bug are as follows:
> 1) Set the registry key "HKCU\SOFTWARE\GNU\Emacs\HOME" to "C:\Old\Home"
> 2) Run "emacs.exe -Q"
> 3) In a scratch buffer, evaluate "(setenv "HOME" "C:/New/Home")"
> 4) Using Dired (C-x d), open "C:\Old\Home"
> 5) The directory in the new Dired buffer is "C:\New\Home"

FWIW, I wouldn't expect this to work.  Every buffer has its default
directory stored as a string in its buffer object.  If you change
where the home directory points to, most, if not all, of these
directories will become invalid, because their expansions, which
always go through "~" if possible, will not exist, except by chance.
And Emacs uses the default directories of the buffers freely when it
manipulates file names.

OTOH, the use case for supporting such a strange change in the middle
of an Emacs session is entirely not clear to me.  On the contrary, it
seems to me like doing this is asking for a lot of trouble, and not
only in Emacs (because 'setenv' modifies process-environment, so every
subprocess will get this new value of HOME, so, e.g., the shell will
not find its init files). Could you please describe why you needed
this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16087; Package emacs. (Sun, 08 Dec 2013 19:46:02 GMT) Full text and rfc822 format available.

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

From: SDS <sds.biz.main <at> gmail.com>
To: eliz <at> gnu.org
Cc: 16087 <at> debbugs.gnu.org
Subject: Re: Re: bug#16087: Setting HOME environment variable in Emacs on
 Windows has side effects
Date: Sun, 08 Dec 2013 14:44:55 -0500
On 12/8/2013 12:38 PM, Eli Zaretskii wrote:
> OTOH, the use case for supporting such a strange change in the middle
> of an Emacs session is entirely not clear to me.  On the contrary, it
> seems to me like doing this is asking for a lot of trouble, and not
> only in Emacs (because 'setenv' modifies process-environment, so every
> subprocess will get this new value of HOME, so, e.g., the shell will
> not find its init files). Could you please describe why you needed
> this?

On Windows, I have two versions of Emacs running: a Cygwin port 
(Emacs-w32) and a GNU port (NT-Emacs). I was originally using Emacs-w32 
because it supports some Cygwin utilities that aren't supported by 
NT-Emacs (e.g. Cygwin bash, Cygwin OpenSSH). However, Cygwin's port was 
aborting frequently. The Cygwin Emacs maintainer said it was another 
application interfering, but I had removed all that I had installed from 
their list of such applications (BLODA) and it hadn't fixed the 
aborting. I didn't have the time to debug the issue any further, so I 
decided to switch workflow to NT-Emacs until I could fix Emacs-w32.

At the moment, I have two separate .emacs.d directories for each of the 
two ports. I didn't want to use a single .emacs.d directory for both 
ports because I'm not sure if they would play nicely with each other. I 
also don't want issues with one to be carried over to the other. So I 
have my HKCU\SOFTWARE\GNU\Emacs\HOME registry key pointing to a 
directory with the .emacs.d for NT-Emacs, while my .emacs.d for 
Emacs-w32 is in my Cygwin HOME directory.

Ultimately, I'd like my HOME variable in NT-Emacs to point to the Cygwin 
HOME directory. This allows any Cygwin utilities used by NT-Emacs to 
have HOME set correctly. Also, I'd like ~ to be set to the Cygwin HOME 
directory. I tried changing it in init.el, and that's where this issue 
arose.


Cheers,

SDS




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16087; Package emacs. (Sun, 08 Dec 2013 20:10:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: SDS <sds.biz.main <at> gmail.com>
Cc: 16087 <at> debbugs.gnu.org
Subject: Re: bug#16087: Setting HOME environment variable in Emacs on Windows
 has side effects
Date: Sun, 08 Dec 2013 22:09:19 +0200
> Date: Sun, 08 Dec 2013 14:44:55 -0500
> From: SDS <sds.biz.main <at> gmail.com>
> CC: 16087 <at> debbugs.gnu.org
> 
> Ultimately, I'd like my HOME variable in NT-Emacs to point to the Cygwin 
> HOME directory. This allows any Cygwin utilities used by NT-Emacs to 
> have HOME set correctly. Also, I'd like ~ to be set to the Cygwin HOME 
> directory. I tried changing it in init.el, and that's where this issue 
> arose.

Thanks.  So this sounds like a one-time issue, which, once solved to
your satisfaction, should never pop up again, right?

As for setting this up, my suggestion would be to set HOME in the
environment to point to the Cygwin's HOME, and augment that by
whatever you need in the Bash init files.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16087; Package emacs. (Sun, 08 Dec 2013 21:15:02 GMT) Full text and rfc822 format available.

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

From: SDS <sds.biz.main <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 16087 <at> debbugs.gnu.org
Subject: Re: bug#16087: Setting HOME environment variable in Emacs on Windows
 has side effects
Date: Sun, 08 Dec 2013 16:14:11 -0500

On 12/8/2013 3:09 PM, Eli Zaretskii wrote:
> Thanks.  So this sounds like a one-time issue, which, once solved to
> your satisfaction, should never pop up again, right?

A workaround which directly or indirectly prevents this from happening 
is fine. It hasn't even really been an issue unless I'm trying to access 
files within the directory containing the .emacs.d for NT-Emacs. I 
noticed it when I tried to open .emacs.d/init.el for NT-Emacs and it 
opened the init.el for Emacs-w32 instead.

I could isolate the .emacs.d for NT-Emacs inside its own directory, and 
point to that in HKCU\SOFTWARE\GNU\Emacs\HOME before changing HOME in 
init.el. That way it's only a problem when trying to edit the init.el 
for NT-Emacs, which I could workaround by invoking NT-Emacs with --no-init.

I just wasn't sure if there were any other apparent side effects to 
changing the HOME directory in the init.el file. I figured out already 
that doing so requires changing HOME at the end of init.el, and setting 
some directory variables to the full path pointing to .emacs.d for 
NT-Emacs. I also wasn't sure if a better/simpler workaround existed.

> As for setting this up, my suggestion would be to set HOME in the
> environment to point to the Cygwin's HOME, and augment that by
> whatever you need in the Bash init files.

Won't that require merging the .emacs.d directories for the two ports? 
Is there a way of doing this without having them interfere with each other?


Cheers,

SDS




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16087; Package emacs. (Mon, 09 Dec 2013 03:44:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: SDS <sds.biz.main <at> gmail.com>
Cc: 16087 <at> debbugs.gnu.org
Subject: Re: bug#16087: Setting HOME environment variable in Emacs on Windows
 has side effects
Date: Mon, 09 Dec 2013 05:43:13 +0200
> Date: Sun, 08 Dec 2013 16:14:11 -0500
> From: SDS <sds.biz.main <at> gmail.com>
> CC: 16087 <at> debbugs.gnu.org
> 
> > Thanks.  So this sounds like a one-time issue, which, once solved to
> > your satisfaction, should never pop up again, right?
> 
> A workaround which directly or indirectly prevents this from happening 
> is fine. It hasn't even really been an issue unless I'm trying to access 
> files within the directory containing the .emacs.d for NT-Emacs. I 
> noticed it when I tried to open .emacs.d/init.el for NT-Emacs and it 
> opened the init.el for Emacs-w32 instead.
> 
> I could isolate the .emacs.d for NT-Emacs inside its own directory, and 
> point to that in HKCU\SOFTWARE\GNU\Emacs\HOME before changing HOME in 
> init.el. That way it's only a problem when trying to edit the init.el 
> for NT-Emacs, which I could workaround by invoking NT-Emacs with --no-init.

I don't understand why you need to use HOME or the Registry to access
any directory on your system.  Each one of them has its own unique
absolute file name, doesn't it?  Just use that.  What am I missing?

> > As for setting this up, my suggestion would be to set HOME in the
> > environment to point to the Cygwin's HOME, and augment that by
> > whatever you need in the Bash init files.
> 
> Won't that require merging the .emacs.d directories for the two ports? 
> Is there a way of doing this without having them interfere with each other?

Depends on what you have in that directory.  In general, I see no
reasons why two builds couldn't use the same .emacs.d.  Which parts do
you think will cause trouble?




Added tag(s) wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 10 Dec 2013 17:14:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 16087 <at> debbugs.gnu.org and SDS <sds.biz.main <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 01 Feb 2014 07:34: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. (Sat, 01 Mar 2014 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 164 days ago.

Previous Next


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