fix: clarify system-install doctor alias and shim path checks

Use UserBinDir for PATH checks and pass aliases as not required under
system install without treating that as active interception.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Sahilb315
2026-07-13 15:37:02 +05:30
co-authored by Cursor
parent ffd0e7e759
commit 8d1a4b60e1
3 changed files with 39 additions and 18 deletions
+19 -5
View File
@@ -48,8 +48,13 @@ func NewDefaultShimManager() (*ShimManager, error) {
return nil, err
}
binDir, err := UserBinDir()
if err != nil {
return nil, err
}
return &ShimManager{config: ShimConfig{
BinDir: filepath.Join(homeDir, ".pmg", "bin"),
BinDir: binDir,
HomeDir: homeDir,
PMGBin: pmgBin,
PackageManagers: aliasCfg.PackageManagers,
@@ -140,6 +145,15 @@ func (m *ShimManager) GetBinDir() string {
return m.config.BinDir
}
// UserBinDir returns the per-user PMG shim directory (~/.pmg/bin).
func UserBinDir() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
return filepath.Join(homeDir, ".pmg", "bin"), nil
}
func (m *ShimManager) writeShimScript(pm string) error {
shimPath := filepath.Join(m.config.BinDir, pm)
pmgBin := shellQuote(m.config.PMGBin)
@@ -236,12 +250,12 @@ func (m *ShimManager) removePathFromShells() error {
return nil
}
// UserShimsInstalled reports whether the per-user shim directory (~/.pmg/bin)
// contains at least one shim script.
// UserShimsInstalled reports whether the per-user shim directory contains at
// least one shim script.
func UserShimsInstalled() bool {
homeDir, err := os.UserHomeDir()
binDir, err := UserBinDir()
if err != nil {
return false
}
return shimsPresent(filepath.Join(homeDir, ".pmg", "bin"))
return shimsPresent(binDir)
}