{"record":{"id":"cca8d81b97a007b0","repo":"direnv/direnv","slug":"cannot-allow-empty-path","errorCode":null,"errorMessage":"cannot allow empty path","messagePattern":"cannot allow empty path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/rc.go","lineNumber":102,"sourceCode":"\terr = times.Unmarshal(marshalledTimes)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tpathHash, err := pathHash(path)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tdenyPath := filepath.Join(config.DenyDir(), pathHash)\n\n\treturn &RC{path, allowPath, denyPath, times, config}\n}\n\n// Allow grants the RC as allowed to load\nfunc (rc *RC) Allow() (err error) {\n\tif rc.allowPath == \"\" {\n\t\treturn fmt.Errorf(\"cannot allow empty path\")\n\t}\n\tif err = os.MkdirAll(filepath.Dir(rc.allowPath), 0755); err != nil {\n\t\treturn\n\t}\n\tif err = allow(rc.path, rc.allowPath); err != nil {\n\t\treturn\n\t}\n\tif err = rc.times.Update(rc.allowPath); err != nil {\n\t\treturn\n\t}\n\tif _, err = os.Stat(rc.denyPath); err != nil {\n\t\tif errors.Is(err, fs.ErrNotExist) {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\treturn os.Remove(rc.denyPath)\n}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/direnv/direnv/blob/b00e451f547f39be7ab836d969054114a465a0f9/internal/cmd/rc.go#L84-L120","documentation":"Raised in RC.Allow when the RC struct's allowPath field is empty. allowPath is computed as AllowDir()/sha256-of-rc-file by RCFromPath/RCFromEnv; an empty value means the RC object was constructed without a resolvable allow path (e.g. RCFromEnv failed to hash the file and returned a degenerate RC, or the RC was hand-built in tests/embedding). This is a defensive invariant guard — Allow refuses to write permission state to an unspecified location. Reached from cmdEditAction after editing.","triggerScenarios":"Thrown at internal/cmd/rc.go:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Construct the RC via RCFromPath/FindRC so allowPath is populated from config.AllowDir()","If building RC manually, initialize all fields including the hashed allow path","Check that config.DataDir is set so AllowDir() yields a non-empty base","Report a bug if this fires during normal `direnv allow`/`direnv edit` usage — it indicates a construction bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b00e451f547f39be7ab836d969054114a465a0f9","analyzedAt":"2026-09-05T21:39:49.983Z","contentChangedAt":"2026-09-05T21:39:49.983Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}