Skip to content

fix: resolve configurations path from executable location#72

Closed
mauricio-leoncio wants to merge 1 commit intocmd-tools:mainfrom
mauricio-leoncio:fix/config-path
Closed

fix: resolve configurations path from executable location#72
mauricio-leoncio wants to merge 1 commit intocmd-tools:mainfrom
mauricio-leoncio:fix/config-path

Conversation

@mauricio-leoncio
Copy link
Contributor

@mauricio-leoncio mauricio-leoncio commented Feb 18, 2026

Fix: Resolve configurations path from executable location

Problem

When aws-commander is installed via Homebrew (brew install aws-commander), running the binary from any directory other than the project root fails with:

open ./configurations: no such file or directory

This happens because ConfigurationsRelativeFilePath was hardcoded as "./configurations", which resolves against the current working directory instead of the binary's location.

Solution

Replaced the hardcoded relative path with resolveConfigurationsPath(), which uses os.Executable() + filepath.EvalSymlinks() to locate the configurations/ directory next to the actual binary. This handles both direct execution and Homebrew's symlink layout (bin/Cellar/). Falls back to "./configurations" if resolution fails.

Local Testing (Run from the aws-commander folder to build it)

1. Reproduce the bug:

mkdir -p /tmp/aws-commander-test
go build -o /tmp/aws-commander-test/aws-commander .
cd /tmp && /tmp/aws-commander-test/aws-commander
# ❌ open ./configurations: no such file or directory

2. Apply fix and test with configurations next to binary:

go build -o /tmp/aws-commander-test/aws-commander .
cp -r configurations /tmp/aws-commander-test/
cd /tmp && /tmp/aws-commander-test/aws-commander
# ✅ TUI launches successfully

3. Test symlink scenario (simulates Homebrew layout):

mkdir -p /tmp/aws-commander-symtest
ln -sf /tmp/aws-commander-test/aws-commander /tmp/aws-commander-symtest/aws-commander
cd /tmp && /tmp/aws-commander-symtest/aws-commander
# ✅ Resolves through symlink, finds configurations next to real binary

4. Verify existing tests:

go build ./... && go vet ./... && go test ./...
# ✅ All tests pass

@biagiopietro
Copy link
Collaborator

closed as done in #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants