nikivdev/code · error
Source and destination are the same path.
Error message
Source and destination are the same path.
What it means
Thrown by migrate_to_path (src/code.rs:279) when the source and destination paths resolve to the same path. Copying/moving a folder onto itself is a no-op at best and dangerous at worst, so it is rejected up front before the `copy` or `move` action executes.
Source
Thrown at src/code.rs:279
cmd.skip_codex,
)
}
/// Migrate a folder to an arbitrary target path (not necessarily ~/code).
fn migrate_to_path(
from: &Path,
target: &Path,
copy: bool,
dry_run: bool,
skip_claude: bool,
skip_codex: bool,
) -> Result<()> {
let target_display = target.display().to_string();
let action = if copy { "copy" } else { "move" };
let action_past = if copy { "Copied" } else { "Moved" };
if from == target {
bail!("Source and destination are the same path.");
}
if !from.exists() {
bail!("Source folder does not exist: {}", from.display());
}
if !from.is_dir() {
bail!("Source path is not a directory: {}", from.display());
}
if target.exists() {
bail!("Destination already exists: {}", target.display());
}
if target.starts_with(from) {
bail!("Destination cannot be inside the source folder.");
}
// Create parent directories if needed
if let Some(parent) = target.parent() {
if !parent.exists() {
if dry_run {View on GitHub (pinned to a747e741ae)
Solutions
- Pass a destination that is a different path: `f migrate ~/code/src ~/code/src-renamed`.
- Check the resolved paths (`realpath <from>` vs `realpath <target>`) — they must differ.
- If you only wanted to relocate the current dir, run from its parent: `cd .. && f migrate <name> <new-location>`.
- Nothing to fix if the move was unintentional duplicate — simply skip the command.
Example fix
// before $ f migrate ~/code/myapp ~/code/myapp Error: Source and destination are the same path. // after $ f migrate ~/code/myapp ~/dev/myapp
Defensive patterns
Strategy: validation
Validate before calling
// Shell: compare canonicalized paths before migrating
FROM=$(realpath -m "$SRC"); TO=$(realpath -m "$DST")
[ "$FROM" != "$TO" ] || { echo "source and destination are identical"; exit 1; } Type guard
fn paths_differ(a: &Path, b: &Path) -> bool {
match (a.canonicalize(), b.canonicalize()) {
(Ok(a), Ok(b)) => a != b,
_ => a != b,
}
} Try / catch
match run_migrate(opts) {
Err(e) if e.to_string().contains("same path") => {
eprintln!("Source equals destination; nothing to migrate.");
}
other => other?,
} Prevention
- Canonicalize both paths (realpath) in scripts before calling migrate
- Don't run migrate while cd'd inside the source directory
- Compare resolved destinations when source/target come from variables
When it happens
Trigger: Running `f migrate <src> <src>` or paths that canonicalize identically (e.g. `f migrate . .`, `f migrate ~/code/x ~/code/../code/x`), including the single-target form where <target> equals the current directory's resolved path.
Common situations: Script variables that happen to hold the same value; relative-vs-absolute spellings of the same directory; forgetting you are already cd'd into the source folder.
Related errors
- Missing profile: {}
- enable-global is only supported for Codex sessions; use `f c
- Project mismatch. Bundle is for '{}' but this repo is '{}'.
- Diff bundle not found. Expected {} or pass a path to a bundl
- No templates found in ~/new/
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/b15ab05e36318c8e.
Report an issue: GitHub.