nikivdev/code · error
This repo is not a jj workspace. Run `jj git init --colocate
Error message
This repo is not a jj workspace. Run `jj git init --colocate` in {} and retry. What it means
ensure_jj_repo_in walks up from the given path looking for a jj workspace root (via try_jj_root / jj_root_if_exists). If no jj workspace is found, it bails with this error telling the user to initialize one with `jj git init --colocate`. It guards all downstream jj operations that require an existing workspace.
Source
Thrown at src/vcs.rs:46
}
let git_dir = path.join(".git");
if git_dir.exists() {
let status = Command::new("jj")
.current_dir(path)
.args(["git", "init", "--colocate"])
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.context("failed to run jj git init --colocate")?;
if status.success() {
if let Ok(root) = try_jj_root(path) {
return Ok(root);
}
}
}
bail!(
"This repo is not a jj workspace. Run `jj git init --colocate` in {} and retry.",
path.display()
);
}
pub fn jj_root_if_exists(path: &Path) -> Option<PathBuf> {
let output = Command::new("jj")
.current_dir(path)
.arg("root")
.output()
.ok()?;
if !output.status.success() {
return None;
}
let root = String::from_utf8_lossy(&output.stdout).trim().to_string();
if root.is_empty() {
None
} else {View on GitHub (pinned to a747e741ae)
Solutions
- Run `jj git init --colocate` in the directory named in the error message to create a colocated git+jj workspace, then retry.
- cd into the correct project directory (one that is already a jj workspace) before running, or fix the configured path.
- If it's an existing git repo you want to keep: `jj git init --colocate` in that repo converts it in place without losing history.
- Verify `jj root` succeeds manually in the target directory to confirm the workspace is detected.
Example fix
// before $ mytool sync Error: This repo is not a jj workspace. Run `jj git init --colocate` in /home/me/project and retry. // after $ cd /home/me/project $ jj git init --colocate $ mytool sync
Defensive patterns
Strategy: validation
Validate before calling
use std::path::Path;
fn is_jj_workspace(dir: &Path) -> bool {
dir.join(".jj").exists() || std::env::var("JJ_WORKSPACE").is_ok()
}
// before calling:
let dir = Path::new("/home/me/project");
if !is_jj_workspace(dir) {
eprintln!("Run `jj git init --colocate` in {} first", dir.display());
std::process::exit(1);
} Prevention
- Always run `jj git init --colocate` when converting an existing git repo before using jj-based tooling
- Verify `jj root` succeeds in your project directory before running tools that depend on jj
- Store absolute, existing workspace paths in tool configuration
- Beware git worktrees and submodules — ensure the checkout you run from is itself jj-initialized
When it happens
Trigger: Calling ensure_jj_repo_in(path) (or ensure_jj_repo(), which passes the current directory) where neither the path nor any ancestor is a jj workspace — i.e. `jj root` fails at every level up the tree.
Common situations: Running the tool in a plain git repo that was never colocated with jj (no `jj git init --colocate` was run); running from a scratch/tmp directory; pointing the config at the wrong project path; jj workspace was deleted or the .jj directory was removed/gitignored; running inside a git worktree that jj does not recognize.
Related errors
- jj workspace corrupted
- jj root failed
- jj {} failed: {}
- jj bookmark set failed: {}
- jj git push failed: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/356fb25adebe4300.
Report an issue: GitHub.