hashicorp/nomad · error
panic(err)
Error message
panic(err)
What it means
logmon resolves its own plugin binary path at package init time via os.Executable(); the package-level `var bin = getBin()` runs during process startup. If the OS cannot determine the executable path, the error is unrecoverable for the plugin and is panicked.
Source
Thrown at client/logmon/plugin.go:23
import (
"context"
"os"
"os/exec"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/logmon/proto"
"github.com/hashicorp/nomad/plugins/base"
"google.golang.org/grpc"
)
var bin = getBin()
func getBin() string {
b, err := os.Executable()
if err != nil {
panic(err)
}
return b
}
// LaunchLogMon launches a new logmon or reattaches to an existing one.
// TODO: Integrate with base plugin loader
func LaunchLogMon(logger hclog.Logger, reattachConfig *plugin.ReattachConfig) (LogMon, *plugin.Client, error) {
logger = logger.Named("logmon")
conf := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
"logmon": &Plugin{},
},
AllowedProtocols: []plugin.Protocol{
plugin.ProtocolGRPC,
},
Logger: logger,
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Ensure the Nomad executable file still exists on disk while the process runs; don't delete/replace the binary in place during upgrades
- Upgrade via unlink+replace of a new file rather than truncating/moving the running binary path
- Check the underlying err in the panic to identify the OS-level cause (permission, missing /proc, deleted file)
- Restart the agent from a valid, existing binary path
Example fix
// before
var bin = getBin() // panics at init on error
// after
var bin = func() string {
b, err := os.Executable()
if err != nil {
b = os.Args[0] // fallback instead of panicking
}
return b
}() Defensive patterns
Strategy: fallback
Try / catch
// package init cannot be recovered from inside the package; wrap usage
func initLogmon() (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("logmon init failed: %v", r)
}
}()
_ = logmon.Plugin // triggers bin resolution
return nil
}
Prevention
- Never delete or move the running Nomad binary in place; replace atomically
- Verify os.Executable() works in your container/runtime environment before upgrade
- Keep /proc mounted properly in containers
When it happens
Trigger: Package initialization of client/logmon when os.Executable() fails — e.g. the executable file was deleted/replaced after start, /proc is unavailable, or the process was launched in a way the OS cannot trace back to a binary path.
Common situations: Binary deleted or upgraded (moved) while the agent process is running; running in minimal containers with odd /proc mounts; exec'ing the Nomad binary from a temp file that was removed; unusual embedding environments where os.Executable returns an error.
Related errors
- Failed to determine the nomad executable: %v
- rpc.dial_timeout must be greater than or equal to zero
- client_introduction.enforcement must be set
- No addresses found, please configure one.
- invalid acl policy: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/3a3a24e9f8425c7a.
Report an issue: GitHub.