9
3
NOTE: Please see my second edit below for an update on the problem.
Cygwin was working fine for me until last week. Now .bashrc isn't getting sourced. I must have installed something or changed something but I can't remember exactly what caused the problem. When I start Cygwin, I'm in my Windows home and none of my aliases work. I have to manually source .bashrc. The following is my Cygwin.bat:
@echo off
C:
chdir C:\cygwin\bin
set CYGWIN=tty notitle glob
bash --login -i
Any ideas?
EDIT: My .bash_profile contains the following,
# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
EDIT2: IMPORTANT! When I started Cygwin it starts in my Windows home folder. I tried putting my .bash_profile and .bashrc in this folder and they were sourced correctly! This means that the problem has been reduced to figuring out why Cygwin starts in the Windows home folder and not the normal Cygwin home folder.
EDIT3: Results of running grep Gulshan /etc/passwd/
$ grep Gulshan /etc/passwd
Administrator:unused:500:513:U-Gulshan-HP\Administrator,S-1-5-21-1235613160-4193452482-2032876723-500:/home/Administrator:/bin/bash
Guest:unused:501:513:U-Gulshan-HP\Guest,S-1-5-21-1235613160-4193452482-2032876723-501:/home/Guest:/bin/bash
Gulshan:unused:1000:513:U-Gulshan-HP\Gulshan,S-1-5-21-1235613160-4193452482-2032876723-1000:/home/Gulshan:/bin/bash
When your bash shell starts (and puts you in your Windows home directory), what does
echo $HOME
print? – Keith Thompson – 2012-03-01T00:44:35.517It echoes my Windows home, not my Cygwin home. – gsingh2011 – 2012-03-01T00:52:09.783
But using Cygwin syntax, right? (
/cygdrive/c/Users/foo
rather thanC:\Users\foo
) – Keith Thompson – 2012-03-01T00:55:09.457Yes, using Cygwin syntax. – gsingh2011 – 2012-03-01T00:56:25.793
What happens when you type
HOME=/home/yourname bash -l
at the terminal prompt? If I'm right, this should give you properly working shell. Note that this is a diagnostic, or at best a workaround, not a solution; we still need to figure out why your$HOME
is incorrect in the first place. The root problem is the incorrect setting of$HOME
; bash is behaving correctly. – Keith Thompson – 2012-03-01T00:57:45.787Yes, that command works, thanks. How can we go about debugging what changed the $HOME variable? – gsingh2011 – 2012-03-01T01:01:24.673
See my answer.. – Keith Thompson – 2012-03-01T01:05:52.347