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

Issue: gsudo script fails missing gsudo.exe in MSYS env #338

Closed
KSR-Yasuda opened this issue Feb 20, 2024 · 2 comments
Closed

Issue: gsudo script fails missing gsudo.exe in MSYS env #338

KSR-Yasuda opened this issue Feb 20, 2024 · 2 comments

Comments

@KSR-Yasuda
Copy link

Issue Description

In MSYS env, running gsudo command, that refers to the shell script, comes to fail due to gsudo.exe missing.

% gsudo --version
/c/Program Files/gsudo/Current/gsudo: 行 12: ./gsudo.exe: No such file or directory
# `gsudo` command (the shell script one) fails.
# It searches for the binary `gsudo.exe` in the current dir.

% type -a gsudo
gsudo is /c/Program Files/gsudo/Current/gsudo

% sudo --version
gsudo v2.4.3 (Branch.tags-v2.4.3.Sha.7da1395544bc53ecba069ff21c490f4922ce055c)
Copyright(c) 2019-2022 Gerardo Grignoli and GitHub contributors
# `sudo` command (`sudo.exe`) does work expectedly.

% type -a sudo
sudo is /c/Program Files/gsudo/Current/sudo

It looks readlink command is returning nothing for gsudo script path, that is not a symbolic link.
Then, it searches in dirname "" or . directory to find nothing.

With -f option to readlink, it works.

--- "a/c/Program Files/gsudo/Current/gsudo"
+++ "b/c/Program Files/gsudo/Current/gsudo"
@@ -8,5 +8,5 @@
 # For better experience (fix credentials cache) in git-bash/MinGw create this wrapper can be added as function in .bashrc:
 #       gsudo() { WSLENV=WSL_DISTRO_NAME:USER:$WSLENV MSYS_NO_PATHCONV=1 gsudo.exe "$@"; }
 
-thisdir="$(dirname "$(readlink "$0")")"
+thisdir="$(dirname "$(readlink -f "$0")")"
 WSLENV=WSL_DISTRO_NAME:USER:$WSLENV MSYS_NO_PATHCONV=1 "${thisdir}/gsudo.exe" "$@"
% gsudo --version
gsudo v2.4.3 (Branch.tags-v2.4.3.Sha.7da1395544bc53ecba069ff21c490f4922ce055c)
Copyright(c) 2019-2022 Gerardo Grignoli and GitHub contributors

Steps to Reproduce

As above.

Screenshots

Context:

  • Windows version: Windows 11 Pro 23H2 ([Version 10.0.22631.3155])
  • gsudo version: v2.4.3
% pacman -Q msys2-runtime
msys2-runtime 3.4.10-5

% cmd version
Microsoft Windows [Version 10.0.22631.3155]
(c) Microsoft Corporation. All rights reserved.
# Windows 11 Pro 23H2

% readlink --version
readlink (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Dmitry V. Levin.
@gerardog
Copy link
Owner

Thanks for reporting! Fixed in cf887bf v2.4.4

@KSR-Yasuda
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants