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

Can't get it to work on Windows #193

Closed
Slion opened this issue Jan 21, 2021 · 9 comments
Closed

Can't get it to work on Windows #193

Slion opened this issue Jan 21, 2021 · 9 comments

Comments

@Slion
Copy link

Slion commented Jan 21, 2021

All I get is error: cannot spawn git-filter-repo: Exec format error.
Used Python as provided from Microsoft Store.
Installed git-filter-repo using pip.
Copied script to git folder.
Try run it.
Get error mentioned above.

Tried to change the shebang line, no joy.

@Slion
Copy link
Author

Slion commented Jan 21, 2021

Shebang: #!crap
Result: error: cannot spawn git-filter-repo: Exec format error

Shebang: #!C:\Users\username\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
Result: error: cannot spawn git-filter-repo: Exec format error

Shebang: #!/usr/bin/env python
Result: /usr/bin/env: 'python': Permission denied

1 similar comment
@Slion
Copy link
Author

Slion commented Jan 21, 2021

Shebang: #!crap
Result: error: cannot spawn git-filter-repo: Exec format error

Shebang: #!C:\Users\username\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
Result: error: cannot spawn git-filter-repo: Exec format error

Shebang: #!/usr/bin/env python
Result: /usr/bin/env: 'python': Permission denied

@newren
Copy link
Owner

newren commented Jan 22, 2021

Did you read https://github.com/newren/git-filter-repo/blob/main/INSTALL.md (linked to from the main page) and particularly the NOTES for windows users? Did you try things mentioned in the three links from there?

@Slion
Copy link
Author

Slion commented Jan 22, 2021

Did you read https://github.com/newren/git-filter-repo/blob/main/INSTALL.md (linked to from the main page) and particularly the NOTES for windows users? Did you try things mentioned in the three links from there?

I did read through those yes. Did not help though. I did a rebase instead 😁

@devkoa
Copy link

devkoa commented Feb 2, 2021

Hello there, @Slion you are not right, it works on Windows. In my case i have hundred of git repositories, and i develop and test in Windows system. And i have a quite complex setup. I run python code, i generate a shell script and the shell script calls the git-filter-repo, and all this works well on Windows. So i dont see any issue here.
@newren Thanks, great work.

Solution:
You will need Portable: Python, Git
python_path="path/to/python/python.exe"
git_path="path/to/git/git.exe"
git_filter_repo="path/to/script/git-filter-repo.py" # copy code local first
git_path python_path git_filter_repo "parameters"
or if you are in git bash just run:
python_path git_filter_repo "parameters"

@SteveBenz
Copy link

I haven't figured this all the way out, but in Python 3.9.0, which is the one I downloaded from python.org (not the windows store version), it seems that the default instructions of replacing:

#!/usr/bin/env python3

with whatever your version of python is (e.g. mine is 'py'), resulting in:

#!/usr/bin/env py

Don't quite work because I'm pretty sure that 'py' is itself interpreting the '#!' and launching another 'py' process, leaving the machine with an infinitely growing list of 'py' processes... One would think that the way to fix it would be to add '-x' to the shebang line (which causes python to ignore the first line of the file), but I still haven't managed it.

@Andrefei
Copy link

@SteveBenz Probably way to late to help you, but as a Windows user I also struggeled for hours trying to get this to work. I entered the same trap as you mention by changing the shebang to #!/usr/bin/env py. Ended up crashing the dev environment as I did not realize my mistake until it was too late... Don't know if this issue is worth adding somewhere @newren

Anyways, what ended up working for me was changing the shebang to #!/usr/bin/env python and running git filter-repo through the Anaconda PowerShell Prompt in Administrator mode as mentioned in #36. I am wondering if this solution could work in a general case, as the Anaconda PowerShell should reach you Python installation in a similar way regardless of installation method or version.

@ViliusS
Copy link

ViliusS commented Apr 1, 2021

@Slion try changing shebang value to #!\python.exe
Worked for me.

Also, don't run cmd shell under Administrator as you won't have rights to access MS Store version of Python (it is installed under user's profile).

@newren
Copy link
Owner

newren commented Oct 14, 2022

I updated the INSTALL.md file to point out that folks can just run python3 git-filter-repo instead of trying to get git filter-repo to work. Don't know why Windows makes it so difficult to make the short form magic work, but it's really not necessary.

@newren newren closed this as completed Oct 14, 2022
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

6 participants