unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
@ 2013-12-07 20:45 SDS
  2013-12-08 17:38 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: SDS @ 2013-12-07 20:45 UTC (permalink / raw)
  To: 16087

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





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

* bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
  2013-12-07 20:45 bug#16087: Setting HOME environment variable in Emacs on Windows has side effects SDS
@ 2013-12-08 17:38 ` Eli Zaretskii
  2013-12-08 19:44   ` bug#16087: " SDS
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2013-12-08 17:38 UTC (permalink / raw)
  To: SDS; +Cc: 16087

> Date: Sat, 07 Dec 2013 15:45:01 -0500
> From: SDS <sds.biz.main@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?





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

* bug#16087: Re: bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
  2013-12-08 17:38 ` Eli Zaretskii
@ 2013-12-08 19:44   ` SDS
  2013-12-08 20:09     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: SDS @ 2013-12-08 19:44 UTC (permalink / raw)
  To: eliz; +Cc: 16087

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





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

* bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
  2013-12-08 19:44   ` bug#16087: " SDS
@ 2013-12-08 20:09     ` Eli Zaretskii
  2013-12-08 21:14       ` SDS
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2013-12-08 20:09 UTC (permalink / raw)
  To: SDS; +Cc: 16087

> Date: Sun, 08 Dec 2013 14:44:55 -0500
> From: SDS <sds.biz.main@gmail.com>
> CC: 16087@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.





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

* bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
  2013-12-08 20:09     ` Eli Zaretskii
@ 2013-12-08 21:14       ` SDS
  2013-12-09  3:43         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: SDS @ 2013-12-08 21:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 16087



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





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

* bug#16087: Setting HOME environment variable in Emacs on Windows has side effects
  2013-12-08 21:14       ` SDS
@ 2013-12-09  3:43         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2013-12-09  3:43 UTC (permalink / raw)
  To: SDS; +Cc: 16087

> Date: Sun, 08 Dec 2013 16:14:11 -0500
> From: SDS <sds.biz.main@gmail.com>
> CC: 16087@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?





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

end of thread, other threads:[~2013-12-09  3:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07 20:45 bug#16087: Setting HOME environment variable in Emacs on Windows has side effects SDS
2013-12-08 17:38 ` Eli Zaretskii
2013-12-08 19:44   ` bug#16087: " SDS
2013-12-08 20:09     ` Eli Zaretskii
2013-12-08 21:14       ` SDS
2013-12-09  3:43         ` Eli Zaretskii

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