Skip to content

Support conda repoquery depends for package dependency graph #379

@ktaletsk

Description

@ktaletsk

Summary

The package dependency graph feature currently requires mamba because it uses mamba repoquery depends --json <pkg>. However, recent versions of conda with conda-libmamba-solver now support the same repoquery depends command.

Background Research

Current Implementation

The pkg_depends method in envmanager.py previously checked is_mamba() and returned early if conda was detected:

if not self.is_mamba():
    self.log.warning(
        "Package manager '{}' does not support dependency query.".format(
            self.manager
        )
    )
    return {pkg: None}

Discovery: conda-libmamba-solver provides repoquery

According to the conda 25.x documentation:

Note: The conda repoquery depends command is provided by the conda-libmamba-solver.

This means users with conda-libmamba-solver installed can use:

conda repoquery depends --json <package>

The JSON output format is identical to mamba's output, making it a drop-in replacement.

Preliminary Fix (Tested Successfully)

We temporarily removed the is_mamba() check, allowing both mamba and conda to use repoquery depends. This was tested successfully in an environment with:

  • conda 24.11.3
  • conda-libmamba-solver installed

Both the package dependency graph visualization and environment listing work correctly.

Proposed Implementation

Option 1: Simple removal of mamba check (current temporary fix)

  • Pros: Simple, works for users with libmamba-solver
  • Cons: Will fail for users without libmamba-solver

Option 2: Try/catch with graceful fallback

async def pkg_depends(self, pkg: str) -> Dict[str, List[str]]:
    try:
        ans = await self._execute(self.manager, "repoquery", "depends", "--json", pkg)
        # ... process response
    except Exception:
        self.log.warning("repoquery not available. Install mamba or conda-libmamba-solver.")
        return {pkg: None}

Option 3: Explicit detection of repoquery support

  • Run conda repoquery --help or similar to detect availability
  • Cache the result like we do for manager detection

Tasks

  • Decide on implementation approach
  • Add proper error handling for environments without repoquery support
  • Update user-facing error message in PkgGraph.tsx to mention conda-libmamba-solver as alternative to mamba
  • Add tests for conda repoquery path
  • Update documentation

Related Files

  • mamba_gator/envmanager.py - pkg_depends() method
  • packages/common/src/components/PkgGraph.tsx - Frontend error message

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions