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

More informative error for non-existent package #609

Open
2 tasks done
wholtz opened this issue Feb 12, 2024 · 0 comments
Open
2 tasks done

More informative error for non-existent package #609

wholtz opened this issue Feb 12, 2024 · 0 comments

Comments

@wholtz
Copy link

wholtz commented Feb 12, 2024

Checklist

  • I added a descriptive title
  • I searched open requests and couldn't find a duplicate

What is the idea?

Currently, if I try to lock the following:

name: base
platforms:
  - linux-64
channels:
  - conda-forge
dependencies:
  - not-a-real-package

the output is:

$ conda-lock lock -f bad-name.yaml
Locking dependencies for ['linux-64']...
INFO:conda_lock.conda_solver:linux-64 using specs ['not-a-real-package']
Traceback (most recent call last):
  File "/Users/willholtz/.local/bin/conda-lock", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_lock.py", line 1402, in lock
    lock_func(
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_lock.py", line 1110, in run_lock
    make_lock_files(
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_lock.py", line 393, in make_lock_files
    fresh_lock_content = create_lockfile_from_spec(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_lock.py", line 836, in create_lockfile_from_spec
    deps = _solve_for_arch(
           ^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_lock.py", line 748, in _solve_for_arch
    conda_deps = solve_conda(
                 ^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_solver.py", line 160, in solve_conda
    dry_run_install = solve_specs_for_arch(
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_solver.py", line 396, in solve_specs_for_arch
    return _reconstruct_fetch_actions(conda, platform, dryrun_install)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/willholtz/.local/pipx/venvs/conda-lock/lib/python3.11/site-packages/conda_lock/conda_solver.py", line 252, in _reconstruct_fetch_actions
    if "LINK" not in dry_run_install["actions"]:
                     ~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'actions'

That error wasn't very helpful. I dropped into the python debugger, and then I could see:

(Pdb) dry_run_install["error"]
"PackagesNotFoundError: The following packages are not available from current channels:\n\n  - not-a-real-package\n\nCurrent channels:\n\n  - https://conda.anaconda.org/conda-forge\n  - file:///var/folders/qq/q46r86t55t382q18lcxtk2tw0000gp/T/tmpqf06wj8e\n\nTo search for alternate channels that may provide the conda package you're\nlooking for, navigate to\n\n    https://anaconda.org\n\nand use the search bar at the top of the page.\n"

Why is this needed?

Make it easier to realize that you made a typo in a package name.

What should happen?

Display dry_run_install["error"] to the user.

Additional Context

No response

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

No branches or pull requests

1 participant