macoszshmacos-sonoma

cd doesn't appear to be changing directory in terminal


I have a weird issue that I first noticed in VS Code but can replicate in terminal, and it's that when I try to cd to a folder, nothing happens. Here's my terminal output to demonstrate:

rh-macbook@AS1554 ~ % pwd
/Users/rh-macbook
rh-macbook@AS1554 ~ % ls
Applications        Library         Public
Desktop         Movies          node_modules
Documents       Music           package-lock.json
Downloads       Pictures        package.json
rh-macbook@AS1554 ~ % cd Desktop
rh-macbook@AS1554 ~ % ls
Applications        Library         Public
Desktop         Movies          node_modules
Documents       Music           package-lock.json
Downloads       Pictures        package.json

Here's an example from within VS Code on a demo project

rh-macbook@AS1554 website-demo % pwd
/Users/rh-macbook/Desktop/Repos/website-demo
rh-macbook@AS1554 website-demo % ls
README.md       my-app
rh-macbook@AS1554 website-demo % cd my-app
rh-macbook@AS1554 website-demo % ls
README.md       my-app
rh-macbook@AS1554 website-demo % 

This is a work-issued laptop but I seem to be the only person with this issue.

Device: M2 Pro 16GB MacOS: Sonoma 14.6.1 (23G93)

I've tried cd /Desktop, cd desktop, cd ~/Desktop and all variations. It just does not seem to be switching the folder.

There is no error code.

rh-macbook@AS1554 ~ % echo $?
0
rh-macbook@AS1554 ~ % echo $HOME
/Users/rh-macbook

Answer:

As per the answer below, cd had been aliased to cdnvm. This happened when I followed the instructions on NVM's readme to automatically change node versions per .nvmrc file. Running this command fixed it:

unalias cd


Solution

  • Check what is output of which cd. Looks like either your cd binary is corrupted or some alias is running instead of cd itself.

    P.S. - It was alias issue. output of which cd was aliased to cdnvm