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

'Run python file' doesn't work in Git Bash #23384

Open
ingempo opened this issue May 8, 2024 · 3 comments
Open

'Run python file' doesn't work in Git Bash #23384

ingempo opened this issue May 8, 2024 · 3 comments
Assignees
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@ingempo
Copy link

ingempo commented May 8, 2024

When clic on upper rigth button (Run python file):

DEVOPS-WIP-01+opalrtlinux@DEVOPS-WIP-01 MINGW64 /c/work/hardware-qualification (OS-1494_add_hs_api_support) $ /work/hardware-qualification/.venv/Scripts/python.exe /work/hardware-qualification/test_hypersim.py bash: /work/hardware-qualification/.venv/Scripts/python.exe: No such file or directory

My interpreter is /.venv/Scripts/python.exe

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label May 8, 2024
@ingempo
Copy link
Author

ingempo commented May 8, 2024

if i change to Command prompt, it works.

@NIV27e
Copy link

NIV27e commented May 9, 2024

I attempted to replicate the issue of 'Run python file' not working in Git Bash on my macOS setup but was unsuccessful. Here's a brief overview of what I did:

Setup: I set up a Python environment and ran a simple script through VSCode using the macOS Terminal.
Outcome: The script executed successfully without any errors.

It seems that the issue might be specific to Git Bash on Windows, possibly due to differences in how path resolutions are handled between operating systems. I recommend further testing on Windows or investigating how Git Bash handles paths compared to other shells.

Observations:

  1. Path Syntax and Handling: Path syntax differs significantly between Windows and Unix-like systems. While Unix uses forward slashes (/) for paths, Windows typically uses backslashes (). Git Bash attempts to bridge this gap by translating Unix paths to Windows paths, which can sometimes lead to inconsistencies or incorrect paths.

  2. Executable Files and Environment Variables: Standards also vary, with Windows executables typically ending in .exe and using %VAR% format for environment variables, as opposed to the Unix $VAR format and permission-based executability.

Possible Causes:
The issue might stem from how Git Bash handles these translations and emulates Unix paths and commands within the Windows environment. This could lead to scripts generating paths that don't actually resolve correctly under Windows file system rules.

Suggestions for Resolution:

  1. Path Handling: Ensure that any scripts or tools explicitly handle different path conventions depending on the operating system. This might involve checking the operating system at runtime and adjusting paths accordingly.

  2. Cross-Platform Testing: More rigorous testing across different environments could help identify these issues earlier. Testing in both native Unix environments and Windows with Git Bash can highlight discrepancies that need addressing.

  3. Use Cross-Platform Libraries: For development, consider using libraries that abstract away these differences, such as Python’s os.path or pathlib modules, which handle file system paths intelligently across platforms.

I hope this helps clarify the potential root causes and provides a path forward for resolving the issue. I’m looking forward to any further insights or suggestions on this matter!

@anthonykim1
Copy link

Hello @ingempo Thanks for filing the issue.
Please note that git bash isn't officially supported by Python extension at the moment. Reference: #22908

@NIV27e Appreciate the thorough comments on this and this would definitely come in handy once we get time, bandwidth in the future to be ready to support Git bash!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants