My .bashrc file is a symlink to ~/Scripts/rc/bashrc. This works well for me, and has been for years.

However, as of today, this is what I am seeing:

bash-4.3$ source .bashrc
bash: source: .bashrc: file not found
bash-4.3$ ls -la .bashrc
lrwxrwxrwx 1 jonas jonas 17 Oct 28 12:31 .bashrc -> Scripts/rc/bashrc
bash-4.3$ source Scripts/rc/bashrc 

I can't really make sense of this. Why would it suddenly stop working? I am using Utopic on a amd64 Dell laptop.

Some debug ouput:

bash-4.3$ stat .bashrc
  File: ‘.bashrc’ -> ‘Scripts/rc/bashrc’
  Size: 17          Blocks: 8          IO Block: 4096   symbolic link
Device: 22h/34d Inode: 10880136    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1001/   jonas)   Gid: ( 1001/   jonas)
Access: 2014-10-28 12:31:57.076868217 +0100
Modify: 2014-10-28 12:31:57.076868217 +0100
Change: 2014-10-28 12:31:57.076868217 +0100
 Birth: -

bash-4.3$ stat Scripts/rc/bashrc
  File: ‘Scripts/rc/bashrc’
  Size: 4019        Blocks: 24         IO Block: 4096   regular file
Device: 22h/34d Inode: 11146383    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/   jonas)   Gid: ( 1001/   jonas)
Access: 2014-10-28 12:29:53.352871873 +0100
Modify: 2014-05-27 12:43:09.470849817 +0200
Change: 2014-05-27 12:43:09.470849817 +0200
 Birth: -

bash-4.3$ readlink -e .bashrc
  • Maybe try changing the linked file to a hidden file? .bashrc? – Tim Oct 28 '14 at 11:48
  • Strange indeed... please post the output of stat .bashrc and stat Scripts/rc/bashrc and readlink -e .bashrc. – Jan Oct 28 '14 at 11:48
  • I have found the cause of this bug. I have an rsync task in Gnome Scheduler which when run causes this. A reboot fixes it. @Jan, do you see anything strange in the output? Anything I can use to file a bug against Gnome Scheduler? – Jonas G. Drange Oct 28 '14 at 12:51
  • 1
    What does the rsync do? Could it be removing the file and recreating it? Such a race condition might explain your symptoms. Also try running strace bash -c "builtin . ~/.bashrc that should show you exactly where the error is happening and why. – terdon Oct 28 '14 at 13:25
  • It pushes some unrelated files (deja-dup files) to a remote location. I doubt that's it. – Jonas G. Drange Oct 28 '14 at 15:01

If the filename does not contain a /, the builtin command source may look up the name in the PATH only, depending on some shell options. So instead of source .bashrc,

`source ./.bashrc`

should do what you want.

From man bash:

     .  filename [arguments]
    source filename [arguments]
           Read  and  execute  commands from filename in the current shell
           environment and return the exit status of the last command exe‐
           cuted  from  filename.   If  filename does not contain a slash,
           filenames in PATH are used to  find  the  directory  containing
           filename.   The  file  searched  for  in  PATH need not be exe‐
           cutable.  When bash is not in posix mode, the current directory
           is  searched  if  no  file is found in PATH.  If the sourcepath
           option to the shopt builtin command is turned off, the PATH  is
           not  searched.
  • That works, thanks, but I'm running the source program indirectly by starting gnome-terminal. Should I change the profile file you mean? This does not answer why it suddenly changed, maybe you can speculate? My reasoning fall short. – Jonas G. Drange Oct 28 '14 at 12:19
  • It could have something to do with the recent Bash security problem named ShellShock. The security hole had to do with parsing indirect parameters which could be altered, the fix is to not longer allow this. – Requist Oct 28 '14 at 13:03
  • @JonasG.Drange As the man page says it depends on POSIX mode or not, a change in that may have changed it. – Volker Siegel Oct 28 '14 at 13:44
  • I don't know what POSIX mode is. – Jonas G. Drange Oct 28 '14 at 15:00
  • @JonasG.Drange it's what you get if you call bash as sh or launch it with the POSIXLY_CORRECT variable set. – terdon Oct 28 '14 at 18:05

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.