question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Support for MSYS2 in Windows

See original GitHub issue

Thanks @asottile and all the other contributors for the great tool! ❤️ 👍

I am one of the maintainers for Gaphor, and we make heavy use of pre-commit as part of our work flow. It is also built in GTK, and we have to use MSYS2 to build the app for Windows. I know it is a pretty niche environment to support, but it would be really great if we could make it happen.

Current Behavior

version information

pre-commit version: 2.7.1
sys.version:
    3.8.5 (default, Sep  7 2020, 18:26:56)  [GCC 10.2.0 64 bit (AMD64)]
sys.executable: c:/tools/msys64/home/dyeaw/gaphor/.venv/bin/python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: FileNotFoundError: [WinError 3] The system cannot find the path specified: '/home/dyeaw/gaphor'
Traceback (most recent call last):
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/error_handler.py", line 63, in error_handler
    yield
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/main.py", line 343, in main
    _adjust_args_and_chdir(args)
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/main.py", line 163, in _adjust_args_and_chdir
    os.chdir(toplevel)
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/home/dyeaw/gaphor'

Updates Needed

  • Update pre-commit to make use of the cygpath command to convert the path to the standard Windows path format after it gets the top-level path from git.
  • Remove cygwin warnings about incompatible Python+git versions if in the MSYS2 environment
  • Make upstream updates to setuptools_scm to patch additional path conversions for similar things as 1 above.

My plan, as long is everyone is good with adding support for this environment, is to submit a PR for the first two, and then I’ll start to work with the setuptools_scm team to see if I can fix the third one as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Sep 20, 2020

no problem! thanks for the helpful comment as well 😃

0reactions
danyeawcommented, Sep 20, 2020

If anyone stumbles on this issue in the future and you want to run MINGW Python:

  1. Remove msys git using pacman -R git
  2. Install git-for-windows, if you use chocolately you can run choco install git
  3. Add git to your path:
echo 'export PATH=$PATH:/c/ProgramData/chocolatey/bin' >> ~/.bashrc
source ~/.bashrc

Git-for-windows is compiled using MINGW64 as well, and returns the correct Windows paths. Thanks @asottile for the guidance, I don’t think this is well known for MSYS2 users, I’ll see if I can’t add it to their FAQ or other documentation. Sorry for being hard headed 😄.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MSYS2
MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software.
Read more >
MSYS2-Installation
The installers and base archives only contain the tools necessary to 1) start MSYS2 2) update the pre-installed packages and 3) install new...
Read more >
MSYS2-Introduction
MSYS2 is software distribution and a building platform for Windows. It provides a Unix-like environment, a command-line interface and a software repository ...
Read more >
Terminals - MSYS2
The new Windows Terminal application, which by default supports cmd, powershell and WSL ... Insert the example profiles shown below under the profiles...
Read more >
Porting - MSYS2
Porting. While in our humble opinions, MSYS2 makes collaborative, organised development of open-source software on Windows a workable proposition, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found