charmbracelet/crush · error
error resolving file path: %w
Error message
error resolving file path: %w
What it means
filepath.Abs(filePath) failed while making the (working-dir-joined) target file path absolute. Like error 204, this only fails if os.Getwd fails, since SmartJoin(workingDir, params.FilePath) produced a relative path that needed cwd resolution.
Source
Thrown at internal/agent/tools/view.go:123
// Handle builtin skill files (crush: prefix).
if strings.HasPrefix(params.FilePath, skills.BuiltinPrefix) {
resp, err := readBuiltinFile(params, skillTracker)
return resp, err
}
// Handle relative paths
filePath := filepathext.SmartJoin(workingDir, params.FilePath)
// Check if file is outside working directory and request permission if needed
absWorkingDir, err := filepath.Abs(workingDir)
if err != nil {
return fantasy.ToolResponse{}, fmt.Errorf("error resolving working directory: %w", err)
}
absFilePath, err := filepath.Abs(filePath)
if err != nil {
return fantasy.ToolResponse{}, fmt.Errorf("error resolving file path: %w", err)
}
relPath, err := filepath.Rel(absWorkingDir, absFilePath)
isOutsideWorkDir := err != nil || strings.HasPrefix(relPath, "..")
isSkillFile := isInSkillsPath(absFilePath, skillsPaths)
sessionID := GetSessionFromContext(ctx)
if sessionID == "" {
return fantasy.ToolResponse{}, fmt.Errorf("session ID is required for accessing files outside working directory")
}
// Request permission for files outside working directory, unless it's a skill file.
if isOutsideWorkDir && !isSkillFile {
granted, permReqErr := permissions.Request(
ctx,
permission.CreatePermissionRequest{
SessionID: sessionID,
Path: absFilePath,View on GitHub (pinned to 7944b8e522)
Solutions
- Pass absolute paths for both workingDir and file_path
- Restore/recreate the process's original working directory
- Restart the process from a valid directory
- Re-run the view call with a fully absolute file_path
Example fix
// before // cwd deleted -> filepath.Abs(rel) fails // after cd /valid/dir && crush # restart process with a valid cwd, or pass absolute file_path
Defensive patterns
Strategy: validation
Validate before calling
if _, err := filepath.Abs(filePath); err != nil {
return fmt.Errorf("unresolvable path %q: %w", filePath, err)
} Type guard
func canResolve(p string) bool {
_, err := filepath.Abs(p)
return err == nil
} Try / catch
var pe *fs.PathError
if errors.As(err, &pe) {
// cwd invalid: restore cwd or pass absolute file_path
} Prevention
- Pass absolute file_path values to the view tool
- Ensure the process cwd remains valid for its lifetime
- Restart the process from a valid directory after cwd removal
When it happens
Trigger: Same root cause as the working-dir error: a relative workingDir/target path combined with a process cwd that was deleted or is inaccessible.
Common situations: Deleted or unmounted current working directory; running inside a container whose workdir vanished; tmpdir cleanup races.
Related errors
- error resolving working directory: %w
- failed to write file: %w
- failed to read file: %w
- failed to write file: %w
- error checking file: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/eb6513042f6ea144.
Report an issue: GitHub.