-
Notifications
You must be signed in to change notification settings - Fork 41
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
Export MSYS2_ROOT environment variable #228
Conversation
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.
This has been requested before, but I'm not sure we want to have it explicitly. This is typically requested for non-recommended use cases, such as adding one of MSYS2's bin locations to the PATH. We should encourage users to instead use the path-type option and/or to package their tools with PKGBUILD. As commented in #227 (comment), if users really need to know the location of the MSYS2 installation, they can get it with cygpath -m /
. They can wrap that in a call from any other terminal.
@lazka @jeremyd2019 @Biswa96 what do you think?
Two alternatives that come to mind:
|
I understand that users should be recommended to use the msys shell, however, one problem with this is that I can only have one environment shell at a time. Say I have a python virtual environment, how do I combine it with an msys2 environment? Can I nest environments? The reason to expose for example the path to the root is to allow msys2 to be used in a way that it is not the primary environment, for example in case of python virtual env, or a rust build environment (there are probably more usecases). |
MSYS2 MINGW environments have Python and Rust. |
@windelbouwman, I feel some misconceptions in your writing. The environment, a shell and a python virtual environment are different things. "Nesting environments" is a confusing concept. Python and bash are interpreted languages, which do require an interpreter to understand and execute commands. The interpreter of Python is typically This Action provides a helper/wrapper executable, which is available in the PATH and which you can use to execute commands in MSYS2 shells without explicitly knowing the location. See https://github.com/msys2/setup-msys2#usage: - shell: powershell
run: msys2 -c 'uname -a' So, if you wanted to execute some commands in a MSYS2 shell, from Python, you would do: - shell: python
run:
from subprocess import check_call
check_call(['msys2', '-c', 'uname -a'], shell=True) Note that this is not exclusive to Python or bash. This Action is written in JavaScript (another interpreted language) and a very similar approach is used: https://github.com/msys2/setup-msys2/blob/main/main.js#L199-L207. Naturally, you can pass a file instead of hardcoding the commands in the call. Furthermore, if you really want to add MSYS2 bin dirs to some environment, you can explicitly tell this Action where to install MSYS2: https://github.com/msys2/setup-msys2#location. Overall, as @MehdiChinoune suggested, I recommend to use Python or Rust within MSYS2 if you rely on dependencies which are only available on MSYS2. |
@lazka, https://github.com/msys2/setup-msys2/blob/main/.github/workflows/Test.yml#L48-L83 and https://github.com/msys2/setup-msys2/blob/main/.github/workflows/Test.yml#L86-L127 show (and test) how to call any msys2 command from either cmd or powershell. I added two new examples showing how to save the location to a variable, either from powershell or from python: setup-msys2/.github/workflows/Test.yml Lines 400 to 408 in 066de4c
See https://github.com/msys2/setup-msys2/runs/6573587546?check_suite_focus=true. |
I've created #404 which is similar. While using cygpath is an alternative, I think letting people figure that out, just to get a path they can add to PATH is too much to ask. |
Fixes partially #227