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

Windows Gitbash Support Fixes #1302 #1475

Open
wants to merge 124 commits into
base: main
Choose a base branch
from

Conversation

Jawabiscuit
Copy link

@Jawabiscuit Jawabiscuit commented Apr 21, 2023

Fixes #1302 by adding gitbash support.
Fixes #1321 with path normalization changes for shells.

Fixed

  • Rex code compilation
  • Executable file paths in rez-shell* context invoking scripts
  • Existing issue with rez bind python 2 on Windows
  • Existing issue where execute_shell contexts are being executed with the wrong shell when @per_available_shell() in unittests. See testing observations
  • Corner case with running unittests on Windows systems with WSL installed. I recommend setting path to bash.exe in system settings for best experience.
  • Existing issue (and partial fix implemented by Fix shebang and executable paths in gitbash #1364) with implicit requires string expansion in setenv
  • Existing encoding issue when building wiki locally with Python 3.7

Changed

  • Path normalization
    • Off by default
    • /A/b/c rex paths are normalized to /a/b/c in Gitbash
    • Prevent paths with mixed slashes and backslashes in all shells
    • Do not automatically normalize {root} or this.root
    • {root} or this.root provides the platform normalized canonical path
    • Revert Fix shebang and executable paths in gitbash #1364 filepath normalization changes in sourcecode.py which were too broad and not fixing any issues
  • Configuration
    • Make platform pathed and shell pathed vars distinct from one another
    • co-opt warn_shell_startup to enable shell setting validation and logging warnings or errors
    • global enable_path_normalization to turn off all normalization

Adds

  • bash-style #!/usr/bin/env bash style shebangs which are supported in gitbash, and gitbash can execute files with/without file ext much like Unix
  • cygpath emulation
    • Refactored rezplugins/shell/_utils/windows.py
    • cygpath.py and uncpath.py created to emulate cygpath
    • cygpath.py used specifically for gitbash path normalization
    • Better UNC and long path handling for gitbash
  • Configuration
    • shell_pathed_env_vars, a per-shell pathed_env_vars setting
    • debug_shells to enable debug logging for all shells, includes path normalization messages
    • debug_cygpath to enable debug logging for the cygpath module
  • Rez bind
    • --py-script-mode and argument to bind added, see testing observations
  • Unittests
    • Similar to setting exclude on the per_available_shell decorator and to ease testing for a minimal number of available shells, enable use of a small list of included shells per test
    • Due to path normalization being disabled by default, and to keep shell tests DRY for gitbash, overriding the configuration on gitbash shell tests was added to the per_available_shell decorator with comment to remove if & when normalization is enabled by default
    • assertRaisesRegexp is used and mapped to assertRaisesRegex for backwards compatibility with Python 2
    • Many normalization / cygpath emulation tests
    • Shell tests
    • Shell e2e tests
    • Fixes some existing Windows unittests as well as most shell tests that were reporting false positives. It appeared to have been assumed that, in unittests when using the per_available_shell decorator, execute_shell would execute the intended shell when it was actually picking up the default system shell every time.
  • as_path and as_shell_path rex functions with as_shell_path(pathish, shell=bool). No time to implement, but works fine without this feature. I wouldn't mind taking a crack at it in a future PR b/c I do see its benefits.

Observations

Testing

  • Observed early on putting code into rezplugins/shell like cypath.py or uncpath.py causes issues when trying to test. The unittest structure for rez needs to be extended to handle plugin tests so plugin code can be encapsulated. I will break this out into a separate discussion.
  • Attempted to create a test that checked more specifically for spaces in executable paths breaking shell invoking scripts--one of the apparent root causes prompting #1302--but ran into inconsistencies running local vs CI. The tests run fine locally.
    • In my observation rez's backport of subprocess does not correctly capture stderr when the stdin option is used. I attempted a hack workaround using Python's builtin subprocess with the args of the return of rez's subprocess call which worked locally to catch the error but not on CI.
    • Most Windows shells failing to output expected paths on e2e shell tests but on Linux pwsh is the only one exhibiting the same problem.
  • On Windows, Python files can be executed with or without the py extension depending on the shell. Gitbash supports execution without the extension. For this reason, rez bind, which installs hello_world in many tests, was updated to support an additional --py-script-mode via the CLI and an additional argument to bind on the API side for unittests.
  • Most shell tests need to override the default_shell setting when @per_available_shell() is used so I modified the decorator to set this setting automatically thereby removing the necessity to state it in most shell tests.

Experience

  • Overall, my opinion here, the gitbash experience on Windows feels improved. Before the recent changes to normalization it was necessary to use gitbash's builtin cygpath to convert paths in build scripts embedded into package defs. This is no longer necessary, which feels more cross-platform capable, however more complicated build scripts outside of a package.py would likely not inherit all the benefits but to what extent remains to be tested.

Testing

How to Test/Enable

I recommend using the most recent version of Git for Windows, a backlog of features and fixes was added recently.

Git for Windows 2.41.0 comes with MSYS2 runtime (Git for Windows flavor) with all these improvements based on Cygwin 3.4.6.

  • Install gitbash
  • Clone the PR branch
  • Enable gitbash in the settings

The minimum viable settings required to enable gitbash:

default_shell = "gitbash"
enable_path_normalization = True

Logging Settings

Turn logging on to see normalization in action by setting the appropriate value in your rez config. Messages will print to the terminal as well as in temporary context files.

# Set this in gitbash if you need to see content of temporary context files
export REZ_KEEP_TMPDIRS=1

# Set for viewing messages in gitbash
debug_shells = True

# Print debugging info for the cygpath module
debug_cygpath = False

# Print warnings and errors useful for debugging
warn_shell_startup = True

# On windows, it's nice to set this as well
color_enabled = "force"

Path Normalization Settings

These are the most notable settings related to normalization. Please see rezconfig.py for more explicit documentation on each of these settings.

pathed_env_vars = [
    "*PATH"
]

env_var_separators = {
    "CMAKE_MODULE_PATH": ";",
    "DOXYGEN_TAGFILES": " ",
}

shell_pathed_env_vars = {
    "gitbash": [
        "PYTHONPATH",
        "CMAKE_MODULE_PATH",
    ]
}

# Path-like list variables in here will override those set in `env_var_separators`
shell_env_var_separators = {
    "gitbash": {
        "PATH": ":",
        "PYTHONPATH": ";",
    }
}

Resolved Context Execution

Here's a table of expected path modifications given the defaults above.

note var/method shell method path in path out
context.package_paths normalize_path c:\\Users\\jdoe\\src\\...\\packages /c/Users/jdoe/src/.../packages
[1] executor.rez_path normalize_path c:\\Users\\jdoe\\...\\rez /c/Users/jdoe/src/.../rez
executor.setenv.REZ_USED_PACKAGES_PATH normalize_path c:/Users/jdoe/src/.../packages /c/Users/jdoe/src/.../packages
[2] executor.setenv.REZ_PATH normalize_path c:\\Users\\jdoe\\...\\rez /c/Users/jdoe/src/.../rez
[3] resolved_package.base normalize_path c:\\users\\jdoe\\...\\1.0.0 /c/users/jdoe/src/.../1.0.0
[3] resolved_package.root normalize_path c:\\users\\jdoe\\...\\1.0.0 /c/users/jdoe/src/.../1.0.0
executor.setenv.REZ_SHELL_BASE normalize_path c:\\users\\jdoe\\...\\1.0.0 /c/Users/jdoe/src/.../1.0.0
executor.setenv.REZ_SHELL_ROOT normalize_path c:\\users\\jdoe\\...\\1.0.0 /c/Users/jdoe/src/.../1.0.0
[4] executor.globals.root as_path c:\\users\\jdoe\\...\\1.0.0 c:\\users\\jdoe\\...\\1.0.0
[5] executor.globals.base normalize_path c:\\users\\jdoe\\...\\1.0.0 /c/Users/jdoe/src/.../1.0.0
[6] [7] executor.append_system_paths normalize_paths C:\\Program Files\\git\\bin ${PATH}:/c/Program Files/git/bin
C:\\Python37 ${PATH}:/c/Python37
${PATH}:C:\\Windows ${PATH}:/c/Windows
${PATH}:C:\\Windows\\System32 ${PATH}:/c/Windows/System32
${PATH}:/mingw64/bin ${PATH}:/mingw64/bin
${PATH}:/usr/bin ${PATH}:/usr/bin
  1. The interpreter always normalizes path to rez
  2. If config.rez_1_environment_variables is set
  3. For each resolved package
  4. {root} variant binding, no normalization
  5. There are no code changes here, this path is still normalized i.e. posix-style in Gitbash
  6. fnmatch: *PATH
  7. pathsep used: :

Note that rex delegates normalization to the shell (interpreter), calling the appropriate method for the type of path or binding. All paths are normalized to POSIX-style paths, since those are expected when using Gitbash. Gitbash also understands mixed (C:/foo/bar and quoted "C:\foo\bar" paths) but the whole point of using Gitbash is to be able to use posix style paths wherever possible.

Source Code Execution

Now we investigate what we can we expect during execution of the package.py source code which is performed after the "binding and environment setup" steps above.

import os

env.PATH.append("{root}")
env.PYTHONPATH.append(os.path.join("{root}", "src"))
env.CMAKE_MODULE_PATH.append(os.path.join(this.root, "cmake"))

Given the above code block in commands() of a package definition, here's what we can expect.

var fnmatch pathsep shell method path in path out
env.PATH.append PATH : normalize_paths c:\\users\\jdoe\\src\\...\\1.0.0 /c/users/jdoe/src/.../1.0.0
env.PYTHONPATH.append PYTHONPATH ; as_shell_path c:\\users\\jdoe\\src\\...\\1.0.0\\src c:/users/jdoe/src/.../1.0.0/src
env.CMAKE_MODULE_PATH.append CMAKE_MODULE_PATH ; as_shell_path c:\\users\\jdoe\\src\\...\\1.0.0\\cmake c:/users/jdoe/src/.../1.0.0/cmake

Useful to note here, PATH is overridden to use : since that is what Gitbash expects; ; is used for PYTHONPATH and CMAKE_MODULE_PATH due to python and cmake being windows native apps that don't care what shell they are running in. Also, there's nothing technically wrong with setting CMAKE_MODULE_PATH or any other path-like variable in both env_var_separators as well as shell_env_var_separators, the latter will override the former. It can be assumed that the pathsep for PATH is usually os.pathsep so that is why it is being overridden for Gitbash in this case.

Effects of Normalization for Other Shells

Briefly, environment variables can be designated as "shell pathed" via the shell_pathed_env_vars setting but they must also implement any special logic in an as_shell_path method. Also the as_shell_path method is only used during execution of the package.py source code. Further customization needs to be handled by normalize_path or normalize_path[s] methods if necessary.

As they are today, cmd and powershell do not override their as_shell_path methods to do anything "special" and normalize_path does all the work normalizing paths and converting \s into /s. This is for better interoperability with more software like cmake and, unlike Gitbash, there is no need for normalization to be any more complex than that. If for some reason normalization this way becomes an issue then enable_path_normalization can be set to False. That should be a very unlikely occurrence since Windows shells have been able to interpret paths with mixed slashes since Windows 7.

Please see rezconfig.py for a more verbose explanation of the different ways and settings rez handles path normalization. Below are some examples of what to expect when path normalization is enabled in rez.

Resolved Context Execution

shell path from path to
cmd
powershell
pwsh
c:\\Users\\jdoe\\src\\package_a c:/Users/jdoe/src/package_a
cmd
powershell
pwsh
\\\\server\\projects\\sw\\dev\\jdoe\\packages //server/projects/sw/dev/jdoe/packages

Source Code Execution

shell var path from path to
cmd
powershell
pwsh
CMAKE_MODULE_PATH \\\\server\\projects\\...\\cmake;
\\\\server\\projects\\...\\Modules
//server/projects/.../cmake;
//server/projects/.../Modules

Known Issues

MSYS_NO_PATHCONV=1 seems to have no effect when using gitbash inside a rez-env context. Using that environment variable should inhibit gitbash from converting arguments to windows-style paths. Git for Windows version <=2.41.0 and winpty tested.

MSYS_NO_PATHCONV=1 python -c "import sys; print(sys.argv)" --dir=/tmp:/bla
['-c', '--dir=C:\\Users\\jonas\\AppData\\Local\\Temp;C:\\Program Files\\Git\\bla']

Questions

  • Should there be additional wiki content added and where?

Related PRs

#1364

🕶 Recommended reading

@Jawabiscuit Jawabiscuit changed the title Fixes #1302 Windows Gitbash Support Fixes #1302 Apr 21, 2023
@Jawabiscuit
Copy link
Author

I'm getting time in our next sprint starting next week to dive back in and get reoriented with the requirements of this PR, referencing #1364. I'll be working on other things as well, which is why it's a reorientation task. Also, I need to get familiarized a bit more with rez code and the details of unittesting. I'm optimistic I'll get to start on addressing the notes very soon.

@JeanChristopheMorinPerso
Copy link
Member

Thanks for the update @Jawabiscuit !

@Jawabiscuit
Copy link
Author

I'm running into a peculiar situation and I'm not sure the best way to resolve it for this PR. Help is appreciated. Here are my notes:

[!error]+

Traceback (most recent call last):
  File "/home/javrin/rez/2.112.0-pr-1475-test-0/local/lib/python2.7/site-packages/rez/tests/test_shell_utils.py", line 59, in test_path_conversion_unix_forced_fwdslash
    converted_path = convert_path(test_path, 'unix', force_fwdslash=True)
  File "/home/javrin/rez/2.112.0-pr-1475-test-0/local/lib/python2.7/site-packages/rezplugins/shell/_utils/windows.py", line 43, in convert_path
    path = _env_var_regex.sub(_repl, path)
AttributeError: 'NoneType' object has no attribute 'sub'
  • rez selftest failure on Ubuntu
    • Shell: bash
    • Errors are coming from test_shell_utils.py
    • Doesn't reproduce if running unittest like I would a normal python package in VSCode
      • Python: Configure Tests -> unittest -> with "tests" or "src" directory and "test_*.py" test discovery
    • Doesn't reproduce if I run rez selftest --shell_utils
      • This is because an upstream test is provoking the error
      • I did a binary search to figure the offender. It made sense after I found it that it was test_plugin_manager.py
    • Problem is coming from test_plugin_manager.py and _reset_plugin_manager
      • _reset_plugin_manager runs on test case construction, setup, and teardown and deletes rezplugin modules from sys path
      • If I comment the del sys.modules[key] line in _reset_plugin_manager the testing errors downstream in test_shell_utils.py go away
      • If I run the tests in this order ['rez.tests.test_release', 'rez.tests.test_plugin_manager', 'rez.tests.test_shell_utils'] the problem also clears itself up
        • The normal alphabetical order is ['rez.tests.test_plugin_manager', 'rez.tests.test_release', 'rez.tests.test_shell_utils']
        • I modified run_unittest in selftest.py to binary search (see below), adding that block and switching the test order should reproduce what I'm seeing
      • Manipulating _reset_plugin_manager so that sys modules do not get deleted after the last test runs, only surfaces another error in rez.tests.test_release
        • AttributeError: type object 'MemoryPackageRepository' has no attribute 'create_repository' (in shell 'sh')

[!example]+ selftest.py

    argv = [argv[0]] + [
        'rez.tests.test_e2e_shells',
        'rez.tests.test_release',
        'rez.tests.test_plugin_manager',
        'rez.tests.test_shell_utils'
    ]
    main(module=None, argv=argv, verbosity=verbosity)

@JeanChristopheMorinPerso @davidlatwe

@davidlatwe
Copy link
Contributor

davidlatwe commented May 16, 2023

Hey @Jawabiscuit ,

Yeah that del sys.modules[key] indeed is dangerous. Can't remeber why I did such thing, sorry. 😅

Manipulating _reset_plugin_manager so that sys modules do not get deleted after the last test runs, only surfaces another error in rez.tests.test_release

Hm, I think that's because this plugin-manager testcase is loading a fake memory repository from testing data. And when the teardown function doesn't do cleanup, test_release is getting that fake instance.

We should have another PR to address this test module, each test case should be loading fake plugins which are named in a way that are safe to be deleted from sys.modules when the test is finished, e.g. package_repository/dum.

That said, why it's not falling on CI?


Edit

I think I've got the idea why I did that del sys.modules[key] in test. Need to verify but plugin manager should be able to load (re-import) requested plugin when it's not in sys.module.

And in your test_shell_utils.py, you are importing that convert_path function from rezplugins.shell._utils which is an internal helper that are not meant to be exposed.

We should keep in mind that, rezplugin.* can only works as a plugin, not also being a library. Does that make sense?

As for should we do del sys.modules[key] in test? I am not sure, need to get more familiar with the underlaying code and doing some tests. 💦

@Jawabiscuit
Copy link
Author

Jawabiscuit commented May 16, 2023

Hey @davidlatwe, thanks for responding. Yeah, I'm anticipating there being issues when CI is run in this repo. I'm seeing it come up in my repo https://github.com/Jawabiscuit/rez/actions/runs/4981272972/jobs/8915311256. I'm new with GH actions, for instance I don't know why now it's saying awaiting maintainer approval. It's possible I'm seeing something that might not occur in the ASWF repo but I am able to reproduce it so I thought it's probably worth looking into.

I was thinking the same thing about the import for rezplugin as well. Do you have an opinion as to how rezplugins.shell._utils.windows gets brought in for testing? If not, I'll assume importlib should be used. Oh, and keep in mind I didn't write the tests for test_shell_utils. Thanks!

@JeanChristopheMorinPerso
Copy link
Member

I don't know why now it's saying awaiting maintainer approval.

That's because we've configured GitHub to not run CI for first time contributors unless we manually approve it. I've been approving the workflows all this time in the background without you noticing. I'm usually pretty quick, but today was a pretty busy day.

@Jawabiscuit
Copy link
Author

Jawabiscuit commented May 16, 2023

Oh, thanks @JeanChristopheMorinPerso , you were so fast I though it was automated! And sure enough... E AttributeError: 'NoneType' object has no attribute 'sub' :)

