plandex-ai/plandex · error

no project root found

Error message

no project root found

What it means

GetProjectPaths resolves project file paths relative to fs.ProjectRoot, but returns 'no project root found' when that package-level variable is empty. ProjectRoot is normally initialized when the CLI/REPL loads a workspace; calling GetProjectPaths before that initialization (or outside a valid project directory) yields this error.

Source

Thrown at app/cli/fs/paths.go:19

package fs

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
	"plandex-cli/types"
	"strings"
	"sync"

	shared "plandex-shared"

	ignore "github.com/sabhiram/go-gitignore"
)

func GetProjectPaths(baseDir string) (*types.ProjectPaths, error) {
	if ProjectRoot == "" {
		return nil, fmt.Errorf("no project root found")
	}

	return GetPaths(baseDir, ProjectRoot)
}

func GetPaths(baseDir, currentDir string) (*types.ProjectPaths, error) {
	ignored, err := GetPlandexIgnore(currentDir)

	if err != nil {
		return nil, err
	}

	allPaths := map[string]bool{}
	activePaths := map[string]bool{}

	allDirs := map[string]bool{}
	activeDirs := map[string]bool{}
	gitIgnoredDirs := map[string]bool{}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run the command from inside a project directory that root detection recognizes (contains the expected marker file)
  2. Ensure the project-discovery/initialization step ran before calling GetProjectPaths — call the root-detection entry point first if using this as a library
  3. Check earlier startup logs for a silent failure in root detection
  4. If Programmatic use is intended, set fs.ProjectRoot explicitly before calling GetProjectPaths

Example fix

// before
paths, err := fs.GetProjectPaths(baseDir) // panics with 'no project root found'
// after
if fs.ProjectRoot == "" {
	root, rerr := fs.DetectProjectRoot(cwd)
	if rerr != nil {
		return fmt.Errorf("cannot locate project root: %w", rerr)
	}
	fs.ProjectRoot = root
}
paths, err := fs.GetProjectPaths(baseDir)
Defensive patterns

Strategy: validation

Validate before calling

// run before calling GetProjectPaths or any dependent API (Build, MustLoadContext, ...)
if fs.ProjectRoot == "" {
	return fmt.Errorf("no project root detected — run from inside a project directory or initialize the root first")
}

Type guard

func hasProjectRoot() bool {
	return fs.ProjectRoot != ""
}

Try / catch

paths, err := fs.GetProjectPaths(baseDir)
if err != nil {
	if err.Error() == "no project root found" {
		// recover: run project discovery or prompt the user
		root, rerr := promptOrDetectRoot()
		if rerr != nil { return rerr }
		fs.ProjectRoot = root
		paths, err = fs.GetProjectPaths(baseDir)
	}
	if err != nil { return err }
}

Prevention

When it happens

Trigger: Calling GetProjectPaths (directly or via MustApplyPlanAttempt, MustLoadContext, Build, runRepl, update) while fs.ProjectRoot == "": running the tool outside a project directory, invoking library functions before project discovery runs, or initialization code failing silently earlier.

Common situations: Running CLI commands from $HOME or a directory with no project marker; embedding the library and calling Build/MustLoadContext without setting fs.ProjectRoot; a failed earlier root-detection step leaving the variable unset.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/86053bde5421fc0e. Report an issue: GitHub.