antonmedv/fx · error
specify a file as the first argument to be able to save: fx
Error message
specify a file as the first argument to be able to save: fx file.json
What it means
Raised by the __save__ builtin injected into the JS VM when a script calls save() but the tool was launched without a target file path. It is a generic guard on the global FilePath variable: save() needs a real file to write the JSON payload to, so an empty FilePath means there is nowhere to persist the output and the save is rejected before any write is attempted.
Source
Thrown at internal/engine/vm.go:32
if err := vm.Set("__save__", func(json string) error {
if FilePath == "" {
return fmt.Errorf("specify a file as the first argument to be able to save: fx file.json ")
}
if info, err := os.Lstat(FilePath); err == nil && info.Mode()&os.ModeSymlink != 0 {
return fmt.Errorf("cannot save to a symbolic link: %s", FilePath)
}
if err := os.WriteFile(FilePath, []byte(json), 0644); err != nil {
return err
}
return nil
}); err != nil {
panic(err)
}View on GitHub (pinned to 4f31cd3a0c)
Solutions
- Run fx with a file argument, e.g. fx file.json
- Only call save() when a file argument was supplied
- Pass the target path explicitly before invoking save() in the script
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/engine/vm.go:32 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of antonmedv/fx@4f31cd3a0c (2026-09-02).
Data as JSON: /api/errors/d4b12ccfbfcfe908.
Report an issue: GitHub.