hykilpikonna / hyfetch

🏳️‍🌈 🏳️‍⚧️ Neofetch with LGBTQ+ pride flags!
MIT License
1.27k stars 96 forks source link

'No such file or directory' error occurs when running hyfetch on Windows #84

Closed Namorzyny closed 1 year ago

Namorzyny commented 1 year ago

Description

hyfetch is installed by pip. After I maked a workground for #83, it throws <path of python>/Lib/site-packages/neofetch: No such file or directory. I tried copy <path of python>/Scripts/neowofetch to <path of python>/Lib/site-packages/neofetch, the script runs successfully but freezed like #82.

$ hyfetch
/usr/bin/bash: line 1: /c/Users/zzz/scoop/apps/python/current/Lib/site-packages/neofetch: No such file or directory
Error: Command '[WindowsPath('C:/Program Files/Git/bin/bash.exe'), '-c', '/c/Users/zzz/scoop/apps/python/current/Lib/site-packages/neofetch ascii_distro_name']' returned non-zero exit status 127.
Traceback (most recent call last):
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\main.py", line 429, in run
    neofetch_util.run(preset, config.color_align, config.backend)
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\neofetch_util.py", line 265, in run
    return run_neofetch(preset, alignment)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\neofetch_util.py", line 279, in run_neofetch
    asc = get_distro_ascii()
          ^^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\neofetch_util.py", line 239, in get_distro_ascii
    det = distro_detector.detect(distro or get_distro_name())
                                           ^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\neofetch_util.py", line 260, in get_distro_name
    return run_neofetch_cmd('ascii_distro_name', True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\site-packages\hyfetch\neofetch_util.py", line 220, in run_neofetch_cmd
    return check_output(full_cmd).decode().strip()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zzz\scoop\apps\python\current\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '[WindowsPath('C:/Program Files/Git/bin/bash.exe'), '-c', '/c/Users/zzz/scoop/apps/python/current/Lib/site-packages/neofetch ascii_distro_name']' returned non-zero exit status 127.

Neofetch version

7.3.6

Screenshot

See description above and #82.

jules-party commented 1 year ago

I managed to get it work, it doesn't freeze, just a bit slow.

All I did was make a symbolic link, just like this:

cmd /c mklink %userprofile%\scoop/apps/python/current/Lib/site-packages/neofetch %userprofile%\scoop\apps\python\current\Scripts\neowofetch
hykilpikonna commented 1 year ago

Oops. I hard-coded the path before when people reported that the symbolic link path doesn't work... maybe different python implementations/versions install scripts to different paths, and it seems that the site-packages/neofetch path is no longer valid... weird, it should be installed along with the source distribution 🤔

image

hykilpikonna commented 1 year ago

Ok so the cause is that in higher versions of setup.py packaging, the package script actually expands symlinks and doesn't keep the original symlink and item in their source locations. (i.e. ./hyfetch/scripts/neowofetch is a symlink to ./neofetch in the source repo, but in the packaged zip it is regular file instead). So I added another fix to check both of these paths plus the command name in PATH. Should work now.

image

image