I have a python script in my WSL Debian called pasman, which is in my home directory bin folder, where I keep my custom scripts. I have an export statement in .bashrc file so that I can run this scripts anywhere on the WSL system. I also has my bin folder set in visudo file to run scripts as sudo when needed.
This python script has a shebang:
#!/mnt/c/Users/<MyWindowsUsername>/AppData/Local/Programs/Python/Python38/python.exebecause I want to run it with the Python for Windows interpreter.
The problem is that I want to keep this script owned by root, so then I need to run it with sudo, but when I do run with sudo I got:
C:\Users\<MyWindowsUsername>\AppData\Local\Programs\Python\Python38\python.exe: can't open file '/home/<mylinuxusername>/bin/pasman': [Errno 2] No such file or directoryIf the script is not owned by root and I run it without sudo, it runs perfectly.
So, I do not think that the problem is that Windows Python interpreter can't find my script in WSL, but that is it can't find the script only when it's runned with sudo, without sudo it found the script.
I also do not think that the problem is in the export statement in my .bashrc file. If it were, then when I tried to run it with sudo I will just get something like sudo: pasman: command not found.. sudo found my pasman command even with the export in my user .bashrc.
Does anyone have any idea why this is happening?
4 Reset to default