Skip to content

feat: Add conda as a managed tool with conda-spawn activation#116

Closed
mattkram wants to merge 23 commits into
mainfrom
feat/add-conda-tool
Closed

feat: Add conda as a managed tool with conda-spawn activation#116
mattkram wants to merge 23 commits into
mainfrom
feat/add-conda-tool

Conversation

@mattkram
Copy link
Copy Markdown
Collaborator

@mattkram mattkram commented Apr 16, 2026

Note

This is a work in progress, reflecting technical evaluation of an experimental upcoming feature.

Summary

This PR adds conda as a managed tool in ana, providing a lightweight alternative to traditional Miniconda/Anaconda installations. The implementation shares design philosophy with conda-express (cx) by Jannis Leidel.

Key Features

  • Conda as a managed tool: Install via ana tool install conda
  • Wrapper-based architecture: ana intercepts conda commands to provide a better experience
  • conda-spawn activation: Uses subshell-based activation (conda shell myenv) instead of traditional conda activate
  • shell alias: conda shell works as an alias for conda spawn (matching cx's UX)
  • Frozen base environment: Prevents accidental modification of the managed conda installation
  • Helpful error messages: Intercepts activate, deactivate, and init with guidance

Comparison with conda-express

Feature ana conda-express
Embedded lockfile
Rattler-based installation
conda-spawn activation
shell command alias
Frozen base environment
Intercepts activate/deactivate

Differences: ana is a multi-tool manager (conda, pixi, anaconda-cli) while cx is conda-only. ana defaults to Anaconda's main channel; cx defaults to conda-forge.

Changes

  • Add conda tool specification with lockfile
  • Add conda wrapper module that:
    • Intercepts activate/deactivate/init with helpful messages
    • Aliases shellspawn for cx-compatible UX
    • Filters create output to show conda-spawn instructions
    • Passes through all other commands
  • Add .condarc with Anaconda channel defaults
  • Add frozen marker to prevent base environment modification
  • Add comprehensive integration tests
  • Add documentation comparing ana's conda with conda-express

Usage

# Install conda
ana tool install conda

# Create an environment
conda create -n myenv python=3.12 -y

# Activate (subshell-based)
conda shell myenv

# Exit the environment
exit

Test Plan

  • ana tool install conda installs conda successfully
  • conda --version works via wrapper
  • conda activate shows helpful error pointing to conda shell
  • conda shell myenv spawns a subshell (alias for conda spawn)
  • conda init shows helpful message
  • conda create output is filtered to show spawn instructions
  • Base environment is frozen

Documentation

Added docs/conda.md explaining the conda integration and comparing it with conda-express.

@mattkram mattkram changed the base branch from main to feat/add-pixi-tool April 16, 2026 19:01
@github-actions github-actions Bot added the feat New feature label Apr 16, 2026
@mattkram mattkram changed the title feat: POC installation of conda-based distribution as a tool feat: Add conda as a managed tool with conda-spawn activation Apr 16, 2026
Base automatically changed from feat/add-pixi-tool to main April 16, 2026 20:01
@mattkram mattkram force-pushed the feat/add-conda-tool branch 3 times, most recently from 3291ac6 to 430cd55 Compare April 17, 2026 21:55
@marcoesters marcoesters force-pushed the feat/add-conda-tool branch from bb3b66f to 5c2e03b Compare May 8, 2026 21:53
@mattkram mattkram force-pushed the feat/add-conda-tool branch from f6c804d to 6120112 Compare June 3, 2026 14:33
mattkram and others added 17 commits June 3, 2026 10:28
feat: Add additional conda plugins, based on miniconda
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update ana_binary fixture to look for ana.exe on Windows
- Update conda_wrapper fixture to use conda.exe on Windows
- Skip conda wrapper tests when ana_binary is not found

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The create_wrapper_symlink function was not using paths::binary_name()
to add the .exe extension on Windows, causing the conda wrapper
symlink to be created without the extension.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update conda_wrapper to use specs module after rename
- Remove useless .into() conversion in cli.rs
- Allow dead_code for make_download_client (future use)
- Replace 3.14 with 1.5 in tests to avoid approx_constant lint
- Use is_some_and instead of map_or in spool.rs
- Mark conda tool as experimental in specs
- Show styled warning on install with highlighted commands
- Update design doc with experimental status section
Switch from exec() to spawn+wait on Unix so we can intercept exit codes.
When conda exits non-zero, show a hint to report issues via ana self feedback.
The constraint was likely added to avoid a deprecation warning but is
no longer necessary.
@mattkram mattkram force-pushed the feat/add-conda-tool branch from bcb02d8 to ad3b63c Compare June 3, 2026 15:28
mattkram added 3 commits June 3, 2026 10:44
Instead of having ana detect when it's invoked as "conda" via symlink,
we now compile a standalone wrapper binary (src/wrappers/conda.rs) that
gets embedded into ana and written to ~/.ana/bin/conda on install.

Benefits:
- Cleaner separation of concerns
- Same approach on all platforms
- Wrapper is self-contained and independently testable
- No need for ana to detect invocation context

The wrapper binary is ~500KB and includes all the conda-spawn UX:
- Intercepts activate/deactivate/init with helpful messages
- Aliases shell -> spawn
- Filters create output to show spawn instructions
- Shows feedback hint on errors
- Remove incorrect CEP 22 reference for conda-spawn (no CEP exists for it)
- Fix CEP 22 URL to use correct zero-padded format (cep-0022.md)
- CEP 22 is about frozen environments, not conda-spawn
mattkram added 3 commits June 3, 2026 12:03
Document what we would need from conda-express to use it as a foundation:
- Customizable installation paths
- Custom .condarc support
- Custom lockfile support
- Wrapper customization

Also clarify wrapper differences and current implementation gaps.
Remove outdated docs/conda.md (had stale info about symlink approach).
Add troubleshooting section and references to the design doc.
@mattkram
Copy link
Copy Markdown
Collaborator Author

mattkram commented Jun 3, 2026

Closing to minimize CI churn, as the technical approach is further evaluated.

@mattkram mattkram closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants