# CMake Error: The current CMakeCache.txt directory is different than the directory where CMakeCache.txt was created

**Code:** `CMakeCache.txt directory is different` · **Category:** C/C++ · **Seen on:** CMake

The build folder was copied or moved.

## Meaning

CMake stores absolute paths in `CMakeCache.txt`. If you copy or rename a build folder, those paths are wrong and CMake refuses to continue instead of mixing two locations.

## Common causes

- build directory moved
- Copied from another machine
- Build folder committed or copied between machines

## Quick fix

1. `rm -rf build` then reconfigure
2. Delete the whole build directory and configure again
3. Keep build directories out of version control

## Detailed fix by platform

### Shell

1. `rm -rf build && cmake -S . -B build`

## How to diagnose

1. **Moved** — Folder?
2. **Recent change** — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/cmake-cache-directory-different)
