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
Thrown by TestSuiteRunner.Test when filepath.Abs fails to resolve the ConfigDirectory to an absolute path. filepath.Abs fails only when the OS cannot determine the current working directory (os.Getwd returns an error), typically because the process's working directory was deleted from underneath it. This is an environment/process-state error, not a configuration error.
Solutions
- Ensure the working directory exists and is accessible when terraform test is invoked (do not delete it in parallel steps)
- If ConfigDirectory is relative, ensure the process CWD is valid, or pass an absolute path
- Re-run terraform test from a stable, existing directory
- In CI, verify the checkout/workspace step completes before the test step starts and is not cleaned concurrently
Defensive patterns
Strategy: validation
Validate before calling
// Before invoking TestSuiteRunner.Test, verify the working directory exists:
if wd, err := os.Getwd(); err != nil {
return fmt.Errorf("working directory is inaccessible, cannot resolve ConfigDirectory: %w", err)
} else {
absConfigDir := filepath.Join(wd, runner.ConfigDirectory)
if _, err := os.Stat(absConfigDir); err != nil {
return fmt.Errorf("config directory %s does not exist: %w", absConfigDir, err)
}
} Try / catch
// This is a fatal diagnostics error from Test(); catch at the caller:
status, diags := runner.Test(false)
for _, d := range diags {
if strings.Contains(d.Description().Summary, "absolute path") {
// environment issue — CWD was deleted; restart from a valid directory
return fmt.Errorf("working directory issue during test: %s", d.Description().Summary)
}
} Prevention
- Never delete or rename the process working directory while terraform test is running
- In CI, ensure the checkout/workspace is not cleaned by a concurrent step during the test phase
- Pass an absolute ConfigDirectory to TestSuiteRunner to reduce dependence on CWD stability
When it happens
Trigger: The process's current working directory was deleted or renamed while the test runner was initializing; the ConfigDirectory path is empty and Getwd fails; running terraform test from within a directory that another process removed; container/CI environment where the build workspace was cleaned mid-run.
Common situations: CI pipeline that cleans the workspace in a parallel step while terraform test is starting; a script that deletes and recreates the working directory; running in a ephemeral container whose mount was removed; very rare under normal interactive use.
Related errors
- blank output
- can not get working directory for current os platform
- can't form absolute path of
- Error creating temporary file for upload
- Error getting pwd
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/4e8727f96059bd41.
Report an issue: GitHub.
Appendix: 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 d32a084675)