12

I noticed this several times today. If I type cd ../Directory to change to another directory, it prints "bash: cd: write error: Success". I can't determine what other previous commands might be related to this.

  • typeset -f prints nothing.
  • alias prints nothing.
  • type -a cd prints "cd is a shell builtin".
  • echo $CDPATH prints an empty line.
  • $BASH_VERSION prints "bash: 4.2.37(1)-release: command not found".
  • I only noticed this 2-3 times. The initial directory and target directory were identical in both situations. I changed directories in this manner many other times, but did not encounter the error always.

What could be causing this?

4
  • Please add the output of type -a cd as Glenn requested.
    – terdon
    Commented Feb 22, 2014 at 12:56
  • Please add the output of the type command to your question. Also, does this happen in all directories or only if you are in a specific one(s)? And what is the output of echo $CDPATH?
    – terdon
    Commented Feb 22, 2014 at 13:26
  • What exact bash version (in $BASH_VERSION) are you running?
    – Gabe
    Commented Feb 23, 2014 at 0:07
  • I have bash 4.2.37(1).
    – Village
    Commented Feb 23, 2014 at 1:28

2 Answers 2

6

Maybe a bug?

This sounds like a potential bug. I found a similar report showing the same message. The bug bash: pwd builtin exits with write error: Success.

excerpt

This message will be displayed if ferror(stdout) returns non-zero. For some reason (probably the fflush() call immediately preceding the check), stdio is causing ferror() to return true without setting errno.

Does this happen twice in a row? The pwd builtin calls clearerr() after printing the error message, so even if the stdout error flag `sticks', that should clear it.

Can't update history?

The error makes me think that it was successful in changing directories, but wasn't able to write the command cd ../Directory to your $HOME/.bash_history. I'd confirm that this file is intact and is writable. Also confirm that your $HOME directory is writable and not full.

$ df -h $HOME
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/fedora_greeneggs-home  402G  157G  225G  42% /home
5
  • The /home partition has much space available. I cannot find anything strange in ".bash_history", it is set to read and write only for the owner. Whenever I quit a terminal, the data from that terminal still goes there. Is is possible this came up because I was running multiple terminal windows at the same time?
    – Village
    Commented Feb 22, 2014 at 14:49
  • @Village - perhaps, but each time a command is run in a shell it should get a lock on the history file and release when it's done, every other process doing the same would just wait.
    – slm
    Commented Feb 22, 2014 at 14:58
  • bash does not write to ~/.bash_history immediately after running the command, but after the session closed, right?
    – SOFe
    Commented Mar 19, 2016 at 13:18
  • @Pemapmodder - correct, it was unclear to me if the OP had done something like this: askubuntu.com/questions/67283/….
    – slm
    Commented Mar 19, 2016 at 13:34
  • I encountered the same problem, and I'm quite sure that it is not true (because I was su root at that time, and I instantly tail /root/.bash_history and saw nothing relevant, then exit to back to my normal user, then sudo tail /root/.bash_history, and the line (both lines, since I repeated the cd) was indeed written.
    – SOFe
    Commented Mar 20, 2016 at 16:33
3

Your cd command is either an alias or most likely a bash function.

typeset -f  # displays functions
alias       # display aliases

If not found with the above commands which cd will locate the path of the cd command.

Look for the cd alias or function definition in the normal start scripts .bash_profile, .bashrc and .profile.

3
  • typeset -f, alias, and which cd all return nothing, and the other files only contain PATH=~/.context/tex/texmf-linux/bin/:$PATH.
    – Village
    Commented Feb 22, 2014 at 10:33
  • 2
    use type -a cd Commented Feb 22, 2014 at 11:25
  • 1
    type -a cd prints "cd is a shell builtin".
    – Village
    Commented Feb 22, 2014 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .