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

pdm install --no-lock fails in the absence of lock file #2245

Closed
1 task done
deronnax opened this issue Sep 7, 2023 · 9 comments · Fixed by #2250
Closed
1 task done

pdm install --no-lock fails in the absence of lock file #2245

deronnax opened this issue Sep 7, 2023 · 9 comments · Fixed by #2250
Assignees
Labels
🐛 bug Something isn't working

Comments

@deronnax
Copy link
Contributor

deronnax commented Sep 7, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

Steps to reproduce

rm pdm.lock
pdm install --no-lock -v

Actual behavior

$ rm pdm.lock
$ pdm install --no-lock -v
Lock file does not exist
STATUS: Resolving packages from lockfile...
Traceback (most recent call last):
  File "/Users/mathieu/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 157, in handle
    command.handle(project, options)
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/commands/install.py", line 95, in handle
    actions.do_sync(
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/actions.py", line 197, in do_sync
    candidates = resolve_candidates_from_lockfile(project, requirements)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/actions.py", line 140, in resolve_candidates_from_lockfile
    mapping, *_ = resolve(
                  ^^^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/core.py", line 36, in resolve
    result = resolver.resolve(requirements, max_rounds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mathieu/.local/pipx/venvs/pdm/lib/python3.11/site-packages/resolvelib/resolvers.py", line 399, in resolve
    raise ResolutionImpossible(e.criterion.information)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=NamedRequirement(name='jinja2', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=False), parent=None)]

Expected behavior

install succeeds

Environment Information

 pdm info ; pdm info --env
PDM version:
  2.9.1
Python Interpreter:
  /Users/mathieu/.pyenv/versions/3.10.12/bin/python3 (3.10)
Project Root:
  /Users/mathieu/dev/ggcore
Local Packages:
  /Users/mathieu/dev/ggcore/__pypackages__/3.10
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.12",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "22.6.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 22.6.0: Wed Jul  5 22:17:35 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8112",
  "python_full_version": "3.10.12",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "darwin"
}

@deronnax deronnax added the 🐛 bug Something isn't working label Sep 7, 2023
@pawamoy
Copy link
Contributor

pawamoy commented Sep 7, 2023

--no-lock means don't generate/update a lock file before installing. Of course if there's no lock file it will fail. What else would you expect? :/

Unless I'm mistaken. The logs are indeed curious.

@deronnax
Copy link
Contributor Author

deronnax commented Sep 7, 2023

No, that's not what it means. The pdm install --help about --no-lock is clear:

  --no-lock             Don't do lock if the lock file is not found or outdated

@pawamoy
Copy link
Contributor

pawamoy commented Sep 7, 2023

Well yes.

  • you removed the lock file
  • you run pdm install --no-lock
  • lock file is not found
  • PDM does not lock (because of --no-lock)
  • so PDM can't install

PDM needs a lock file to install dependencies.

@frostming
Copy link
Collaborator

Oh, I almost forget there's a such option, i can't remember what the use case it's for.

@frostming
Copy link
Collaborator

it's looks pretty like pdm sync, maybe we should remove the option.

@pawamoy
Copy link
Contributor

pawamoy commented Sep 7, 2023

Hmmm I definitely don't think --no-lock should be removed. The use-case is clear: don't re-lock even if pyproject.toml changed. This allows faster build of Docker images for example, and ensures reproducibility. It gives users the choice of when to re-lock.

But yeah, if that's what pdm sync does, why not. I never use sync so I don't really know 🙂

@deronnax
Copy link
Contributor Author

deronnax commented Sep 7, 2023

Well yes.

  • you removed the lock file
  • you run pdm install --no-lock
  • lock file is not found
  • PDM does not lock (because of --no-lock)
  • so PDM can't install

PDM needs a lock file to install dependencies.

It doesn't make sense: the help message clearly says the command will go on and do without the lock file. But then crash because of the absence of lock file.
Or the help message is wrong and does not describe the intended bebaviour. But I doubt it. Pipenv has the same option and does the expected behavior: it does the installation without relying on a lock file (yes it generates a lock file internally for its own one-time usage but that's an implementation detail).
It matters because we are currently migrating a number of our libraries from Pipenv to PDM and our libraries' CIs use and reliy on --no-lock.

@pawamoy
Copy link
Contributor

pawamoy commented Sep 7, 2023

I guess you interpreted the help message based on your own experience with Pipenv, and I interpreted it without it. To me the message is clear too, and the result expected (error), but not for you 🙂 That's fine of course, PDM and Pipenv work differently. Maybe @frostming will be interested in adding such functionality (internal lock data for one time installs without generating lock files).

@deronnax
Copy link
Contributor Author

deronnax commented Sep 7, 2023

OK I won't lose any more time arguing.
@frostming would you be interested implementing it? We would definitely use it (I am sure other would too).

@frostming frostming self-assigned this Sep 11, 2023
frostming added a commit that referenced this issue Sep 11, 2023
Fixes #2245

Signed-off-by: Frost Ming <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants