Skip to content

fix: fallback to CWD/.bin when no git repo or envs#108

Merged
fentas merged 5 commits intomainfrom
fix/install-without-git-repo
Feb 14, 2026
Merged

fix: fallback to CWD/.bin when no git repo or envs#108
fentas merged 5 commits intomainfrom
fix/install-without-git-repo

Conversation

@fentas
Copy link
Owner

@fentas fentas commented Feb 14, 2026

Summary

  • GetBinaryPath() now falls back to $PWD/.bin when PATH_BIN, PATH_BASE, and git root are all unavailable
  • Improved ErrNoBinaryPath error message with actionable hint
  • Added 3 unit tests for GetBinaryPath (CWD fallback, env override, git root)

Closes #86

Test plan

  • TestGetBinaryPath_FallbackCWD — verifies CWD/.bin fallback in non-git directory
  • TestGetBinaryPath_EnvOverride — verifies PATH_BIN takes priority
  • TestGetBinaryPath_GitRoot — verifies git root detection still works
  • Existing test suite passes

🤖 Generated with Claude Code

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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ErrNoBinaryPath error 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Check os.Getwd and os.Chdir errors consistently across all tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

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 fentas merged commit 6b2b30f into main Feb 14, 2026
7 checks passed
@fentas fentas deleted the fix/install-without-git-repo branch February 14, 2026 17:38
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).
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.

b install fails without git repo or envs

2 participants