larksuite/cli · error
cannot determine working directory: %w
Error message
cannot determine working directory: %w
What it means
denyCheckLocalInput resolves the path against the current working directory (fail-closed) before applying the built-in denylist. If the OS cannot report the working directory, the check cannot run and the function fails closed with this wrapped error rather than guessing a location.
Source
Thrown at internal/vfs/localfileio/path.go:87
}
if err := validateLocalInputPlatform(path); err != nil {
return "", err
}
if err := denyCheckLocalInput(path); err != nil {
return "", err
}
return path, nil
}
// denyCheckLocalInput applies the built-in denylist to the relaxed local
// input tier. Resolution is fail-closed like safePath, but the allowlist is
// deliberately not consulted here. This tier hands the path back verbatim, so
// every interpretation of it is checked — the caller opens the one the OS
// picks, which for "~/..." is a literal "~" entry in the working directory.
func denyCheckLocalInput(path string) error {
cwd, err := vfs.Getwd()
if err != nil {
return fmt.Errorf("cannot determine working directory: %w", err)
}
interps, err := interpretations(path, cwd)
if err != nil {
return err
}
for _, abs := range interps {
resolved, err := resolveReal(abs)
if err != nil {
return err
}
if err := checkDeny("local input path", path, abs, resolved, cwd); err != nil {
return err
}
}
return nil
}
func isWindowsNonLocalNamespace(path string) bool {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- cd to a valid existing directory before running the command
- Restart the process from an existing directory
- In containers/CI, ensure cleanup steps don't delete the working directory the tool is invoked from
Example fix
// before (cwd deleted) $ lark apps upload --file data.json // error: cannot determine working directory: getwd: no such file or directory // after $ cd /tmp && lark apps upload --file /abs/path/data.json
Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Getwd(); err != nil {
return fmt.Errorf("cwd unavailable: %w", err)
} Try / catch
p, err := localfileio.LocalInputPath(flagValue)
if err != nil && strings.Contains(err.Error(), "cannot determine working directory") {
os.Chdir("/tmp")
p, err = localfileio.LocalInputPath(flagValue)
} Prevention
- Don't delete the directory a process is running from
- Use absolute paths and a stable WORKDIR in CI
- Verify cwd validity after cleanup steps in scripts
When it happens
Trigger: Calling localfileio.LocalInputPath (via denyCheckLocalInput) in a process whose cwd was deleted (e.g. the containing directory was removed while the process ran), or where vfs.Getwd fails due to permission loss on a path component.
Common situations: CI/container steps that rm -rf the directory a runner started in; a shell script that cds into a temp dir that a cleanup job deleted; running from a mounted volume that was unmounted.
Related errors
- No visible worksheet matched
- account has no home directory
- invalid chart size: {size!r}
- +csv-get truncated the scan range at {actual_range}; narrow
- --max-sheets must be at least 1
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/48b5713506dd520b.
Report an issue: GitHub.