Claude Code “Working Directory No Longer Exists”: How to Fix It

Claude Code “Working Directory No Longer Exists”: How to Fix It

The Claude Code working directory no longer exists error means the folder your session is using was deleted, renamed or moved while Claude Code was open. Claude Code stops the command before it runs and moves its shell to a folder that still exists. Your conversation is safe.

To fix it in a running session, type /cd followed by the folder you want, such as /cd ~/projects/my-app. That moves the session and keeps the conversation. If only a subfolder vanished, you can skip that and ask Claude to run the command again.

If claude won’t start at all, your terminal is sitting in a deleted folder. Run cd ~/projects/my-app, or cd "$PWD" if the folder was recreated at the same path, then start Claude Code again.

Browse all our Claude Code tutorials for more fixes and how-tos.

Tested with Claude Code v2.1.330 on macOS on November 22, 2026. We moved and deleted throwaway folders under live sessions, renamed a project, removed worktrees and tried each fix. Points we didn’t run ourselves come from Anthropic’s docs and are marked that way.

Quick Summary

What you seeWhat happenedFix
Working directory "..." no longer exists, so this command was not runA folder disappeared during the sessionRun it again, or use /cd
The current directory no longer exists (it was deleted or moved)You started claude in a dead foldercd to a real folder
No conversation found to continueThe project was renamedclaude --resume with the session ID
Your worktree ... no longer existsA worktree was removedKeep working, then prune
Couldn't start a background session (working directory no longer exists ...)The folder went away while it startedRecreate it or pick another folder

What “Working Directory No Longer Exists” Means in Claude Code

A working directory is the folder where commands run. Claude Code remembers it between commands, so when Claude runs cd build, the next command starts inside build.

Something outside the session can then take that folder away. Common causes are a build script that clears dist, a branch switch that drops a folder, a project you renamed in Finder, or a git worktree removed from another terminal.

Diagram showing Claude Code's shell in a build folder, the folder being deleted, the folder check failing and the command not being run
Claude Code checks the folder first, so the command never runs in the wrong place.

Why Claude Code stops the command

Picture a command like rm -r * that was meant for build. Running it one level up would be a disaster, so Claude Code refuses to guess.

That protection is recent. According to Anthropic’s changelog, version 2.1.325 fixed shell commands running in the launch directory after the working directory was deleted. Run claude update if you’re on an older version.

We Reproduced the Error in a Live Session

We asked Claude to create a build folder, move into it and print the path. Then we moved build away from a second terminal and asked for ls -a:

Error: Working directory "/Users/you/claude-code-demos/wd-gone/app/build" no longer exists, so this command was not run. Shell cwd recovered to "/Users/you/claude-code-demos/wd-gone/app": re-issue the command if it still makes sense there.
Claude Code showing Error: Working directory no longer exists, so this command was not run, then pwd printing the project folder
The full error in the Ctrl+O view. The next pwd ran fine in the project folder.

The words after “recovered to” matter most. They tell you where Claude’s next command will run. In the normal view the failure may be a short “1 failed” line, so press Ctrl+O to see the whole message.

When the whole project is renamed

Next we renamed the project folder itself, from app to app-renamed. This time there was no project folder to return to, and the shell went to the home folder.

Claude Code error saying the working directory app no longer exists and Shell cwd recovered to the home folder
With the project renamed, the shell recovered to the home folder.

We asked for pwd once more, and it really did run in the home folder. Claude didn’t go looking for the renamed project.

Claude Code running pwd in the home folder with the note Shell cwd was reset to the home folder
The next command ran in the home folder, not in the renamed project.

So don’t just tell Claude to try again here. A search or a cleanup command would run against your entire home folder.

Read the path after “recovered to” before you say “try again.”

How to Fix “Working Directory No Longer Exists”

Start with when the message appeared, then follow the first row that matches.

Decision diagram for fixing Claude Code working directory no longer exists: won't start, subfolder gone, project moved, worktree gone
Match the moment to the fix.

Fix 1: A subfolder is gone, so run the command again

If the recovered path is your project folder, you’re already in a good place. Ask Claude to recreate the folder or run the command from the project:

The build folder was deleted. You're in the project root now. Recreate build, then run the last command again from the root.

If this keeps happening with one folder, ask Claude to stay in the project root and use paths such as ls build. You can also set CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 before launch. The tools reference says every Bash command then starts in the project directory.

Fix 2: The project moved, so use /cd

This is the best fix for a renamed or moved project. Type /cd and the new path in the same session:

/cd ~/claude-code-demos/wd-gone/app-renamed
Claude Code /cd command showing Moved to app-renamed after the working directory error, and pwd with ls now listing the project files
One /cd after the error, and Claude was back with the project files.

Claude answered from the right folder and still had the earlier conversation. Per the permissions docs, /cd also loads the new folder’s CLAUDE.md, settings, hooks and skills. If the folder isn’t trusted yet, you get the trust prompt first.

Don’t mix it up with /add-dir. That command gives Claude access to a second folder, but it doesn’t change the main one.

Fix 3: claude won’t start, so leave the dead folder

Your terminal can sit in a deleted folder without any warning. In our test, claude and claude -p both refused to start, and claude --bg gave the same message with exit code 1.

Terminal showing The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory, with exit code 1
Started from a deleted folder, Claude Code exits before a session begins.

The simple fix is to move somewhere that exists:

cd ~/projects/my-app
claude

There’s one trap. We recreated the folder at the same path, and Claude Code still refused, because the terminal was holding on to the old deleted folder. Running cd "$PWD" solved it.

Terminal showing Claude Code failing after the folder was recreated, then working after cd with the PWD variable
Recreating the folder wasn’t enough. cd “$PWD” fixed it.

Anthropic’s error reference gives the same advice. It also says versions before 2.1.239 crashed with a raw ENOENT ... uv_cwd stack instead, so that old crash is the same problem.

Claude Code error reference steps for the current directory no longer exists, with the cd PWD step highlighted
The error reference: your shell still holds the deleted directory.

Fix 4: Get your conversation back after a rename

Say you closed the session before renaming the project. Claude Code files conversations under the folder path, so a new name looks like a new project. We opened the renamed folder and ran claude --continue:

Terminal in app-renamed showing claude --continue reply No conversation found to continue
The old conversations still exist, but not under this path.

Nothing is lost. Resuming by session ID worked from the renamed folder and brought back the whole conversation:

claude --resume <session-id>
Claude Code session from the old app folder reopened in the renamed folder with its full earlier conversation
The same conversation, reopened from the renamed folder by session ID.

Claude Code prints the ID when you exit. If you don’t have it, run claude --resume and press Ctrl+A to list every project. The sessions docs say a session whose folder is gone resumes in your current directory.

Once it’s open, ask Claude to use the new path, since the old one is all over the conversation. Our sessions guide explains naming, so you can resume by name instead of an ID.

Fix 5: A worktree was removed

Worktrees are easy to delete by mistake, because they look like spare copies. We moved one away under a live session, and the same error appeared. The shell went to the home folder here too.

Claude Code error in a worktree session saying the working directory fix-cart no longer exists and the shell recovered to the home folder
A worktree session loses its folder: same error, same fallback.

We then force-closed another worktree session, moved its folder and resumed it from the main checkout. Claude Code opened it there with a clear notice:

Claude Code notice Your worktree fix-nav no longer exists, so this session is working in the current directory without worktree isolation
The session resumes, but it’s now in the main checkout without isolation.

The worktree docs say no action is needed. Just remember that edits now land in your main checkout. If you want isolation back, start a new one with claude --worktree <name>.

Claude Code worktree docs table with the row Your worktree no longer exists highlighted
The docs list this notice and its close relatives.

Git still remembers the missing worktrees, so clean up its list:

git worktree list
git worktree prune -v
git worktree unlock .claude/worktrees/fix-nav
git worktree prune -v
Terminal showing git worktree prune removing fix-login, then unlock and prune removing fix-nav, while fix-cart stays locked
Prune skips locked entries, so unlock a dead one first.

Prune skipped the locked entries until we unlocked one. Unlock only worktrees with no session running, because that lock protects live work. Your branch stays in git, but uncommitted files live only in the deleted folder.

Fix 6: Background sessions

The background version reads Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo). Per the error reference, the folder was removed while the session was starting. Recreate it or start from a folder that exists.

If the folder was already gone, versions since 2.1.281 say could not be resolved on disk instead. The fix is the same.