@JeanChristopheMorinPerso
Copy link
Member

Hehe. I just approved them. FYI, we do this because someone could open PRs to do crypto mining, or just put a super long sleep and it would waste some precious build minutes and it would monopolize the agents. We have access to 100 parallel workflows at the organization level, which means someone could do crypto mining on 100 workers for multiple hours (or until we notice it).

So in general, it's better to disable automatic triggers for first time contributors. And I actually think that it's configured like this by default when you create a repo nowadays.

@davidlatwe
Copy link
Contributor

davidlatwe commented May 17, 2023

👋🏼 @Jawabiscuit

Do you have an opinion as to how rezplugins.shell._utils.windows gets brought in for testing?

Just my 2 cents, I would either directly test with a real shell like this test_shell.py :: test_disabled_path_normalization(), or move that function into rez.utils and test it in here.

Oh, and keep in mind I didn't write the tests for test_shell_utils.

Ah sorry, didn't notice that and no mean to finger-pointing! 🤗

@Jawabiscuit
Copy link
Author

JC, cool I have no quams with that. David, thanks, I will do something similar to what you are suggesting.

Tangentially, I think this little issue reveals how tests and plugin code are not as isolated as they should could be. In attempts to keep the PR on track, I think if I get the chance I'm feeling inspired to create a discussion to layout a proposal for structural improvements to get some feedback from contributers. I'll look more into if there are similar discussions and through the history of plugins and tests for shells in the meantime. I don't want to spark too much conversation around that subject here.

