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

Fail to resolve env var default in git packages #12668

Closed
1 task done
ltrojan-ths opened this issue May 1, 2024 · 3 comments
Closed
1 task done

Fail to resolve env var default in git packages #12668

ltrojan-ths opened this issue May 1, 2024 · 3 comments
Labels
type: support User Support

Comments

@ltrojan-ths
Copy link

Description

Trying to add a default value to the git ref specified as an env var fails to parse the value correctly:

my-package @ git+ssh://git@github.com/my-repo.git@${PACKAGE_REF:-main}#subdirectory=package

will produce the following error:

(...)

Running command git clone --filter=blob:none --quiet 'ssh://****@github.com/my-repo.git /tmp/pip-install-7fi75vp9/my-package_12345


  WARNING: Did not find branch or tag '${PACKAGE_REF:-main}', assuming revision or ref.
  Running command git checkout -q '${PACKAGE_REF:-main}'
  error: pathspec '${PACKAGE_REF:-main}' did not match any file(s) known to git
  error: subprocess-exited-with-error
  
  × git checkout -q '${PACKAGE_REF:-main}' did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

the same happens regardless of whether the PACKAGE_REF is defined or not...

Expected behavior

the correct branch is checked out: master if PACKAGE_REF is not defined and $PACKAGE_REF if it is defined

pip version

24.0

Python version

Python 3.10.9 (pyenv/venv)

OS

Linux ltrojan-laptop 5.15.0-101-generic #111~20.04.1-Ubuntu SMP Mon Mar 11 15:44:43 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

How to Reproduce

  1. create and setup a repo (with a pyproject.toml and a source folder containing some basic python code)
  2. create a feature branch and adit the python code
  3. in a separate folder, create a requirements.txt
  4. add `py-package @ git+ssh://git@github.com/my-repo.git@${PACKAGE_REF:-main}#subdirectory=package
  5. ensure git can clone the repo (ssh keys are setup properly)
  6. run pip install -r requirements.txt
  7. run PACKAGE_REF=my-feature-branch pip install -r requirements.txt

Output

see above

Code of Conduct

@ltrojan-ths ltrojan-ths added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels May 1, 2024
@pfmoore
Copy link
Member

pfmoore commented May 1, 2024

The ${PACKAGE_REF:-main} syntax is specific to bash (and maybe some other shells?) It's not supported by pip, so it won't get interpreted correctly in a requirements file.

@pfmoore pfmoore added type: support User Support and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels May 1, 2024
@ltrojan-ths
Copy link
Author

ltrojan-ths commented May 1, 2024

@pfmoore thanks for the reply!

ok... i miss-read another issue from a couple of years ago'.. i thought the : and the :- notation were not bash specific...

is there another way to provide a default to an env var? the idea is that the env var should be set only in "special" occasions, in this particular case if one wants to try a new feature only being developed as a new feature branch...

@pfmoore
Copy link
Member

pfmoore commented May 1, 2024

Docs are here. No, there's no way to provide a default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support User Support
Projects
None yet
Development

No branches or pull requests

2 participants