Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, in Terminal, when I execute a cd command, it also executes LWP's head command.

A copy of the Terminal output follows:

laptop:bin user$ cd ~
Unknown option: n
Usage: head [-options] <url>...
    -m <method>   use method for the request (default is 'HEAD')
    -f            make request even if head believes method is illegal
    -b <base>     Use the specified URL as base
    -t <timeout>  Set timeout value
    -i <time>     Set the If-Modified-Since header on the request
    -c <conttype> use this content-type for POST, PUT, CHECKIN
    -a            Use text mode for content I/O
    -p <proxyurl> use this as a proxy
    -P            don't load proxy settings from environment
    -H <header>   send this HTTP header (you can specify several)

    -u            Display method and URL before any response
    -U            Display request headers (implies -u)
    -s            Display response status code
    -S            Display response status chain
    -e            Display response headers
    -d            Do not display content
    -o <format>   Process HTML content in various ways

    -v            Show program version
    -h            Print this message

    -x            Extra debugging output
laptop:bin user$

I've reviewed the ~/.bash_profile and ~/.bashrc but there are only three export statements and no alias or something like that. It's as follows:

[[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm"  # This loads RVM into a shell session.
### Added by the Heroku Toolbelt
export PATH="/Applications/XAMPP/xamppfiles/bin:/usr/local/heroku/bin:$PATH"
export PATH=/Users/user/bin/Sencha/Cmd/$PATH
export SENCHA_CMD_3_0_0="/Users/user/bin/Sencha/Cmd/"
export PATH=$PATH:/Applications/acquia-drupal/drush

From reading, it seems that installing LWP might have overwritten the /usr/bin/head command, but I've checked and it's the OSX one. However, when I call head from Terminal, it invokes the LWP head command instead.

Per patrix's request, here are the contents of ~/.rvm/scripts/rvm:

I'll keep out trying things, and I'll update the question with new information if relevant.

Additional information:

laptop:dir user$ alias cd
-bash: alias: cd: not found
laptop:dir user$ which cd
laptop:dir user$ which head

The output of echo "$PS1"; echo "$PROMPT_COMMAND" is:

\h:\W \u\$ 

The output of type -a update_terminal_cwd is:

update_terminal_cwd is a function
update_terminal_cwd () 
    local SEARCH=' ';
    local REPLACE='%20';
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}";
    printf '\e]7;%s\a' "$PWD_URL"

The output of type -a cd is:

cd is a function
cd () 
    if builtin cd "$@"; then
        return 0;
        return $?;
cd is a shell builtin
cd is /usr/bin/cd
share|improve this question
What is in /Users/user/.rvm/scripts/rvm? – patrix Jan 22 '14 at 12:55
@patrix, edited question to include that file's content, thanks! – Esteban Brenes Jan 22 '14 at 14:08
what does alias cd and which cd show? – Mark Jan 22 '14 at 14:29
@Esteban, In terminal type which head then post the result here. That should tell the path of which one you're actually using. – l'L'l Jan 22 '14 at 14:41
What is the output of echo "$PS1"; echo "$PROMPT_COMMAND"? – glenn jackman Jan 22 '14 at 17:35
up vote 3 down vote accepted

I am going to assume you are using bash.

So in that case when you just type cd it should be running the bash built-in. This is what has the problem.

To confirm this try using the external version - at the command prompt type /usr/bin/cd and you should go to your home directory with no problems.

Now let's check what the other cd might be up to.

type -a cd should give us

cd is a shell builtin
cd is /usr/bin/cd

which head should give us /usr/bin/head

alias might give us a long list but nothing pointing towards an alias for cd

The CD environment variables should have sane entries:


The same with:

PROMPT_COMMAND='history -a; history -n; printf "\e]1;${PWD}\a"'
PS1='\[\033[34m\]\h:\W \u$\[\033[0m\] '

If all that is OK then my money would be on cd being redefined by a builtin function that has gone pear shaped. At the command line set | less will allow you to page through a dump of all your shell variables, aliases and functions. If you type / you can search through the file for cd (notice the space) and see if that is happening.

Once you have discovered that "someone" - in your case rvm - is defining a shell function called cd then you can either uninstall the culprit or find where it does the nasty work and change the name of the function to something like 'rcd' instead of 'cd'. As the shell function is listed first in the output of type the builtin cd is ignored except where it is getting called by the function (that's what the builtin cd in the function definition is doing - calling the builtin version).

I'd almost guarantee that the function is defined in /Users/user/.rvm/scripts/rvm.

I'd start by uninstalling rvm and then reinstall to see if that fixes it. Are you installing it using MacPorts or Homebrew?

share|improve this answer
I think, based on the first command type -a cd we've got part of the culprit, as I'm getting something from RVM as well as the builtin shell function (added output to question). So I believe it's calling both? How would one fix that so it's not using those two cd definitions? – Esteban Brenes Jan 23 '14 at 12:06
Uninstalling fixed the issues (especially following RVM's instructions to remove all traces of it from the system) It was installed using Homebrew. – Esteban Brenes Jan 23 '14 at 12:32
Nice. RVM was actually my first thought when I read the description. Just get rbenv, it only aliases the ruby commands and therefor shouldn't mess with anything else. – mtsr Jan 23 '14 at 15:58

Your Answer


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.