glanceapp/glance · error

getting absolute path of %s: %w

Error message

getting absolute path of %s: %w

What it means

filepath.Abs failed for the config/include path while resolving includes. Abs only fails when os.Getwd fails (usually because the working directory was deleted) since it converts any path to absolute without touching the filesystem. The path and wrapped error are included in the message.

Source

Thrown at internal/glance/config.go:258

var configIncludePattern = regexp.MustCompile(`(?m)^([ \t]*)(?:-[ \t]*)?(?:!|\$)include:[ \t]*(.+)$`)

func parseYAMLIncludes(mainFilePath string) ([]byte, map[string]struct{}, error) {
	return recursiveParseYAMLIncludes(mainFilePath, nil, 0)
}

func recursiveParseYAMLIncludes(mainFilePath string, includes map[string]struct{}, depth int) ([]byte, map[string]struct{}, error) {
	if depth > CONFIG_INCLUDE_RECURSION_DEPTH_LIMIT {
		return nil, nil, fmt.Errorf("recursion depth limit of %d reached", CONFIG_INCLUDE_RECURSION_DEPTH_LIMIT)
	}

	mainFileContents, err := os.ReadFile(mainFilePath)
	if err != nil {
		return nil, nil, fmt.Errorf("reading %s: %w", mainFilePath, err)
	}

	mainFileAbsPath, err := filepath.Abs(mainFilePath)
	if err != nil {
		return nil, nil, fmt.Errorf("getting absolute path of %s: %w", mainFilePath, err)
	}
	mainFileDir := filepath.Dir(mainFileAbsPath)

	if includes == nil {
		includes = make(map[string]struct{})
	}
	var includesLastErr error

	mainFileContents = configIncludePattern.ReplaceAllFunc(mainFileContents, func(match []byte) []byte {
		if includesLastErr != nil {
			return nil
		}

		matches := configIncludePattern.FindSubmatch(match)
		if len(matches) != 3 {
			includesLastErr = fmt.Errorf("invalid include match: %v", matches)
			return nil
		}

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Restart the process from a directory that exists
  2. Pass an absolute config path so the cwd is irrelevant
  3. Fix the deployment step that removes the working directory before/while the process starts

Example fix

# before
./glance --config glance.yml   # run from a dir that may vanish
# after
./glance --config /etc/glance/glance.yml
Defensive patterns

Strategy: try-catch

Validate before calling

if wd, err := os.Getwd(); err != nil {
    log.Fatal("working directory unavailable: ", err)
}

Try / catch

if err := loadConfig(p); err != nil {
    if strings.Contains(err.Error(), "getting absolute path") {
        // cwd vanished; retry from a known directory with absolute path
    }
}

Prevention

When it happens

Trigger: The glance process's current working directory is removed while it loads config with a relative path, causing Getwd inside filepath.Abs to fail.

Common situations: Running glance from a directory that a deployment script or container orchestration deleted/replaced mid-run; exotic environments where the cwd is inaccessible. Rarely seen in normal operation.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/771711b3db430818. Report an issue: GitHub.