msys2-runtime icon indicating copy to clipboard operation
msys2-runtime copied to clipboard

How to disable unix path translation?

Open realyukii opened this issue 1 year ago • 11 comments

some program like msiexec.exe only understand Windows path, thus it cause trouble when python program tried to spawn msiexec.exe:

Unpacking msi files...
Traceback (most recent call last):
  File "/home/ACER/portable-msvc.py", line 285, in <module>
    subprocess.check_call(["msiexec.exe", "/a", m, "/quiet", "/qn", f"TARGETDIR={OUTPUT.resolve()}"])
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['msiexec.exe', '/a', PosixPath('downloads/Universal CRT Headers Libraries and Sources-x86_en-us.msi'), '/quiet', '/qn', 'TARGETDIR=/home/ACER/msvc']' returned non-zero exit status 103.

I have tried this solution, but it just show another error that I'm not sure that I fully understand the error:

Unpacking msi files...
This installation package could not be opened.  Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
Traceback (most recent call last):
  File "/home/ACER/portable-msvc.py", line 285, in <module>
    subprocess.check_call(["msiexec.exe", "/a", m, "/quiet", "/qn", f"TARGETDIR={OUTPUT.resolve()}"])
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['msiexec.exe', '/a', PosixPath('downloads/Universal CRT Headers Libraries and Sources-x86_en-us.msi'), '/quiet', '/qn', 'TARGETDIR=/home/ACER/msvc']' returned non-zero exit status 83.

realyukii avatar Oct 22 '24 23:10 realyukii

the python program originated from this gist

realyukii avatar Oct 22 '24 23:10 realyukii

This may help https://www.msys2.org/docs/filesystem-paths/

Biswa96 avatar Oct 23 '24 04:10 Biswa96

I'm not sure if that link would help, I already tried what mentioned there but it still translate the path with PosixPath

realyukii avatar Oct 23 '24 10:10 realyukii

@Biswa96 that page does not describe the new MSYS_NO_PATHCONV variable, maybe it should? It does not allow for as fine-grained configuration as MSYS2_ENV_CONV_EXCL/MSYS2_ARG_CONV_EXCL, but on the upside it is much, much easier to use.

dscho avatar Oct 23 '24 10:10 dscho

I'm not sure if that link would help, I already tried what mentioned there but it still translate the path with PosixPath

Maybe you can provide some sort of detail, such as a small reproducer, detailed output, etc? It is hard to solve a problem when forced to guess.

dscho avatar Oct 23 '24 10:10 dscho

I'm not sure if that link would help, I already tried what mentioned there but it still translate the path with PosixPath

Maybe you can provide some sort of detail, such as a small reproducer, detailed output, etc? It is hard to solve a problem when forced to guess.

Well... I do apologize for not provide enough details explicitly, here's the way to reproduce the issue:

pacman -S python libopenssl
curl -LOJ https://gist.githubusercontent.com/mmozeiko/7f3162ec2988e81e56d5c4e22cde9977/raw/9f8555326867d4ecba70ee07f105f159f5d8afd5/portable-msvc.py
python portable-msvc.py

realyukii avatar Oct 23 '24 10:10 realyukii

curl -LOJ https://gist.githubusercontent.com/mmozeiko/7f3162ec2988e81e56d5c4e22cde9977/raw/9f8555326867d4ecba70ee07f105f159f5d8afd5/portable-msvc.py

@RealYukiSan are you really calling this a small reproducer?

Please revisit https://stackoverflow.com/help/mcve, in particular this part:

Your code examples should be…

  • Minimal: Use as little code as possible that still produces the same problem

Also, you may want to zone in on the PosixPath() function, which is not even in your reproducer (probably only via yet a different asset that makes the reproducer even less minimal). I bet that the use of PosixPath() is the problem, as you clearly want to use this on Windows and hence might need Windows paths, not POSIX paths?

dscho avatar Oct 23 '24 10:10 dscho

are you really calling this a small reproducer? which is not even in your reproducer

I can't reproduce in a small reproducer, the problem is I don't even know why the PosixPath function was printed on CalledProcessError stack, it's not even called in the python script

as you clearly want to use this on Windows and hence might need Windows paths, not POSIX paths?

indeed, maybe I should post the issue on msys2-package repository instead? as it's related to specific python package installed from msys

realyukii avatar Oct 23 '24 10:10 realyukii

maybe I should post the issue on msys2-package repository instead?

I don't think that it is a good idea to reflexively try to throw this issue over the wall, without even analyzing it properly yourself.

I mean, you know where in the script it is stuck, and it's likely around this line, and you could then call that command individually (and have a much, much more minimal reproducer already).

Then dig into what this .msi does, where it is defined, where that PosixPath() function is used within that definition. The dig deeper. And deeper.

It's really good idea to ask people for help after doing these first steps and being able to present a much more concise problem description. Otherwise, those exact people who could help you, like me, may decide that they do not want to deal with the problem altogether because all the analysis is expected from them.

dscho avatar Oct 23 '24 10:10 dscho

You're right, and I do apologize for not having searched more carefully. I'm grateful for your prompt response and your civility in the face of my impatience!

I will try to debug the issue and provide any details if I found something useful to share.

realyukii avatar Oct 23 '24 11:10 realyukii

Possibly related: The documented environment variables seem to have no effect in a fresh MSYS2 installation from last thursday.

Zsar avatar Jan 13 '25 15:01 Zsar