nikivdev/code · error

Destination cannot be inside the source folder.

Error message

Destination cannot be inside the source folder.

What it means

Error "Destination cannot be inside the source folder." thrown in nikivdev/code.

Source

Thrown at src/code.rs:291

) -> 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 {
                println!("Would create {}", parent.display());
            } else {
                fs::create_dir_all(parent)
                    .with_context(|| format!("failed to create {}", parent.display()))?;
            }
        }
    }

    if dry_run {
        println!("Would {} {} -> {}", action, from.display(), target_display);
    } else if copy {
        copy_dir_all(from, target)?;

View on GitHub (pinned to a747e741ae)

When it happens

Trigger: Thrown at src/code.rs:291 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/e7157213a129c36f. Report an issue: GitHub.