git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.39k stars 2.55k forks source link

W10: Unable to execute `git filter-repo --analyse` /usr/bin/env: 'python3': Permission denied #2833

Closed zosrothko closed 4 years ago

zosrothko commented 4 years ago

Setup

$ git --version --build-options

git version 2.28.0.windows.1
cpu: x86_64
built from commit: 77982caf269b7ee713a76da2bcf260c34d3bf7a7
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
$ cmd.exe /c ver

Microsoft Windows [version 10.0.18362.1082]
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: ConHost
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled

insert your response here

Details

CMD

C:\Users\fandre\Documents\MXW\MI\release>git filter-repo --analyse
/usr/bin/env: 'python3': Permission denied

C:\Users\fandre\Documents\MXW\MI\release>git filter-repo --analyse
/usr/bin/env: 'python': Permission denied

C:\Users\fandre\Documents\MXW\MI\release>where python3
C:\Users\fandre\AppData\Local\Microsoft\WindowsApps\python3.exe

Same with a git-bash window:

FAE@FANDRE-LAPTOP MINGW64 ~/Documents/MXW/MI/release (release)
$ git filter-repo --analyse
/usr/bin/env: 'python': Permission denied

FAE@FANDRE-LAPTOP MINGW64 ~/Documents/MXW/MI/release (release)
$ ls -l /c/Users/fandre/AppData/Local/Microsoft/WindowsApps/python
-rwxr-xr-x 1 FAE 1049089 0 Sep 22 10:59 /c/Users/fandre/AppData/Local/Microsoft/WindowsApps/python*

$ env | grep USER
USERDOMAIN=METRIXWARE
USERNAME=FAE
USERPROFILE=C:\Users\fandre
USERDOMAIN_ROAMINGPROFILE=METRIXWARE
FPS_BROWSER_USER_PROFILE_STRING=Default
USERDNSDOMAIN=METRIXWARE.LOCAL
ALLUSERSPROFILE=C:\ProgramData
UIPATH_USER_SERVICE_PATH=C:\Users\fandre\AppData\Local\UiPath\app-20.4.3\UiPath.Service.UserHost.exe
Path=C:\Program Files (x86)\IBM\EHLLAPI\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ASF\apache-ant-1.9.13\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\IBM\CICS Transaction Gateway\bin;C:\Program Files (x86)\IBM\Personal Communications\;C:\Program Files (x86)\IBM\Trace Facility\;C:\Program Files (x86)\WinSCP\;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\Program Files\dotnet\;C:\Program Files (x86)\NuGet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\PuTTY\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\ASF\apache-maven-3.6.1\bin;C:\Users\fandre\AppData\Local\Microsoft\WindowsApps;C:\Users\fandre\AppData\Roaming\npm;C:\Program Files\CMake\bin;C:\Users\fandre\.dotnet\tools;C:\Users\fandre\.dotnet\tools
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

May be adding a python processor in C:\Program Files\Git\mingw64\bin could solve this issue.

dscho commented 4 years ago

Git for Windows does not include Python, and neither does it include filter-branch. How did you install them?

zosrothko commented 4 years ago

filter-branchhas been deprecated by Git in favor of git-filter-repo.

C:\Users\fandre\Documents\MXW\DEMOS\release>git filter-branch
WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort, then use an
         alternative filtering tool such as 'git filter-repo'
         (https://github.com/newren/git-filter-repo/) instead.  See the
         filter-branch manual page for more details; to squelch this warning,
         set FILTER_BRANCH_SQUELCH_WARNING=1.

Installation steps are there reported as below

filter-repo only consists of a few files that need to be installed:

    git-filter-repo

    This is the only thing needed for basic use.

    This can be installed in the directory pointed to by git --exec-path, or placed anywhere in $PATH.

    If your python3 executable is named "python" instead of "python3" (this particularly appears to affect a number of Windows users), then you'll also need to modify the first line of git-filter-repo to replace "python3" with "python".

The full nigthmare story about new python packagin on Windows10 is there.

From a user's perspective, it would be nice to put a "python" into the C:\Program Files\Git\mingw64\bin directory so that the git-filter-repo could be run without execute right problem.

dscho commented 4 years ago

@zosrothko but how did you install them? I.e. from where did you download Python, where did you install it, how/where did you install filter-repo?

From a user's perspective, it would be nice to put a "python" into the C:\Program Files\Git\mingw64\bin directory so that the git-filter-repo could be run without execute right problem.

It sounds so easy, doesn't it? And it would be easy, but it would also increase the size of the Git for Windows installer, and it would put an even heavier maintenance burden on me, the Git for Windows maintainer, because now you would not only ask me to take care of all Git issues but also of all Python issues users might encounter. For those reasons, Python is intentionally not bundled with Git for Windows.

zosrothko commented 4 years ago

Python is installed from the Windows Store and it is installed here C:\Users\fandre\AppData\Local\Microsoft\WindowsApps\python.exe with all issues mentioned here permission-denied-trying-to-run-python-on-windows-10 which do not have a solution/workaround.

There is already a lot of executable in C:\Program Files\Git\mingw64\bin, so I was thinking that adding Python was a good idea.

dscho commented 4 years ago

Python is installed from the Windows Store and it is installed here C:\Users\fandre\AppData\Local\Microsoft\WindowsApps\python.exe with all issues mentioned here permission-denied-trying-to-run-python-on-windows-10 which do not have a solution/workaround.

Thank you.

I cannot promise anything, of course, as I am preparing my way toward Git for Windows v2.29.0, but I do certainly hope to get a chance to reproduce the issue you reported. Eventually, I'd like to have a smooth path to use git filter-repo in Git for Windows (maybe via a convenient script that would install Python and then clone git filter-repo into a suitable location).

dscho commented 4 years ago

Okay, this is what I did over here:

I then verified that I could reproduce your problem:

C:\Users\me\test-worktree>git filter-repo --analyse
/usr/bin/env: 'python3': Permission denied

I then edited the git-filter-repo script and removed the trailing 3 from the python3, and now it works:

C:\Users\me\test-worktree>git filter-repo --analyze
Processed 25 blob sizes
Processed 9 commits
Writing reports to .git\filter-repo\analysis...done.

Of course, I do have a working python.exe in my PATH, actually even two:

C:\Users\me\test-worktree>where python
C:\Users\me\AppData\Local\Programs\Python\Python38-32\python.exe
C:\Users\me\AppData\Local\Microsoft\WindowsApps\python.exe

Neither of them have the "Permission denied" problem that python3 has, apparently.