dagger/dagger · error

Evaluate env file: %w

Error message

Evaluate env file: %w

What it means

Wrapper in EnvFile.Namespace: the underlying evaluation of the env file's variables (expansion of references via ef.Variables) failed, so a namespaced subset cannot be produced. The wrapped cause names the specific variable or parse problem.

Source

Thrown at core/envfile.go:181

// Filters variables by prefix and removes the prefix from keys.
//
// Variables without the prefix are excluded. For example, with the prefix
// "MY_APP_" and variables:
//
//	MY_APP_TOKEN=topsecret
//	MY_APP_NAME=hello
//	FOO=bar
//
// the resulting environment will contain:
//
//	TOKEN=topsecret
//	NAME=hello
func (ef *EnvFile) Namespace(ctx context.Context, prefix string) (*EnvFile, error) {
	// use raw variables here given that they'll get expanded later when used
	vars, err := ef.Variables(ctx, true)
	if err != nil {
		return nil, fmt.Errorf("Evaluate env file: %w", err)
	}
	result := &EnvFile{
		Expand: ef.Expand,
		// Preserve any hidden expansion context already carried by the source.
		Context: slices.Clone(ef.Context),
	}
	for _, variable := range vars {
		if after, match := cutFlexPrefix(variable.Name, prefix); match {
			result.add(after, variable.Value)
		} else {
			// Keep non-matching variables as hidden expansion context so that
			// namespaced values referencing them (e.g. SOURCE=${ROOT_DIR}) can
			// still be expanded later. They are not exposed as defaults.
			result.Context = append(result.Context, variable.Name+"="+variable.Value)
		}
	}
	return result, nil
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Fix the variable error reported in the wrapped cause (undefined reference, cycle, or parse error)
  2. Validate the .env file contents before re-running the namespace operation
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/envfile.go:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/03002107e0571c77. Report an issue: GitHub.