direnv/direnv · error
invalid arguments
Error message
invalid arguments
What it means
`direnv log` expects exactly the command name plus a log type (--status or --error) and a message, i.e. args must have length 3. cmdLog returns this error for any other argument count. The Args spec `[--status | --error] <message>` documents the expected shape.
Source
Thrown at internal/cmd/cmd_log.go:18
package cmd
import (
"errors"
"fmt"
)
// CmdLog is `direnv log [--status | --error] <message>`
var CmdLog = &Cmd{
Name: "log",
Desc: "Logs a given message",
Args: []string{"[--status | --error]", "<message>"},
Action: actionWithConfig(cmdLog),
}
func cmdLog(_ Env, args []string, c *Config) (err error) {
if len(args) != 3 {
return errors.New("invalid arguments")
}
logType := args[1]
message := args[2]
switch logType {
case "--status", "-status":
logStatus(c, message)
case "--error", "-error":
logError(c, message)
default:
return fmt.Errorf("invalid log-type '%s'", logType)
}
return nil
}
View on GitHub (pinned to b00e451f54)
Solutions
- Invoke as `direnv log --status "message"` or `direnv log --error "message"`
- Quote the message so it is passed as a single argument: `direnv log --status "build done"`
- Verify the flag spelling is `--status` (or `-status`) as accepted by the switch
Example fix
// before direnv log build done // after direnv log --status "build done"
Defensive patterns
Strategy: validation
Validate before calling
if [ "$#" -lt 2 ]; then echo "usage: direnv log (--status|--error) <message>" >&2; exit 2; fi direnv log --status "$*"
Prevention
- Always quote log messages so they arrive as one argument
- Include --status or --error explicitly; never rely on a default
- Match arg count to the documented Args spec: exactly two operands
When it happens
Trigger: Calling `direnv log` with fewer than two operands (e.g. no message, or no status flag) or more than two, so `len(args) != 3`.
Common situations: Hook scripts or users log status messages and forget the `--status`/`--error` flag; messages containing unquoted spaces get word-split into multiple args making len(args) exceed 3.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- missing PATH argument
- too many arguments
- a shell name is required
- an envrc path is required
- at least one file path is required
AI-assisted analysis of direnv/direnv@b00e451f54 (2026-09-05).
Data as JSON: /api/errors/9cd252c3af0d824b.
Report an issue: GitHub.