Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I start cygwin, my ~ dir is the same as $HOME. After some time, ~ dir changs, while $HOME stays the same. I am puzzled by this, not sure where to look. Maybe someone experienced this, or has some clue what's going on? When I start:

winuser@mybox ~
$ echo $HOME
/cygdrive/c/cyguser

winuser@mybox ~
$ echo ~
/cygdrive/c/cyguser

Later, ~ changes to /cygdrive/c/winuser, which is non-existent. When I restart cygwin, everything is back to normal. What could be causing this?

share|improve this question

migrated from stackoverflow.com Apr 3 '12 at 18:50

This question came from our site for professional and enthusiast programmers.

1  
The ~ character is expanded to the value of $HOME by the bash shell. The only time this won't happen is if $HOME is not set; then it's expanded to the home directory of the current user, but that's not consistent with what you're describing. Please show us (copy-and-paste) the output of echo \~ = ~, HOME = $HOME, USER = $USER, \~winuser = ~winuser. And normally your home directory should be /home/winuser; why and how did you change it? –  Keith Thompson Apr 3 '12 at 18:58
    
@Keith I set HOME under user section of environment variables dialog. It is set to C:\cyguser. I am waiting for the problem to reoccur. Currently: ~ = /cygdrive/c/cyguser , HOME = /cygdrive/c/cyguser, USER = winuser, ~winuser = /home/winuser. Thanks for looking into this. –  user443854 Apr 3 '12 at 21:03
    
Whatever is causing this behavior (~ and $HOME should be the same), I think you'll be better off using the default settings, with your Cygwin home directory set to /home/username. If you want your Cygwin home directory to be directly under C:` for some reason, you can make /home/username`. The inconsistency between cyguser and winuser is also confusing. –  Keith Thompson Apr 3 '12 at 23:01
    
@Keith the inconsistency is for two reasons. First, I had other things, such as .emacs, at that location before cygwin. And second, my windows user name is assigned by admin, it is too long to type and different from all other computers I use. –  user443854 Apr 4 '12 at 12:34

1 Answer 1

up vote 2 down vote accepted

Your/etc/passwd file is wrong; it'll be listing your home directory as /cygdrive/c/winuser. Fix it by editing that file and correcting the field.

I've had similar problems; Cygwin bash doesn't read your home directory from the passwd file at start up, so ~ is correct, but certain things (I never managed to work out what, exactly) will cause it to reload and reset from that file, picking up the wrong value. I think it's a side-effect of a slightly dodgy package update, but I'm not sure.

share|improve this answer
    
Yes, my /etc/passwd lists my home dir as /home/winuser. I changed it to /cygdrive/c/cyguser. Thank you very much. This ~ changing on me at random was very annoying. Thx! –  user443854 Apr 4 '12 at 12:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.