-
Notifications
You must be signed in to change notification settings - Fork 991
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
automatically add msys2/usr/bin path #12457
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,10 +75,18 @@ def _windows_bash_wrapper(conanfile, command, env, envfiles_folder): | |
# Configure MSYS2 to inherith the PATH | ||
msys2_mode_env = Environment() | ||
_msystem = {"x86": "MINGW32"}.get(conanfile.settings.get_safe("arch"), "MINGW64") | ||
# https://www.msys2.org/wiki/Launchers/ dictates that the shell should be launched with | ||
# - MSYSTEM defined | ||
# - CHERE_INVOKING is necessary to keep the CWD and not change automatically to the user home | ||
msys2_mode_env.define("MSYSTEM", _msystem) | ||
msys2_mode_env.define("MSYS2_PATH_TYPE", "inherit") | ||
# So --login do not change automatically to the user home | ||
msys2_mode_env.define("CHERE_INVOKING", "1") | ||
path = os.path.join(conanfile.generators_folder, "msys2_mode.bat") | ||
# Make sure we save pure .bat files, without sh stuff | ||
wb, conanfile.win_bash = conanfile.win_bash, None | ||
msys2_mode_env.vars(conanfile, "build").save_bat(path) | ||
conanfile.win_bash = wb | ||
env.append(path) | ||
|
||
wrapped_shell = '"%s"' % shell_path if " " in shell_path else shell_path | ||
|
@@ -91,7 +99,9 @@ def _windows_bash_wrapper(conanfile, command, env, envfiles_folder): | |
accepted_extensions=("sh", )) | ||
wrapped_user_cmd = _escape_windows_cmd(wrapped_user_cmd) | ||
|
||
final_command = '{} -c {}'.format(wrapped_shell, wrapped_user_cmd) | ||
# according to https://www.msys2.org/wiki/Launchers/, it is necessary to use --login shell | ||
# running without it is discouraged | ||
final_command = '{} --login -c {}'.format(wrapped_shell, wrapped_user_cmd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying with --login, lets see what happens There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is weird, the
when using --login, I don't know how it is connected There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mm it could be related - that error would come from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the setting to cwd to the current working directory is more of a shell behaviour rather than a user configuration files issue. I can understand the concerns of loading I think the problem here is unique in the sense that Conan (the Python interpreter running bash will load There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that using |
||
return final_command | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say that I don't love this approach, I tried different alternatives: passing an argument, forcing the .bat extension to override the configuration... I didn't love them either, and all had other potential downsides too, so this is the best I could come up with