Copy link
Member

@JeanChristopheMorinPerso JeanChristopheMorinPerso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I transferred the comments from the previous PRs and added new ones.

# as a result of both the shell and the settings in "pathed_env_vars" and
# "shell_pathed_env_vars". This is meant to aid in debugging and should be
# False unless needed.
disable_normalization = False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I remember, we initially said we want it to be off by default. So I'd rename it enable_path_normalization and set the value to False.

@@ -534,6 +534,19 @@
"*PATH"
]

# Some shells may require multiple types of pathing, so this option provides

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be clarified and simplified. In its current form, it's kind of hard to understand what it really does.

# Some shells may require multiple types of pathing, so this option provides
# a way to define variables on a per-shell basis to convert for shell pathing
# instead of the pathing provided above or no modification at all.
shell_pathed_env_vars = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe env_vars_to_convert or something like that?

@@ -433,7 +472,7 @@ def _create_ex():
assert self.rcfile_arg
shell_command = "%s %s" % (self.executable, self.rcfile_arg)
else:
shell_command = self.executable
shell_command = '"{}"'.format(self.executable)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, is the double quotes required or it could be single quotes? Single quote are safer because they are not evaluated.

def test_path_conversion_mixed(self):
"""Test the path conversion to mixed style."""
test_path = r'C:\foo\bar\spam'
converted_path = convert_path(test_path, 'unix')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From @jasoncscott: Isn't this the same test as the previous one? Should it be testing mixed?

