Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions src/runtimes/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,25 +359,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 2. Check common installation locations
locations := getNodeInstallLocations()
for _, loc := range locations {
if _, err := os.Stat(loc); err == nil {
if version, err := getNodeVersion(loc); err == nil {
if !seen[loc] {
detected = append(detected, runtime.DetectedVersion{
Version: version,
Path: loc,
Source: "system",
Validated: true,
})
seen[loc] = true
}
}
}
}

// 3. Check nvm installations
// 2. Check nvm installations
nvmVersions := findNvmVersions()
for _, dv := range nvmVersions {
if !seen[dv.Path] {
Expand All @@ -386,7 +368,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 4. Check fnm installations
// 3. Check fnm installations
fnmVersions := findFnmVersions()
for _, dv := range fnmVersions {
if !seen[dv.Path] {
Expand All @@ -413,34 +395,6 @@ func getNodeVersion(nodePath string) (string, error) {
return version, nil
}

// getNodeInstallLocations returns common Node.js installation paths
func getNodeInstallLocations() []string {
home, _ := os.UserHomeDir()

locations := []string{
// Windows
`C:\Program Files\nodejs\node.exe`,
`C:\Program Files (x86)\nodejs\node.exe`,

// macOS (Homebrew)
"/usr/local/bin/node",
"/opt/homebrew/bin/node",

// Linux
"/usr/bin/node",
"/usr/local/bin/node",
}

// Add user-specific locations
if home != "" {
locations = append(locations,
filepath.Join(home, ".local", "bin", "node"),
)
}

return locations
}

// findNvmVersions scans nvm directory for installed versions
func findNvmVersions() []runtime.DetectedVersion {
detected := make([]runtime.DetectedVersion, 0)
Expand Down
63 changes: 1 addition & 62 deletions src/runtimes/python/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,25 +575,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 2. Check common installation locations
locations := getPythonInstallLocations()
for _, loc := range locations {
if _, err := os.Stat(loc); err == nil {
if version, err := getPythonVersion(loc); err == nil {
if !seen[loc] {
detected = append(detected, runtime.DetectedVersion{
Version: version,
Path: loc,
Source: "system",
Validated: true,
})
seen[loc] = true
}
}
}
}

// 3. Check pyenv installations
// 2. Check pyenv installations
pyenvVersions := findPyenvVersions()
for _, dv := range pyenvVersions {
if !seen[dv.Path] {
Expand Down Expand Up @@ -624,49 +606,6 @@ func getPythonVersion(pythonPath string) (string, error) {
return "", fmt.Errorf("could not parse Python version from: %s", version)
}

// getPythonInstallLocations returns common Python installation paths
func getPythonInstallLocations() []string {
home, _ := os.UserHomeDir()

locations := []string{
// Windows - check multiple Python versions
`C:\Python311\python.exe`,
`C:\Python310\python.exe`,
`C:\Python39\python.exe`,
`C:\Python38\python.exe`,
`C:\Python37\python.exe`,

// macOS (Homebrew and system)
"/usr/local/bin/python3",
"/opt/homebrew/bin/python3",
"/usr/bin/python3",

// Linux
"/usr/bin/python3",
"/usr/local/bin/python3",
}

// Windows - check LocalAppData\Programs\Python
if home != "" {
pythonLocalDir := filepath.Join(home, "AppData", "Local", "Programs", "Python")
if entries, err := os.ReadDir(pythonLocalDir); err == nil {
for _, entry := range entries {
if entry.IsDir() {
pythonExe := filepath.Join(pythonLocalDir, entry.Name(), "python.exe")
locations = append(locations, pythonExe)
}
}
}

// macOS/Linux user installs
locations = append(locations,
filepath.Join(home, ".local", "bin", "python3"),
)
}

return locations
}

// findPyenvVersions scans pyenv directory for installed versions
func findPyenvVersions() []runtime.DetectedVersion {
detected := make([]runtime.DetectedVersion, 0)
Expand Down
55 changes: 3 additions & 52 deletions src/runtimes/ruby/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,25 +572,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 2. Check common installation locations
locations := getRubyInstallLocations()
for _, loc := range locations {
if _, err := os.Stat(loc); err == nil {
if version, err := getRubyVersion(loc); err == nil {
if !seen[loc] {
detected = append(detected, runtime.DetectedVersion{
Version: version,
Path: loc,
Source: "system",
Validated: true,
})
seen[loc] = true
}
}
}
}

// 3. Check rbenv installations
// 2. Check rbenv installations
rbenvVersions := findRbenvVersions()
for _, dv := range rbenvVersions {
if !seen[dv.Path] {
Expand All @@ -599,7 +581,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 4. Check rvm installations
// 3. Check rvm installations
rvmVersions := findRvmVersions()
for _, dv := range rvmVersions {
if !seen[dv.Path] {
Expand All @@ -608,7 +590,7 @@ func (p *Provider) DetectInstalled() ([]runtime.DetectedVersion, error) {
}
}

// 5. Check chruby installations
// 4. Check chruby installations
chrubyVersions := findChrubyVersions()
for _, dv := range chrubyVersions {
if !seen[dv.Path] {
Expand Down Expand Up @@ -639,37 +621,6 @@ func getRubyVersion(rubyPath string) (string, error) {
return "", fmt.Errorf("could not parse Ruby version from: %s", version)
}

// getRubyInstallLocations returns common Ruby installation paths
func getRubyInstallLocations() []string {
home, _ := os.UserHomeDir()

locations := []string{
// Windows
`C:\Ruby33-x64\bin\ruby.exe`,
`C:\Ruby32-x64\bin\ruby.exe`,
`C:\Ruby31-x64\bin\ruby.exe`,
`C:\Ruby30-x64\bin\ruby.exe`,

// macOS (Homebrew and system)
"/usr/local/bin/ruby",
"/opt/homebrew/bin/ruby",
"/usr/bin/ruby",

// Linux
"/usr/bin/ruby",
"/usr/local/bin/ruby",
}

// Add user-specific locations
if home != "" {
locations = append(locations,
filepath.Join(home, ".local", "bin", "ruby"),
)
}

return locations
}

// findRbenvVersions scans rbenv directory for installed versions
func findRbenvVersions() []runtime.DetectedVersion {
detected := make([]runtime.DetectedVersion, 0)
Expand Down