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.

I've got a working Xming / Cygwin installation set up on my Windows. Well, mostly...

I did set my home directory to /cygdrive/d in /etc/passwd. When I start the Cygwin Bash Shell (the pimped-up DOS window), this works - $HOME is set to /cygdrive/d, Cygwin finds my ~/.bash_profile, everything is fine.

However, when I start an xterm, it starts in /cygdrive/c/Documents and Settings/<Username>, and it does not source my .bash_profile, which is annoying as hell.

Sometime during this afternoon, it worked, and now it's broken, but for the life of me I cannot remember how I broke it.

Help?

Edit: Sorry, I should have been more precise. The xterm is started as xterm -ls, i.e. as login shell. It does find the global profile (because it runs a bash and sets $PS1 correctly), but it obviously gets confused about $HOME (and thus does not run ~/.bash_profile because it cannot find it).

I know a way or two to work around it, but I'd like to find the cause of this muckup, not fix the effects.

Edit2: Further testing showed that this - $HOME not being set according to /etc/passwd - happens only when the application is started from the Xming / Xmingrc taskbar menu. It's also contagious: Any sub-xterm started from a "broken" xterm opens in the wrong $HOME. Likewise the other way round: Any bash / xterm started outside the Xmingrc menu (that opens in the proper $HOME) can start sub-xterms that also are correct.

I'm a bit confused here.

share|improve this question
    
Might HOME already be set to C:\Documents and Settings\<user> when xterm is invoked? That would override the /etc/passwd setting. –  ak2 Aug 7 '10 at 22:21
    
@ ak2: Can't be, really. When I start the Cygwin Bash Shell (DOS box), HOME is set correctly. And it doesn't matter whether I start the xterm from that bash shell or directly through a destop shortcut. But I will double-check this tomorrow (it's my office workstation I'm talking about). –  DevSolar Aug 8 '10 at 9:31
add comment

2 Answers 2

xterm starts in the current directory and executes the program you tell it to execute (your preferred shell by default, but not a login shell). That's true on Windows as well as Unix. If you want to have a login shell, run xterm -e bash --login. If you want to start in your home directory, set the directory field in the shortcut (assuming you're starting xterm from a Windows shortcut).

share|improve this answer
    
See updated question, sorry. –  DevSolar Aug 7 '10 at 5:52
add comment
up vote 0 down vote accepted

I found the answer hidden in the Xming documentation. If no HOME environment variable is set in the system, Xming sets it to %USERPROFILE%.

Which in turn overrides the Cygwin /etc/passwd settings, as ak2 pointed out.

So, the solution is to manually set HOME in the control panel.

share|improve this answer
    
Or use Cygwin's own X server instead of Xming. (It's the xorg-server package in setup.exe.) –  ak2 Aug 9 '10 at 12:00
add comment

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.