hashicorp/terraform · error
Failed to get absolute path of the configuration directory:
Error message
Failed to get absolute path of the configuration directory: %v
What it means
At the start of TestSuiteRunner.Test, filepath.Abs(runner.ConfigDirectory) resolves the configuration directory to an absolute path. This wraps a failure of that call.
Source
Thrown at internal/cloud/test.go:129
func (runner *TestSuiteRunner) Stop() {
runner.Stopped = true
}
func (runner *TestSuiteRunner) IsStopped() bool {
return runner.Stopped
}
func (runner *TestSuiteRunner) Cancel() {
runner.Cancelled = true
}
func (runner *TestSuiteRunner) Test(_ bool) (moduletest.Status, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
configDirectory, err := filepath.Abs(runner.ConfigDirectory)
if err != nil {
diags = diags.Append(fmt.Errorf("Failed to get absolute path of the configuration directory: %v", err))
return moduletest.Error, diags
}
variables, variableDiags := ParseCloudRunTestVariables(runner.GlobalVariables)
diags = diags.Append(variableDiags)
if variableDiags.HasErrors() {
// Stop early if we couldn't parse the global variables.
return moduletest.Error, diags
}
addr, err := tfaddr.ParseModuleSource(runner.Source)
if err != nil {
if parserError, ok := err.(*tfaddr.ParserError); ok {
diags = diags.Append(tfdiags.AttributeValue(
tfdiags.Error,
parserError.Summary,
parserError.Detail,
cty.Path{cty.GetAttrStep{Name: "source"}}))View on GitHub (pinned to c9def3e214)
Solutions
- Re-run from a valid, existing directory.
- Ensure the shell's current working directory still exists.
- Pass an absolute configuration directory path to the runner.
Example fix
// before: runner.ConfigDirectory = "." while cwd was deleted -> abs path fails // after: pass an absolute, existing path runner.ConfigDirectory = "/home/user/my-module"
Defensive patterns
Strategy: validation
Validate before calling
// Validate the config directory exists and is resolvable before running tests
abs, err := filepath.Abs(runner.ConfigDirectory)
if err != nil {
return fmt.Errorf("cannot resolve config directory: %w", err)
}
if info, err := os.Stat(abs); err != nil || !info.IsDir() {
return fmt.Errorf("config directory does not exist: %s", abs)
} Prevention
- Run terraform test from an existing directory
- Pass an absolute config directory path
- Avoid renaming/removing the cwd while the process runs
When it happens
Trigger: filepath.Abs fails when the process's current working directory cannot be determined, e.g. the cwd was deleted or renamed underneath the process.
Common situations: Running terraform test from a directory that was removed or renamed while the process ran, or unusual filesystem/permission state.
Related errors
- Failed to open script '%s': %v
- Error getting pwd: %s
- No file or directory at %s
- There is no configuration directory at %s
- Error loading statefile: %w
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/4e8727f96059bd41.
Report an issue: GitHub.