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.


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.

  • 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

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

  • See updated question, sorry. – DevSolar Aug 7 '10 at 5:52

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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