@@ -130,13 +143,17 @@ def escape_string(self, value, is_path=False):
if not txt.startswith("'"):
txt = "'%s'" % txt
else:
if is_path:
if is_shell_path:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between a path and a shell path? I'm not sure to understand the difference just by looking at this code and without looking inside the functions that are called.

src/rez/rex.py Outdated
@@ -571,6 +586,16 @@ def escape_string(self, value, is_path=False):
def _is_pathed_key(cls, key):
return any(fnmatch(key, x) for x in config.pathed_env_vars)

@classmethod
def _is_shell_pathed_key(cls, key):
shell_name = cls.name() if hasattr(cls, 'name') else ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case would name not be present?

src/rez/rex.py Outdated
@@ -590,13 +615,15 @@ def normalize_path(self, path):
Returns:
str: The normalized path.
"""
print_debug("ActionInterpreter normalize_path()")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these stay or they were purely added for local development purposes?

if config.disable_normalization:
return path

# TODO: Is this necessary?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it? I personally don't know without taking a deeper look.

converted_path = convert_path(path, 'windows')

if path != converted_path:
self._addline("REM normalized path: {!r} -> {}".format(path, converted_path))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you log too?

@Jawabiscuit Jawabiscuit force-pushed the fixes_#1302 branch 13 times, most recently from 993f3e2 to 15ac508 Compare June 16, 2023 23:23
@Jawabiscuit
Copy link
Author

Hey @JeanChristopheMorinPerso my goal this week is to mark this PR ready for review. I'm finishing up e2e unittests and documentation is the final task on my list. I'll give a thorough breakdown when I change the PR status. That said, we seem to be confronting EoL for python-2 in the images we're using for testing so now the CI is breaking, see also actions/setup-python#672

@Jawabiscuit Jawabiscuit force-pushed the fixes_#1302 branch 2 times, most recently from 497d526 to 4a21b7a Compare June 22, 2023 17:20
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
…ly fixes the issue in cmd shell.

Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
@JeanChristopheMorinPerso
Copy link
Member

I took the liberty to merge the main brain in this PR to make sure that it's up to date. Tests are passing (even with the new refactored CI setup).

I had to do some debugging though, and noticed that the gitbash tests absolutely need enable_path_normalization to be set to True to pass. I'm not sure if we should be concerned by this or not since they were perfectly working before. See https://github.com/AcademySoftwareFoundation/rez/actions/runs/7679895882 (which contains the fix to make sure that shells are really tested).

@Dennis-Lehmann
Copy link

As requested by @JeanChristopheMorinPerso I'm reposting my comment from #1617 here.

I can confirm that the changes introduced in this PR fully address the mentioned issues.

But there seems to be a remaining issue utilizing the gitbash shell. (See further down below)

Conclusion

The error message now provides the path to the exe:

18:09:10 WARNING  Git-bash executable has been detected at c:\windows\system32\bash.exe, but this is probably not correct (google Windows Subsystem for Linux). Consider adjusting your searchpath, or use rez config setting plugins.shell.gitbash.executable_fullpath.

Also setting up a .rezconfig.py with the following content, gets rid of the warning:

plugins = {
    "shell": {
        "gitbash": {
            "executable_fullpath": R"C:\Program Files\Git\bin\bash.exe",
        }
    }
}

⚠️ The path to bash.exe is properly resolved, though requesting an empty environment using the gitbash shell results in the following issue:

PS C:\Users\Dennis> rez env --shell gitbash

You are now in a rez-configured environment.

bash: rezolve: command not found
>
Dennis@COMPUTER MINGW64 /c/Users/Dennis
$ 

Rez also is not available in that environment

[...]
Dennis@COMPUTER MINGW64 /c/Users/Dennis
$ rez -h
bash: rez: command not found
>
Dennis@COMPUTER MINGW64 /c/Users/Dennis
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:windows Windows-specific run-benchmarks Add this label to a PR to run the benchmarks shell Shell related issues
Projects
None yet
5 participants