hyfetch icon indicating copy to clipboard operation
hyfetch copied to clipboard

hyfetch on windows would start wsl bash if git bash is not in path

Open nexplorer-3e opened this issue 1 year ago • 0 comments

Describe the bug

Current behavior of ensure_git_bash() in neofetch_util.py would firstly detect bash location. If git-for-windows is not installed or the path to git bash is not registered into the path env, and wsl is enabled, this function would return path to wsl bash, which causes ENOENT to execute the neowofetch script.

  • [ x ] Does this issue still occur in the master branch? (Required)

Expected behavior

run native bash, execute the shell script. (or run wsl bash with wsl path to script, and get the output)

Screenshots

Please include a screenshot of your system information if the specific system environment is relevant to the bug.

git for windows is installed to D, with git.exe in path but not for git bash.

stderr:

> hyfetch
/bin/bash: line 1: D:/Python/miniconda3/Lib/site-packages/hyfetch/scripts/neowofetch: No such file or directory
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\Python\miniconda3\Scripts\hyfetch.exe\__main__.py", line 7, in <module>
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\main.py", line 375, in run
    config = create_config() if args.config else check_config(args.config_file)
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\main.py", line 34, in check_config
    return create_config()
           ^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\main.py", line 47, in create_config
    asc = get_distro_ascii()
          ^^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\neofetch_util.py", line 317, in get_distro_ascii
    det = distro_detector.detect(distro or get_distro_name())
                                           ^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\neofetch_util.py", line 338, in get_distro_name
    return run_neofetch_cmd('ascii_distro_name', True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\site-packages\hyfetch\neofetch_util.py", line 298, in run_neofetch_cmd
    return check_output(full_cmd).decode().strip()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\miniconda3\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '[WindowsPath('C:/WINDOWS/system32/bash.exe'), '-c', "'D:/Python/miniconda3/Lib/site-packages/hyfetch/scripts/neowofetch' ascii_distro_name"]' returned non-zero exit status 127.

Config file

first run, not initialized.

Additional context

Some workaround:

  • set priority for getting git path for first
  • give wsl path to wsl bash to get correct output

nexplorer-3e avatar Feb 06 '24 03:02 nexplorer-3e