charmbracelet/crush · error · ErrNoWorkspaceConfig
no workspace config path configured
Error message
no workspace config path configured
What it means
ErrNoWorkspaceConfig is a sentinel error returned when a workspace-scoped write (SetConfigField/RemoveConfigField or configPath resolution) is attempted on a ConfigStore that has no workspace config path configured. The store can read/write global/project config, but workspace-scoped operations require an explicit workspace path.
Source
Thrown at internal/config/scope.go:29
// ScopeWorkspace targets the workspace config (.crush/crush.json).
ScopeWorkspace
)
// String returns a human-readable label for the scope.
func (s Scope) String() string {
switch s {
case ScopeGlobal:
return "global"
case ScopeWorkspace:
return "workspace"
default:
return fmt.Sprintf("Scope(%d)", int(s))
}
}
// ErrNoWorkspaceConfig is returned when a workspace-scoped write is
// attempted on a ConfigStore that has no workspace config path.
var ErrNoWorkspaceConfig = fmt.Errorf("no workspace config path configured")
View on GitHub (pinned to 7944b8e522)
Solutions
- Open/initialize a workspace (run Crush inside a project directory) so the workspace config path is set.
- Use global or project scope instead of workspace scope for the write.
- Construct the ConfigStore with a valid workspace config path if you control its creation.
- Check errors.Is(err, config.ErrNoWorkspaceConfig) and handle gracefully in tooling.
Example fix
// before
store.SetConfigField(config.ScopeWorkspace, "options.foo", val)
// after
if store.HasWorkspaceConfig() {
store.SetConfigField(config.ScopeWorkspace, "options.foo", val)
} else {
store.SetConfigField(config.ScopeProject, "options.foo", val)
} Defensive patterns
Strategy: type-guard
Validate before calling
if store.WorkspaceConfigPath() == "" {
// use another scope or prompt user to open a workspace
} Type guard
func canWriteWorkspace(s *config.ConfigStore) bool {
err := s.SetConfigField(config.ScopeWorkspace, "__probe", true)
if errors.Is(err, config.ErrNoWorkspaceConfig) { return false }
_ = s.RemoveConfigField(config.ScopeWorkspace, "__probe")
return true
} Try / catch
err := store.SetConfigField(config.ScopeWorkspace, key, val)
if errors.Is(err, config.ErrNoWorkspaceConfig) {
// fall back to project/global scope
} Prevention
- Check errors.Is(err, config.ErrNoWorkspaceConfig) on workspace writes
- Only offer workspace scope in the UI when a workspace is open
- Initialize ConfigStore with a workspace path in tests that need it
When it happens
Trigger: Calling configPath(ScopeWorkspace), SetConfigField, or RemoveConfigField with workspace scope on a ConfigStore constructed without a workspace config path (empty workspace path, e.g. outside a project or in tests).
Common situations: Running a workspace-scoped config edit when Crush was started without a project/workspace directory; constructing a ConfigStore in tests without setting the workspace path; tooling that assumes a workspace is always present.
Related errors
- coder agent is not initialized
- failed to initialize config: %w
- task agent not configured
- small model provider not configured
- coder agent not configured
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/07ceea2512ca796f.
Report an issue: GitHub.