AcademySoftwareFoundation / rez

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

Different filesystem ownership in cache package creates PermissionError Exception #1530

Open cumulus-vfx opened 1 year ago

cumulus-vfx commented 1 year ago

Describe the bug here.

Environment

To Reproduce Run rez-env on a pkg when user does not have write perms on pkg cache json file Raised by os.utime function on pkg json file Caused when a different user is using a workstation, then the user that created the cache in the first place

Expected behavior Better to print warning instead of failure

Actual behavior Traceback (most recent call last):  File "/local_data/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/bin/rez/rez-env", line 8, in     sys.exit(run_rez_env())  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/cli/_entry_points.py", line 148, in run_rez_env    return run("env")  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/cli/_main.py", line 191, in run    returncode = run_cmd()  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/cli/_main.py", line 183, in run_cmd    return func(opts, opts.parser, extra_arg_groups)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/cli/env.py", line 261, in command    block=True)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/resolved_context.py", line 1045, in _check    return fn(self, *nargs, *kwargs)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/resolved_context.py", line 1431, in execute_shell    self._execute(executor)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/utils/memcached.py", line 271, in wrapper    return func(nargs, **kwargs)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/resolved_context.py", line 2014, in _execute    cached_root = pkgcache.get_cached_root(pkg)  File "/sw/pkg/rez/2.112.0/platform-linux/python-3.7.9/lib/python3.7/site-packages/rez/package_cache.py", line 110, in get_cached_root    os.utime(json_filepath, None) PermissionError: [Errno 13] Permission denied

JeanChristopheMorinPerso commented 1 year ago

Hi @cumulus-vfx , can you show us what permissions you see and what you would expect? Also, what is the value of your umask (just run umask and you'll see the value that is currently set).

cumulus-vfx commented 1 year ago

Hi Jean our umask is 0022 the default perms at creation on a json file of a cached package is rw-r-r

but I think that's beside the point, os.utime requires write permissions, as rez-env evaluates its pkgs and decides if to use cached packages, it should check if it has perms before trying to use os.utime and if not bail out and use the main repository pkg and not the cached pkg, and perhaps print a warning like it does when the cache directory don't exist.

Having it failure completely and not catching the exception is a problem