Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 9, 2025

This PR fixes an issue where PET fails to discover the base conda environment when conda is installed via Homebrew cask on macOS.

Problem

Users with conda installed via Homebrew cask (e.g., brew install --cask miniforge) were experiencing missing base conda environments in VS Code's Python interpreter selection. The conda manager was detected correctly, but the base environment was not discovered.

Example of the issue:

# PET output showing missing base environment
% ./pet
Manager (Conda)
   Executable  : /opt/homebrew/Caskroom/miniforge/base/bin/conda
   Version     : 24.11.2

Environment (Conda)
   Name        : test
   # Base environment missing here

Root Cause

The conda locator in get_known_conda_install_locations() was only searching for conda installations in standard Homebrew paths like:

  • /opt/homebrew/anaconda3
  • /opt/homebrew/miniconda3
  • /opt/homebrew/miniforge3

However, Homebrew cask installations place conda in the Caskroom subdirectory:

  • /opt/homebrew/Caskroom/miniforge/base
  • /opt/homebrew/Caskroom/miniconda/base
  • /opt/homebrew/Caskroom/anaconda/base

These paths were not included in the search locations, causing the base environments to be missed.

Solution

Added the missing Homebrew Caskroom paths to the known conda install locations for macOS:

// Homebrew cask installations are in the Caskroom subdirectory  
if prefix == PathBuf::from("/opt/homebrew") {
    known_paths.push(prefix.clone().join("Caskroom").join("miniforge").join("base"));
    known_paths.push(prefix.clone().join("Caskroom").join("miniconda").join("base"));
    known_paths.push(prefix.clone().join("Caskroom").join("anaconda").join("base"));
}

This ensures that PET will now discover conda base environments installed via Homebrew cask, while maintaining full compatibility with existing conda installations.

Testing

  • Added comprehensive test coverage for Homebrew Caskroom path discovery
  • Verified existing base environment detection tests continue to pass
  • Confirmed no regressions in other conda installation methods
  • Tested CLI functionality shows base environments are now properly discovered

Fixes #236.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] PET doesn't find the base Conda environment Fix: Add Homebrew Caskroom paths for conda base environment discovery Aug 9, 2025
@Copilot Copilot AI requested a review from DonJayamanne August 9, 2025 01:05
Copilot finished work on behalf of DonJayamanne August 9, 2025 01:05
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.

PET doesn't find the base Conda environment
2 participants