{"record":{"id":"bf64fde0677a0e68","repo":"nikivdev/code","slug":"source-is-not-a-jj-workspace-run-jj-git-init-c","errorCode":null,"errorMessage":"Source is not a jj workspace. Run `jj git init --colocate` in {} and retry.","messagePattern":"Source is not a jj workspace\\. Run `jj git init --colocate` in (.+?) and retry\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ext.rs","lineNumber":244,"sourceCode":"    #[cfg(not(unix))]\n    {\n        let metadata =\n            fs::metadata(target).with_context(|| format!(\"failed to read {}\", target.display()))?;\n        if metadata.is_dir() {\n            copy_dir_all(target, dest)?;\n        } else {\n            fs::copy(target, dest)\n                .with_context(|| format!(\"failed to copy {}\", target.display()))?;\n        }\n        Ok(())\n    }\n}\n\nfn prepare_source_workspace(source: &Path, project_root: &Path) -> Result<PathBuf> {\n    let repo_root = match jj_root(source) {\n        Ok(root) => root,\n        Err(_) => {\n            bail!(\n                \"Source is not a jj workspace. Run `jj git init --colocate` in {} and retry.\",\n                source.display()\n            );\n        }\n    };\n\n    let workspace = workspace_name_for_project(project_root)?;\n    if workspace.is_empty() {\n        return Ok(source.to_path_buf());\n    }\n\n    let status = git_capture_in(&repo_root, &[\"status\", \"--porcelain\"]).unwrap_or_default();\n    if !status.trim().is_empty() {\n        println!(\"Source repo has uncommitted changes:\");\n        for line in status.lines().take(20) {\n            println!(\"  {line}\");\n        }\n        let continue_anyway = prompt_yes_no(","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ext.rs#L226-L262","documentation":"prepare_source_workspace calls jj_root(source) to locate the jj repository root; if the source directory is not inside a jj workspace, jj_root fails and the tool bails with instructions to initialize one with `jj git init --colocate`.","triggerScenarios":"import_external_path given a directory that is a plain folder or a git-only repo (no .jj/), so `jj root` (via jj_capture_in) exits non-zero inside jj_root.","commonSituations":"Importing a freshly cloned git repo that was never colocated; importing an empty or non-VCS directory; jj not installed so the probe fails even in a valid workspace.","solutions":["Run `jj git init --colocate` inside the source directory, then retry the import.","Point the import at the actual jj workspace root instead of a subfolder outside it.","Confirm jj is installed and on PATH (`jj --version`), since a missing binary also makes jj_root fail."],"exampleFix":"// before (shell)\nimport-external ~/repos/plain-git-repo\n// after (shell)\ncd ~/repos/plain-git-repo && jj git init --colocate\nimport-external ~/repos/plain-git-repo","handlingStrategy":"validation","validationCode":"let ok = std::process::Command::new(\"jj\")\n    .args([\"root\"])\n    .current_dir(source)\n    .output()\n    .map(|o| o.status.success())\n    .unwrap_or(false);\nif !ok {\n    return Err(anyhow!(\"{} is not a jj workspace; run `jj git init --colocate` there\", source));\n}\nimport_external_path(source)?;","typeGuard":"fn is_jj_workspace(dir: &Path) -> bool {\n    dir.join(\".jj\").exists() || dir.ancestors().any(|a| a.join(\".jj\").exists())\n}","tryCatchPattern":"if let Err(e) = import_external_path(source) {\n    if e.to_string().contains(\"not a jj workspace\") {\n        eprintln!(\"Initialize first: cd {source} && jj git init --colocate\");\n    } else { return Err(e.into()); }\n}","preventionTips":["Always clone/create sources with `jj git init --colocate` so .git and .jj coexist.","Verify `jj --version` works in the environment before importing.","Point imports at workspace roots, not arbitrary subdirectories."],"tags":["vcs","jj","missing-repository"],"backgroundTag":"not-a-git-repository","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}