Menu

#98 HOME environment variable not honoured in user directory in passwd

1.0
closed
Alexx83
None
2015-02-18
2014-10-14
Ed
No

STR:
1) Define an env variable "HOME" to have the value "C:\Users\Username" (adjust for your username)
2) Clean install http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20141003.exe/download - choosing default options throughout
3) Open msys2_shell.bat
4) Perform "cd ~"

Expected:
Command succeeds.

Actual:
$ cd ~
bash: cd: /home/Ed: No such file or directory

And yet:
$ pwd -W
C:/Users/Ed
$ grep 'Ed' /etc/passwd | cut -d ':' -f 6
/home/Ed

Appears that install/first run didn't set the user up correctly?

Discussion

  • Ed

    Ed - 2014-10-14

    Seems like perhaps this was the cause of http://sourceforge.net/p/msys2/tickets/7/#b1d5 too?

     
  • Ugabade

    Ugabade - 2014-10-25

    I am using that same version and do not have that issue, my home is somewhere else and MSYS2 is detecting it properly.

     
  • Ugabade

    Ugabade - 2014-10-26

    Check if your MSYSTEM exists and its value.

     
  • Ed

    Ed - 2014-10-28

    MSYSTEM was being set to "MSYS" by msys2_shell.bat

    Adding this line to fstab fixes my problem:
    c:/Users/Ed /home/Ed ntfs binary,posix=0,user 0 0

    So it seems like for cases where someone has set a custom value for HOME, the mount isn't being set up properly, and the user has to add a line manually to fstab.

    Therefore we either need to fix the auto-mounting (to avoid needing to adjust fstab), or else make the installer/first-run add the line to fstab.

    If that is WONTFIX (and even if it isn't, for the short term to reduce confusion), it would be helpful to mention needing to adjust fstab on http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/ or other documentation.

     
  • Ed

    Ed - 2014-10-28

    Could someone adjust this ticket title (since I don't seem to have permissions) to something like:
    "Using custom HOME location requires undocumented changes to fstab"

     
  • Ed

    Ed - 2014-10-28

    More complete STR to replace those in the bug report:

    1) Uninstall the existing MSYS2 installation
    2) Verify that C:\msys64 is removed
    3) Rename existing MSYS1 directory to something random
    4) Using cmd.exe
      C:\Users\Ed>echo %PATH%
    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Python27\;C:\Program Files (x86)\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files\TortoiseHg\;C:\Vagrant\bin;C:\Users\Ed\AppData\Roaming\npm
      C:\Users\Ed>echo %HOME%
    C:\Users\Ed
    5) Download http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20141003.exe/download
    6) Run installer and choose default options (installs into C:\msys64)
    7) After installation has finished, leave the "run MSYS2 ... now" box checked and press finish.
    8) Close the subsequent MSYS2 window (since http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/ hints at needing top open/close once).
    9) Run msys2_shell.bat from C:\msys64, using explorer
    10) Using the subsequent shell:
    
    Ed@ed-laptop ~
    $ echo $MSYSTEM
    MSYS
    
    Ed@ed-laptop ~
    $ echo $HOME
    /c/Users/Ed
    
    Ed@ed-laptop ~
    $ pwd
    /c/Users/Ed
    
    Ed@ed-laptop ~
    $ cd ~
    bash: cd: /home/Ed: No such file or directory
    
    Ed@ed-laptop ~
    $ cat /etc/fstab
    # For a description of the file format, see the Users Guide
    # http://cygwin.com/cygwin-ug-net/using.html#mount-table
    
    # DO NOT REMOVE NEXT LINE. It remove cygdrive prefix from path
    none / cygdrive binary,posix=0,noacl,user 0 0
    
     

    Last edit: Ed 2014-10-28
  • Ed

    Ed - 2014-11-17

    Works fine with a clean install of the new release (msys2-x86_64-20141113.exe).
    Happy to call this fixed now.

     
  • Alexx83

    Alexx83 - 2014-11-17
    • status: open --> closed
    • assigned_to: Alexx83
     
  • Ray Donnelly

    Ray Donnelly - 2014-11-17

    Glad it's working for you, but I fear this one's like a bad penny, or Arnold Schwarzenegger .. "I'll be back".

     
  • Jasin

    Jasin - 2014-12-30

    "I'm back"

    I was a cygwin user up till about a week ago. I decided to install windows 8.1 fresh. This time I decided to install MSYS2 instead.

    The reason I ended up here was because windows environment variable %HOME% was not set and as such I had no access to my FS outside of msys64 dir.

    After a few google searches and reading I found out that Git Bash for windows automatically sets the $HOME var. to %USERPROFILE% if %HOME% does not exist. This seems like a logical approach and I would have no problem with doing this if I hadn't of read this on MinWG http://www.mingw.org/wiki/HOWTO_Set_the_HOME_variable_for_cmd_exe

    Seems to me this issue could be handled a little more elegantly other then assuming %HOME% is set.

     
  • Ray Donnelly

    Ray Donnelly - 2014-12-30

    How did you launch the MSYS2 shell?

     
    • Jasin

      Jasin - 2014-12-30

      msys2_shell.bat from the 'MSYS2 Shell' shortcut on the start menu

       
  • Alexx83

    Alexx83 - 2014-12-30

    Please read "/etc/post-install/05-home-dir.post" file. Recently Cygwin/MSYS2 switch to use new scheme for mapping Windows users to Cygwin. To solve your problem you need edit "/etc/nsswitch.conf" file. Find "db_home" line and add "windows" before "cygwin".

    Regards,
    Alexey.