Messages That Look Similar

These have different causes, so check the wording before you pick a fix.

MessageMeaning
Shell cwd was reset to ...Usually harmless: Claude tried to cd outside the project and was brought back
Can't read the current directory (EACCES)The folder exists, but you don’t have permission
Can't read the current directory (EPERM) on a MacmacOS is blocking your terminal from Desktop, Documents, Downloads or iCloud Drive
posix_spawn ENOENT from a hookAn old bug with deleted folders, fixed in 2.1.239

For the Mac EPERM case, the docs say to quit the terminal with Cmd+Q and reopen it. If ls still fails there, allow the folder for your terminal in System Settings under Privacy & Security, Files and Folders.

Hooks have their own fallback. The hooks docs say they run from the start folder, the project root, your home folder or the temp folder, whichever exists first. If yours still fail, see our guide to broken hooks.

Try It Yourself

You can practice in a minute with an empty folder. Never do this with a real project:

mkdir -p ~/wd-test/app && cd ~/wd-test/app
claude

In a second terminal, run mv ~/wd-test/app ~/wd-test/app2. Then give Claude this prompt:

Run pwd with Bash, once. If it fails, don't retry. Quote the error and tell me which folder the shell recovered to.

Finish with /cd ~/wd-test/app2 and ask for pwd again. You should see the new folder.

Common Mistakes

  • Saying “try again” without reading the recovered path. It may be your home folder.
  • Recreating the folder and expecting the open terminal to notice. Run cd "$PWD" first.
  • Assuming your conversation was deleted because claude --continue finds nothing after a rename.
  • Deleting a worktree folder by hand while its session is open.
  • Forcing past a git lock. In our test, git worktree remove --force refused while the session was running, and that refusal saved the folder.

Pro Tips

  • Exit Claude Code before you rename a project, then start again in the new folder.
  • Name long sessions with /rename, so you don’t need the ID later.
  • Use Keep or Remove in the worktree exit prompt instead of deleting the folder. Our worktrees guide walks through it.
  • In scripts, run cd /your/project || exit 1 before claude -p, so a missing folder stops the job early.
  • Keep temporary clones out of cleanup paths such as /tmp when a session will run for hours.

Cheat Sheet

Cheat sheet for Claude Code working directory no longer exists with commands for start errors, session errors, renamed projects and worktrees
Save this for the next time a folder disappears.

Frequently Asked Questions

Do I lose my conversation when the working directory is deleted?

No. Claude Code doesn’t store conversations in your project folder. You can keep using the open session, or reopen it later with claude --resume and its ID.

Can Claude Code restore the deleted folder?

Not by itself. Restore it from git, your Trash or a backup. Don’t rely on /rewind for this, because the docs say changes made outside the session aren’t tracked by default.

Why did the command work after one failure?

Because the shell had already moved to a folder that exists. That’s fine when it’s your project folder and risky when it’s your home folder.

Does this happen on Windows and Linux?

We tested on macOS, but the changelog also lists Windows fixes for the same problem. For example, 2.1.323 fixed commands failing with “Working directory was deleted” on drives where a folder’s real path couldn’t be resolved, so update first.

What if I still can’t start Claude Code?

Open a new terminal window, which starts in a fresh folder, and run claude there. If it fails with another message, look it up in our list of common errors or the guide to exit code 1.

Conclusion

The “working directory no longer exists” error is Claude Code refusing to run a command in the wrong place. Check the recovered path, use /cd to point the session at the right folder, and run cd "$PWD" when a terminal is stuck in a deleted one. Renamed projects and removed worktrees can both be resumed, so your conversation survives. If you’re new to the tool, our Claude overview is a good next stop.

Newsletter

New AI tools in your inbox

The best new tools and the AI news that matters, in one short email. Unsubscribe any time.

Free · No spam · Unsubscribe any time

✓ Looks like you’re subscribed

Loading Google’s sign-up form…

Looks like you’re already subscribed

Thanks for reading! New AI tools and the AI news that matters will land in your inbox.

Not subscribed yet? Refresh the page to load the sign-up form.

The sign-up form couldn’t load. If you use an ad or content blocker, allow news.google.com and reload the page.

Free instant check before you pay. Takes a few seconds.

Scroll to Top