gastownhall/beads · error
open dependency file: %w
Error message
open dependency file: %w
What it means
Wraps the OS error returned by os.Open when readBulkDepEdges cannot open the user-supplied bulk dependency file (any file other than '-'). It lets `bd dep add -f <file>` fail with context about which step failed while preserving the underlying errno message. It is thrown in cmd/bd/dep.go when the file path is wrong, unreadable, or a directory.
Source
Thrown at cmd/bd/dep.go:612
"count": len(resolved),
"dependencies": out,
})
}
fmt.Printf("%s Added %d dependencies\n", ui.RenderPass("✓"), len(resolved))
return nil
}
func readBulkDepEdges(file string, defaultType string) ([]bulkDepEdge, error) {
var r io.Reader
var f *os.File
if file == "-" {
r = os.Stdin
} else {
var err error
f, err = os.Open(file) // #nosec G304 -- user-supplied bulk dependency file
if err != nil {
return nil, fmt.Errorf("open dependency file: %w", err)
}
defer f.Close()
r = f
}
scanner := bufio.NewScanner(r)
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
var edges []bulkDepEdge
var errs []string
lineNo := 0
for scanner.Scan() {
lineNo++
line := strings.TrimSpace(scanner.Text())
if line == "" {
continue
}
var in bulkDepInputView on GitHub (pinned to 71377f2769)
Solutions
- Verify the path exists and is readable: ls -l <file>, or cat <file> to confirm access.
- If input should come from stdin, pass '-' as the file value (readBulkDepEdges maps '-' to os.Stdin).
- Fix permissions (chmod/chown) or move the file into the directory where bd runs.
- Check for a stale relative path and re-run with an absolute path.
Example fix
// before bd dep add bd-1 --file ./deps.txt // error: open dependency file: no such file or directory // after bd dep add bd-1 --file "$PWD/deps.txt" # or verify file exists first [ -r deps.txt ] && bd dep add bd-1 --file deps.txt
Defensive patterns
Strategy: validation
Validate before calling
if [ ! -r "$DEPS_FILE" ] || [ -d "$DEPS_FILE" ]; then echo "dependency file not readable: $DEPS_FILE" >&2; exit 1; fi
Try / catch
if err := addBulkDeps(file); err != nil {
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {
fmt.Fprintf(os.Stderr, "cannot open %s: %v\n", file, err)
os.Exit(1)
}
return err
} Prevention
- Always resolve the -f argument to an absolute path in scripts.
- Use '-' with a heredoc/pipe when generating dependency lists dynamically.
- Check file readability in CI before invoking bd dep add.
When it happens
Trigger: Running `bd dep add --file <path>` (via addBulkDependencies or runDepAddBulkProxied) where os.Open fails: nonexistent path, no read permission, path is a directory, or a stale symlink.
Common situations: Typo in the -f path; running from a different working directory than assumed; file deleted after shell globbing; permission-restricted mount or CI sandbox that blocks reading the dependency list.
Related errors
- line %d: 'dep' requires a subcommand (add|remove)
- line %d: unknown dep subcommand %q (want add|remove)
- --deps cannot attach both %q and %q to the same target %q: a
- --deps target is empty
- resolving --deps target %q: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/8cb23957d959cc15.
Report an issue: GitHub.