Msysgit and $HOME

83 views
Skip to first unread message

Robert Ewald

unread,
Jan 5, 2016, 4:57:40 AM1/5/16
to Git for Windows
Hi,

Using msysgit portable version 2.6.3.windows.1 I get a strange issue with my home directory.

I changed /etc/profile.d/env.sh to adjust $HOME to point to my portable home directory, relative to the $BASH_SOURCE of env.sh.

This works and echo $HOME shows the expected file name for different machines where I plug my thumb-drive in. However, programs like ssh ignore this setting when starting.

Example:

$ echo $HOME
/c/Portable/Home

$ ssh -v example.com
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /h/.ssh/config

As you can see .ssh/config is loaded from /h which is my $Homedrive/$Homepath and not $HOME.

However when I set %HOME (in a windows .bat file or by other means) before starting bash via git-bash.exe or bin/bash.exe everything is well.
The understanding came when reading this email: https://cygwin.com/ml/cygwin-patches/2015-q3/msg00025.html

I am not sure if you would consider this behavior a bug. This is only a problem for the portable version, where I expect $HOME and the ssh configuration to travel along with me on my thumb-drive.

Thanks for reading.

Robert

Johannes Schindelin

unread,
Jan 5, 2016, 9:30:10 AM1/5/16
to Robert Ewald, Git for Windows, git-for...@googlegroups.com
Hi Robert,

On Tue, 5 Jan 2016, Robert Ewald wrote:

> Using msysgit portable version 2.6.3.windows.1 I get a strange issue
> with my home directory.

There is no msysgit 2.6.3... To begin with, msysgit was the
contributor-facing side of Git for Windows 1.x.

Besides, msysgit is retired, now that we have 2.x. Likewise, the entire
msysgit "franchise" was retired, including the msysgit mailing list.

I took the liberty of Cc:ing the correct mailing list.

> I changed /etc/profile.d/env.sh to adjust $HOME to point to my portable
> home directory, relative to the $BASH_SOURCE of env.sh.
>
> This works and echo $HOME shows the expected file name for different
> machines where I plug my thumb-drive in. However, programs like ssh ignore
> this setting when starting.

Correct. ssh uses as home directory what MSys2 thinks is the home
directory, and MSys2 starts up *before* its Bash can source env.sh. It's
really a Catch-22.

> Example:
>
> $ echo $HOME
> /c/Portable/Home
>
> $ ssh -v example.com
> OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
> debug1: Reading configuration data /h/.ssh/config
>
> As you can see .ssh/config is loaded from /h which is my
> $Homedrive/$Homepath and not $HOME.
>
> However when I set %HOME (in a windows .bat file or by other means) before
> starting bash via git-bash.exe or bin/bash.exe everything is well.
> The understanding came when reading this email:
> https://cygwin.com/ml/cygwin-patches/2015-q3/msg00025.html
>
> I am not sure if you would consider this behavior a bug. This is only a
> problem for the portable version, where I expect $HOME and the ssh
> configuration to travel along with me on my thumb-drive.

It cannot really be a bug because you cannot change the HOME directory
after MSys2 spins up.

To support this use case, you need to change the /etc/nsswitch.conf file
in accordance to https://cygwin.com/cygwin-ug-net/ntsec.html. In your
case, I think you will want to set

db_home: /Home

Ciao,
Johannes
Reply all
Reply to author
Forward
0 new messages