fix: fallback to CWD/.bin when no git repo or envs#108
Merged
Conversation
GetBinaryPath now falls back to $PWD/.bin instead of returning an empty string when PATH_BIN, PATH_BASE, and git root are all unavailable. This allows `b install` to work outside of a git repository without requiring environment variables. Closes #86 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve temp dir symlinks with filepath.EvalSymlinks to handle macOS /var → /private/var. Add tests for PATH_BASE fallback, PATH_BIN priority over all sources, and GetDefaultConfigPath CWD fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #86 by adding a fallback to $PWD/.bin when b install is run outside a git repository and without environment variables set. Previously, GetBinaryPath() would return an empty string in this scenario, causing installation failures.
Changes:
- Added CWD/.bin fallback to
GetBinaryPath()when no git repo or env vars are available - Updated
ErrNoBinaryPatherror message with a hint (though this becomes less relevant with the fallback) - Added three unit tests covering the new fallback behavior and existing priority logic
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/path/path.go | Implements CWD/.bin fallback logic and updates function comment with priority order |
| pkg/path/path_test.go | Adds new test file with three tests for different GetBinaryPath scenarios |
| pkg/cli/errors.go | Updates error message with hint about setting PATH_BIN or using git repo |
Use filepath.Join consistently for git root path construction. Update ErrNoBinaryPath message to reflect that CWD fallback makes it only reachable when os.Getwd fails. Fix test to use filepath.Join. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Check os.Getwd and os.Chdir errors consistently across all tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace manual os.Getenv/os.Unsetenv/defer os.Setenv with t.Setenv which properly restores or unsets variables on test cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fentas
pushed a commit
that referenced
this pull request
Feb 15, 2026
🤖 I have created a release *beep* *boop* --- ## [4.7.1](v4.7.0...v4.7.1) (2026-02-14) ### Bug Fixes * fallback to CWD/.bin when no git repo or envs ([#108](#108)) ([6b2b30f](6b2b30f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetBinaryPath()now falls back to$PWD/.binwhenPATH_BIN,PATH_BASE, and git root are all unavailableErrNoBinaryPatherror message with actionable hintGetBinaryPath(CWD fallback, env override, git root)Closes #86
Test plan
TestGetBinaryPath_FallbackCWD— verifies CWD/.bin fallback in non-git directoryTestGetBinaryPath_EnvOverride— verifies PATH_BIN takes priorityTestGetBinaryPath_GitRoot— verifies git root detection still works🤖 Generated with Claude Code