diff --git a/cmd/entire/cli/setup.go b/cmd/entire/cli/setup.go index 13ae0f279..2ff5fbc6a 100644 --- a/cmd/entire/cli/setup.go +++ b/cmd/entire/cli/setup.go @@ -382,11 +382,20 @@ If Entire is already configured but disabled, this re-enables it.`, // Check if we're in a git repository first - this is a prerequisite error, // not a usage error, so we silence Cobra's output and use SilentError // to prevent duplicate error output in main.go - if _, err := paths.WorktreeRoot(ctx); err != nil { + repoRoot, err := paths.WorktreeRoot(ctx) + if err != nil { fmt.Fprintln(cmd.ErrOrStderr(), "Not a git repository. Please run 'entire enable' from within a git repository.") return NewSilentError(errors.New("not a git repository")) } + // Notify the user when running from a subdirectory. + // All path resolution uses paths.WorktreeRoot(ctx) which returns the + // correct repo root regardless of CWD, so no directory change is needed. + cwd, err := os.Getwd() //nolint:forbidigo // Need CWD to detect subdirectory + if err == nil && cwd != repoRoot { + fmt.Fprintf(cmd.ErrOrStderr(), "Note: Running from repository root (%s)\n\n", repoRoot) + } + if err := validateSetupFlags(opts.UseLocalSettings, opts.UseProjectSettings); err != nil { return err }