Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not assume channels are always supplied #256

Merged
merged 2 commits into from
Aug 10, 2023
Merged

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Aug 10, 2023

Description

This command

$ conda create -n unused --dry-run --override-channels -c local python

will make conda-libmamba-solver crash with:

    Traceback (most recent call last):
      File "/opt/conda-src/conda/exception_handler.py", line 17, in __call__
        return func(*args, **kwargs)
      File "/opt/conda-src/conda/cli/main.py", line 64, in main_subshell
        exit_code = do_call(args, parser)
      File "/opt/conda-src/conda/cli/conda_argparse.py", line 167, in do_call
        result = getattr(module, func_name)(args, parser)
      File "/opt/conda-src/conda/notices/core.py", line 124, in wrapper
        return func(*args, **kwargs)
      File "/opt/conda-src/conda/cli/main_create.py", line 50, in execute
        install(args, parser, "create")
      File "/opt/conda-src/conda/cli/install.py", line 316, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "/opt/conda-src/conda/core/solve.py", line 154, in solve_for_transaction
        unlink_precs, link_precs = self.solve_for_diff(
      File "/opt/conda-src/conda/core/solve.py", line 215, in solve_for_diff
        final_precs = self.solve_final_state(
      File "/opt/conda-libmamba-solver-src/conda_libmamba_solver/solver.py", line 199, in solve_final_state
        index = IndexHelper(
      File "/opt/conda-libmamba-solver-src/conda_libmamba_solver/index.py", line 125, in __init__
        self._index = self._load_channels()
      File "/opt/conda-libmamba-solver-src/conda_libmamba_solver/index.py", line 285, in _load_channels
        set_channel_priorities(index)
      File "/opt/conda-libmamba-solver-src/conda_libmamba_solver/mamba_utils.py", line 52, in set_channel_priorities
        current_channel = next(iter(index.values())).channel.canonical_name
    StopIteration

because we assume index will always be populated, but it's not in this case.

The fix is to return index early if empty, and we obtain the desired behaviour:

Channels:
 - local
Platform: linux-aarch64
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - python

Current channels:

  - local

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

This was detected in conda/conda#12984

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Aug 10, 2023
@jaimergp
Copy link
Contributor Author

Failures are unrelated (see #242 and conda/conda#12986).

Ready for review @costrouc!

Copy link
Contributor

@costrouc costrouc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jaimergp jaimergp merged commit 311e5fb into main Aug 10, 2023
57 of 71 checks passed
@jaimergp jaimergp added this to the September 2023 release milestone Sep 25, 2023
@jaimergp jaimergp deleted the dont-assume-channels branch November 7, 2023 10:25
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Nov 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants