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

NameError: name 'git' is not defined #360

Closed
AbbyCottontail opened this issue May 14, 2022 · 9 comments
Closed

NameError: name 'git' is not defined #360

AbbyCottontail opened this issue May 14, 2022 · 9 comments

Comments

@AbbyCottontail
Copy link

Raising the issue, with error name so anyone losing hours to this aren't as lost.

Part of the issue is related to poor installation guide for Window users.

Steps I took:

  1. Git for Windows was already installed.
  2. Downloaded Python 3.10, all options tick including install path
  3. Downloaded Scoop
  4. Scoop seem to install git-filter-repo fine, however I was getting this error when trying use it:
C:\Users\ad\source\repos\RavenNest>git filter-repo
Traceback (most recent call last):
  File "C:\Users\ad\scoop\apps\git-filter-repo\current\git_filter_repo.py", line 1, in <module>
    git-filter-repo
NameError: name 'git' is not defined

I was able to confirm that "git" works fine, "python" worked fine.

image
image

Workaround solution found thank to some helpful people another community:

  1. Press Win + R and goto: %userprofile%\scoop\apps\git-filter-repo\current
  2. Copy git-filter-repo (Not git-filter-repo.py)
  3. Win + R and goto: %programfiles%\Git\mingw64\libexec\git-core
  4. Paste the file into this location

I do not know why this is, but the install guide was an information overload and the second worse installation I've ever had to do.

@newren
Copy link
Owner

newren commented May 28, 2022

If anyone has a Windows machine and can take a look, I'd appreciate it. I have no way to reproduce or test. Looks like the scoop developers also struggled to understand how to reproduce given the link above.

@dafurtney
Copy link

dafurtney commented May 28, 2022

@newren I can reproduce easily. Did you check ScoopInstaller/Main#3471 for my hypothesis/workaround? I believe the symbolic link git_filter_repo.py is not being created properly under Windows. If I can help by providing debug logs or other info, let me know.

@newren
Copy link
Owner

newren commented May 28, 2022

@dafurtney: If the hypothesis is that git_filter_repo.py is not being created properly under Windows, and is a "text" file without execute permissions or the equivalent, then it sounds like something the installer (Scoop) would handle and perhaps I should close this out in favor of the link you provided; it's not something I'd have access to fix. But I'm hesitant to do that given that the Scoop developers seemed to be unsure how to duplicate when they first read the report and asked for more info.

I have no Windows system and no way to try to reproduce either.

@dafurtney
Copy link

@newren Please check ScoopInstaller/Main#3471

Is it the case that since mklink (cmd) or New-Item -ItemType SymbolicLink both require admin privilege, the app manifest can't just do that in post_install?

At minimum the scoop package should somehow inform the install user of the manual fix up required ...

Or is there a way to have the scoop install run in admin mode and create the link as expected via post_install? Another workaround is to not create a link and just copy the file either in the original zip or via post_install in the app package manifest.

@newren
Copy link
Owner

newren commented Jun 4, 2022

You're asking me questions about Windows? I haven't used Windows in decades other than incidentally (e.g. at someone else's house). The fine Scoop folks would be much better at answering questions like that. I honestly have absolutely no clue, and no system to test on to find out. As far as I can tell, there aren't any changes I can make that would help or hinder with this issue; it's all in packaging stuff that exists outside this repository. However, if symlinks are the whole problem here, then you could suggest to the Scoop folks that they avoid symlinks and just make "git-filter-repo.py" be a copy of "git-filter-repo" instead.

@AbbyCottontail
Copy link
Author

If it's an issue with scoop, it might be better to figure out a step by step guide for dummies that get consistent result.

Because people will blame the software, not the installer for issues.

@goigle
Copy link

goigle commented Sep 15, 2022

Not so sure it has to do with scoop, even cloning the repo will produce a git_filter_repo.py file with text contents that just read git-filter-repo. If you're only on Windows it's not even apparent that it should have been a symbolic link, it just looks very odd.

Usually what I've seen for python repos is the opposite setup: the main code would be in the .py file, and the pretty named file would just call python on that file.

@newren
Copy link
Owner

newren commented Oct 12, 2022

Re-reading the scoop issue, it indeed appears to be an issue related to symlinks and they are willing to accept a patch to their installer that makes the file be a copy rather than a symlink (an issue I already mentioned in INSTALL.md). So, looks like there's nothing further to be done on the git-filter-repo side.

Thanks for reporting!

@newren newren closed this as completed Oct 12, 2022
@elikaituriziegler
Copy link

elikaituriziegler commented Apr 25, 2024

I have had days of dealing with related issues with none of the fixes I found working. (Could not try installing python from the store, as I am running this on a legacy windows server machine that cannot be upgraded, etc.)

My final solution was to download the raw file, rename it with the .py extension, and remove the shebang. That should fix related issues on windows systems for single use cases like mine. The file can then be run as a normal python script with "py 'path\to\file.py' --args" from the repository directory.

I would recommend adding this to the list of windows user tips, as if I had found it there it would have saved me hours.

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

5 participants