owasp-amass/amass · error

environment variable %s is not set

Error message

environment variable %s is not set

What it means

LoadDatabaseEnvSettings in config/graphdb.go requires that the AMASS_USER (amassUser) environment variable is set before configuring the graph database credentials. If os.LookupEnv finds the variable unset, it returns this error immediately instead of building a Database entry. It is the library's way of refusing to run with anonymous/empty DB credentials.

Source

Thrown at config/graphdb.go:72

			return err
		}
	}
	return nil
}

// LoadDatabaseEnvSettings initializes the DB structure with the Environment variables.
func (c *Config) LoadDatabaseEnvSettings() error {
	dbURI := ""
	db := &Database{
		Primary: true,
		System:  "postgres",
	}

	var u string
	if uenv, set := os.LookupEnv(amassUser); set {
		u = uenv
	} else {
		return fmt.Errorf("environment variable %s is not set", amassUser)
	}
	db.Username = u
	h := "localhost"
	if dbEnv, set := os.LookupEnv(assetDB); set {
		h = dbEnv
	}
	db.Host = h
	port := "5432"
	if pEnv, set := os.LookupEnv(assetPort); set {
		port = pEnv
	}
	db.Port = port
	n := "assetdb"
	if nEnv, set := os.LookupEnv(assetDBName); set {
		n = nEnv
	}
	db.DBName = n
	if p, set := os.LookupEnv(amassPass); set {

View on GitHub (pinned to 79299dce87)

Solutions

  1. Set the environment variable (export it in the shell or service unit) before running: export $(amassUser value).
  2. Check the exact variable name with `printenv | grep -i amass` to rule out typos.
  3. If running under systemd/docker, add the variable to the unit's Environment= or env_file / -e flag.
  4. As a last resort inspect config/graphdb.go:72 to confirm the expected variable name in your version.

Example fix

// before
$ ./amass enum
// error: environment variable AMASS_USER is not set
// after
$ export AMASS_USER=dbuser
$ ./amass enum
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("AMASS_USER") == "" {
    return errors.New("AMASS_USER must be set before loading settings")
}

Try / catch

if err := config.LoadDatabaseEnvSettings(); err != nil {
    var envErr *config.EnvVarError
    if errors.As(err, &envErr) { /* prompt for env var */ }
}

Prevention

When it happens

Trigger: Calling LoadSettings or loadDatabaseSettings (directly or in tests via TestLoadDatabaseEnvSettings) when the amassUser environment variable is not present in the process environment.

Common situations: Running amass from cron/systemd/CI where the interactive shell environment (with the exported variable) is not inherited; forgetting to export the variable before running; a typo in the variable name.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/fd131aa75466c8b5. Report an issue: GitHub.