AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
945 stars 336 forks source link

rez tools visibility behavior not backwards compatible from 2.61.0 #1300

Open maxnbk opened 2 years ago

maxnbk commented 2 years ago

between 2.60.1 and 2.61.0 , src/rez/system.py changed it's determination of "whether to pass rez-tools along to the environment or not" from being a "is it which-able, to, "is the currently importable rez module also a production install".

This does not have to be the case, and makes sense not to be the case. In our production environment, we have a production install of rez tools exposed on the PATH, and a separate version of rez exposed as a module (via a package), and the module is not a production install, while the one on the PATH is.

When migrating our rez-tools versions to newer versions of rez, nothing changes, but when we migrate the package-version of rez to newer versions to 2.60.0+ , the module version of rez, when performing a solve, no longer exposes the rez tools from the PATH to the downstream resolved context.

This occurred here, although subsequent edits occur to expand the logic to lib64, etc. https://github.com/nerdvegas/rez/compare/2.60.1...2.61.0 "-update to system.rez_bin_path that is more reliable" (in ./src/rez/system.py)

Environment

To Reproduce

  1. Expose rez tools via PATH
  2. rez-env to an environment with a rez rez-package
  3. Use that rez-package's api to create a ResolvedContext and execute the shell
  4. After executing the shell, inspect the PATH and find that the rez-tools are no longer available.

More direct reproduction sample that can be bash-executed, provided you have a python-2 package, and the rez package-versions you want to inspect the reproduction for (Pardon the backslash hell, I wanted a oneliner):

[maxnbk@comp rez]$ REZ_KEEP_TMPDIRS=1 rez-env python-2 rez-2.109.0 -- bash -c "echo \$PATH; echo \$PYTHONPATH; python -c 'import rez; print(rez.__file__); from rez.resolved_context import ResolvedContext; rc = ResolvedContext(package_requests=[]); command=[\"/usr/bin/echo\", \"\\\$PATH\"]; from rez.system import System; print(System().rez_bin_path); rc.execute_shell(command=command)' "
/home/maxnbk/packages/python/2.7.18/_v/a/bin:/usr/local/bin:/usr/bin:/bin:/home/maxnbk/rez/bin/rez
/home/maxnbk/packages/rez/2.109.0/platform-linux/arch-x86_64/os-rocky-8.5/python-2.7
/home/maxnbk/packages/rez/2.109.0/platform-linux/arch-x86_64/os-rocky-8.5/python-2.7/rez/__init__.pyc
None
/usr/local/bin:/usr/bin:/bin # This line should look like the last line in this codeblock
[...]
[maxnbk@comp rez]$ REZ_KEEP_TMPDIRS=1 rez-env python-2 rez-2.60.1 -- bash -c "echo \$PATH; echo \$PYTHONPATH; python -c 'import rez; print(rez.__file__); from rez.resolved_context import ResolvedContext; rc = ResolvedContext(package_reque
sts=[]); command=[\"/usr/bin/echo\", \"\\\$PATH\"]; from rez.system import System; print(System().rez_bin_path); rc.execute_shell(command=command)' "
/home/maxnbk/packages/python/2.7.18/_v/a/bin:/usr/local/bin:/usr/bin:/bin:/home/maxnbk/rez/bin/rez
/home/maxnbk/packages/rez/2.60.1/platform-linux/arch-x86_64/os-rocky-8.5/python-2.7
/home/maxnbk/packages/rez/2.60.1/platform-linux/arch-x86_64/os-rocky-8.5/python-2.7/rez/__init__.pyc
/home/maxnbk/rez/bin/rez
/usr/local/bin:/usr/bin:/bin:/home/maxnbk/rez/bin/rez

Expected behavior I expect the rez-tools to still be available after the execution of the RC's shell.

Actual behavior They aren't.

Regression Bug did not occur in 2.60.1, although we were working from 2.52.1

maxnbk commented 2 years ago

Updated the reproduction information with a helpful oneliner to reproduce in bash, provided you have desired package-versions installed and/or tweak the resolve request according to what you have available.

nerdvegas commented 2 years ago

Yeah I think this regression is a pure logic fail! I figure we just didn't take into account the case where rez-as-rez-pkg should keep a separate production install of rez visible.