AcademySoftwareFoundation / rez

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

'use_variant_shortlinks' config entry ignore by rez-cp #1701

Open garrett-wbpa opened 6 months ago

garrett-wbpa commented 6 months ago

Hello,

I've disabled variant shortlinks for my windows machine using a rez config json file. I went to rez-cp a package to my repository and noticed that rez-cp was still trying to create a _v shortlink folder. It fails due to permissions, but rez-cp continues on and copies the full variant folder anwyay.

Environment

To Reproduce

  1. set 'use_variant_shortlinks=false' in a rez config file
  2. rez-cp a package into a repository and see that a shortlink folder is still created.

Expected behavior I expect rez-cp to skip the shortlink creation when the config specifies to do so.

Actual behavior A _v folder is created even though my config is disabling them.

JeanChristopheMorinPerso commented 6 months ago

I've disabled variant shortlinks for my windows machine using a rez config json file

We don't support JSON config files. Is it a typo?

garrett-wbpa commented 6 months ago

I definitely saved my file as .json, but I suspect it was loaded by PyYAML without me noticing. I've moved it to a .yaml.

This is the contents of the config file I was testing.

{
    "plugins": {
        "package_repository": {
            "filesystem": {
                "file_lock_type": "mkdir",
            }
        },
    },
    "use_variant_shortlinks":true,
    "use_pyside": true,
    "use_pyqt": false,
    "gui_threads": true
}

Edit: I confirmed that I can use a YAML loader to load this dict, even though it was user error on my part.

JeanChristopheMorinPerso commented 6 months ago

Just to be sure that your config is loaded properly, would you mind giving me the result of rez-config use_variant_shortlinks please?

garrett-wbpa commented 6 months ago

Good point. I've just now confirmed that rez-config use_variant_shortlinks returns False and re-run my repro steps with the same issue. Oddly, I get a string formatting error when trying to copy a package containing the symlinked short variants, but no issue when copying something simple like os.

REZ_CONFIG_FILE=/w/CREW/garrett.broussard/scripts/rez_config/rez_config_002.yaml rez-config use_variant_shortlinks
False
REZ_CONFIG_FILE=/w/CREW/garrett.broussard/scripts/rez_config/rez_config_002.yaml rez-cp --dest-path ~/wbpa/tmp/wbpa_001 --allow-empty pycue
Traceback (most recent call last):
  File "C:\Users\garrett\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\garrett\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\opt\rez\Scripts\rez\rez-cp.exe\__main__.py", line 7, in <module>
  File "c:\opt\rez\lib\site-packages\rez\cli\_entry_points.py", line 127, in run_rez_cp
    return run("cp")
  File "c:\opt\rez\lib\site-packages\rez\cli\_main.py", line 191, in run
    returncode = run_cmd()
  File "c:\opt\rez\lib\site-packages\rez\cli\_main.py", line 183, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "c:\opt\rez\lib\site-packages\rez\cli\cp.py", line 156, in command
    result = copy_package(
  File "c:\opt\rez\lib\site-packages\rez\package_copy.py", line 202, in copy_package
    _copy_variant_payload(
  File "c:\opt\rez\lib\site-packages\rez\package_copy.py", line 249, in _copy_variant_payload
    "Cannot copy source variant %s - its root does not appear to "
TypeError: not enough arguments for format string
JeanChristopheMorinPerso commented 4 months ago

Umm, that's an error in our code.

https://github.com/AcademySoftwareFoundation/rez/blob/a13f7bb362cbb05e73f88e9f771c36005c1e9f4a/src/rez/package_copy.py#L244-L247

If should be:

        raise PackageCopyError(
            "Cannot copy source variant %s - its root does not appear to "
            "be present on disk (%s)." % (src_variant.uri, variant_root)
        )