rez icon indicating copy to clipboard operation
rez copied to clipboard

Rez env seems to mangle the PATH

Open czerouni opened this issue 1 year ago • 4 comments

We have been chasing something related to the PATH environment variable, which is seemingly manipulated in a non-obvious way as Rez sets up the environment. To create the simplest demonstration of this, I opened a fresh shell and printed the PATH variable. Then I ran rez env with no packages at all, and inspect the PATH - it has extra entries added, and has rearranged the order of others.

Environment

  • OS - rocky9
  • Rez version 3.1.1
  • Rez python version3.9.16

To Reproduce Here is the before and after.

Before

$ printenv PATH
/local/prod/laika/common/CURRENT/bin/python
/home/c/czerouni/.local/bin
/usr/share/Modules/bin
/usr/local/bin
/usr/bin
/bin
/sbin
/usr/local/sbin
/usr/sbin
/opt/puppetlabs/bin
/opt/puppetlabs/bin
/laika/dist/bin
/laika/dist/third_party/linux_rocky9_x86_64/rez/RELEASE/bin/rez
/opt/puppetlabs/bin

then

$ rez env
$ printenv PATH
/usr/share/Modules/bin
.
/laika/dist/third_party/linux_rocky9_x86_64/rez/RELEASE/bin/rez
/sbin
/usr/sbin
/usr/local/sbin
/opt/puppetlabs/bin
/bin
/usr/bin
/net/ent-prod.nfs.laika.com/ifs/laika/dist/third_party/linux_rocky9_x86_64/rez/v3.1.1/bin/rez

Expected behavior What I would expect is for the PATH to be identical to what it was before I ran rez env, because no packages were loaded that would modify it.

Actual behavior See the example. Notice that '.' is in the path, when it wasn't before, and that many of the paths have been reordered. And laika/dist/bin is missing completely.

czerouni avatar Dec 05 '24 03:12 czerouni

The value of some items in your rez-config will be important to inspect to provide any analysis, for example, parent_variables, resetting_variables, and rez_tools_visibility, as well as standard_system_paths. Better to share your config in its entirety, with anything you need anonymized just mangled/scrubbed.

maxnbk avatar Dec 05 '24 16:12 maxnbk

Makes sense. Here it is - it is 99.9% default values laika_rezconfig.txt

BTW, I tried this on CentOS-7 and it did the same thing, but differently - the PATH was messed up in different ways.

czerouni avatar Dec 05 '24 17:12 czerouni

Is there anything special in the package.py's for your implicit packages? e.g. your linux/arch/rocky/centos etc packages that are being used as your implicits? If so, perhaps do another rez-env PATH test, with --no-implicits and see if it's the same.

The first thing I can identify, is that the last entry in the "after" is correct because you have rez_tools_visibility = "append", so the rez tools will get added as the last thing, allowing you to use rez-tools inside your rez-env's.

maxnbk avatar Dec 06 '24 20:12 maxnbk

Hey. No, I checked that earlier - none of those implicit packages do anything - they don't even have a commands() section. And doing rez env --ni yields the same result as before.

czerouni avatar Dec 06 '24 22:12 czerouni