git-for-windows / git

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

"failed to restrict file handles" while running `git svn` #2890

Closed desbest closed 3 years ago

desbest commented 3 years ago

Setup

$ git --version --build-options

git version 2.29.2.windows.2
cpu: x86_64
built from commit: 3464b98ce6803c98bf8fb34390cd150d66e4a0d3
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19042.610]

Windows 10 20H2 64 bit
# 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: SublimeText
Custom Editor Path: 
Default Branch Option:  
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Core
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled

insert your response here

Details

CMD

svn2git https://wpcom-themes.svn.automattic.com/toolbox/

svn2git is a ruby gem.

I expected my svn repository to be converted to a git repository, It worked before on my windows 8.1 computer.

warning: failed to restrict file handles (87)

handle #0: 0000000000000050 (type 2, handle info (1) 0 handle #1: 0000000000000054 (type 3, handle info (1) 1 handle #2: 0000000000000058 (type 3, handle info (1) 1

This is a bug; please report it at https://github.com/git-for-windows/git/issues/new

To suppress this warning, please set the environment 0 [main] perl 885 dtable::stdio_init: couldn't make stderr distinct from stdout, Win32 error 6 variable

    SUPPRESS_HANDLE_INHERITANCE_WARNING=1

command failed: git svn init --prefix=svn/ --no-metadata --trunk='trunk' --tags='tags' --branches='branches' https://wpcom-themes.svn.automattic.com/toolbox/

https://wpcom-themes.svn.automattic.com/toolbox/

dscho commented 3 years ago

Git for Windows does not support Ruby or svn2git, at least not directly. The 87 in your report corresponds to ERROR_INVALID_PARAMETER, which is quite a bit funny given that it seems to work without restricted handles, which I take means that svn2git connects something very funny to the standard handles.

In any case, if I were facing the challenge you face to run svn2git, already for the reason to get a decent speed, I would use WSL. Have you tried that yet?

desbest commented 3 years ago

I tried to run git svn on a svn repository and I get an error. That doesn't use ruby or svn2git. I get this error.

warning: failed to restrict file handles (87)

handle #0: 0000000000000054 (type 2, handle info (1) 0 handle #1: 00000000000001c0 (type 2, handle info (1) 1 handle #2: 00000000000001c4 (type 2, handle info (1) 1

This is a bug; please report it at https://github.com/git-for-windows/git/issues/new

To suppress this warning, please set the environment variable

    SUPPRESS_HANDLE_INHERITANCE_WARNING=1

  0 [main] perl 428 dtable::stdio_init: couldn't make stderr distinct from stdout, Win32 error 6
dscho commented 3 years ago

I tried to run git svn on a svn repository and I get an error. That doesn't use ruby or svn2git.

Sorry, that was totally not clear to me from the bug report.

In fact, the closest to a concrete command line invocation that I see in the report is: svn2git https://wpcom-themes.svn.automattic.com/toolbox/

0 [main] perl 428 dtable::stdio_init: couldn't make stderr distinct from stdout, Win32 error 6

That is a strange error, first time I encountered it. But apparently StackOverflow encountered this before, and suggests that it happens primarly with version clashes between MSys and Cygwin or MSYS2. I get the distinct feeling that at least some important information is missing from the report. For example, I highly doubt that " insert your response here " is an accurate answer to the question "Any other interesting things about your environment that might be related to the issue you're seeing?". I would expect a more accurate answer to be quite helpful in getting closer to finding the cause for these problems.

In any case, I tried to reproduce from the information provided in the report and failed to get even close:

C:\Users\me>git svn clone https://wpcom-themes.svn.automattic.com/toolbox/
Initialized empty Git repository in C:/Users/johasc/repros/toolbox/.git/
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '/!svn/rvr/100/toolbox' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
Checked through r3200

I stopped it at r3200 because at that point I realized that cloning from this URL is hardly a minimal example. Maybe you can make it reproduce with a smaller example on your side?

desbest commented 3 years ago

I get the distinct feeling that at least some important information is missing from the report. For example, I highly doubt that " insert your response here " is an accurate answer to the question "Any other interesting things about your environment that might be related to the issue you're seeing?". I would expect a more accurate answer to be quite helpful in getting closer to finding the cause for these problems.

How am I supposed to answer what is specific to my environment? I've already said my operating system version, git version, and terminal version. I have not changed any settings. If I've not changed any settings, then I'm hard pressed to think of how my environment would differ from another person.

All I can think of is showing my PATH environment variable.

path environment variable

I've installed subversion from SilkSVN and I've installed Grep and CoreUtils which provides some linux terminal functions on windows.

About MSys, Cygwin and MSYS2, I have MSYS2 installed.

Also I tried it with different commands and the error shown has slight differences in it.

warning: failed to restrict file handles (87)

handle #0: 0000000000000050 (type 2, handle info (1) 0 handle #1: 00000000000001d0 (type 2, handle info (1) 1 handle #2: 00000000000001d4 (type 2, handle info (1) 1

This is a bug; please report it at https://github.com/git-for-windows/git/issues/new

To suppress this warning, please set the environment variable

    SUPPRESS_HANDLE_INHERITANCE_WARNING=1

  0 [main] perl **1464** dtable::stdio_init: couldn't make stderr distinct from stdout, Win32 error 6

warning: failed to restrict file handles (87)

handle #0: 0000000000000054 (type 2, handle info (1) 0 handle #1: 00000000000001bc (type 2, handle info (1) 1 handle #2: 00000000000001c0 (type 2, handle info (1) 1

This is a bug; please report it at https://github.com/git-for-windows/git/issues/new

To suppress this warning, please set the environment variable

    SUPPRESS_HANDLE_INHERITANCE_WARNING=1

  0 [main] perl **1577** dtable::stdio_init: couldn't make stderr distinct from stdout, Win32 error 6
dscho commented 3 years ago

I've installed subversion from SilkSVN and I've installed Grep and CoreUtils which provides some linux terminal functions on windows.

About MSys, Cygwin and MSYS2, I have MSYS2 installed.

That is quite useful and at least SilkSVN (or did you mean SlikSVN?) seems very much related to the issue you reported. So: I am glad that you thought about mentioning this.

Now, the most interesting question is whether you have any msys-2.0.dll in your PATH. Can you have a look?

dscho commented 3 years ago

Now, the most interesting question is whether you have any msys-2.0.dll in your PATH.

What I mean is: not only the first occurrence, but any occurrence in the PATH.

desbest commented 3 years ago

Sorry for the late reply. My emails are flooded. There was 6300 emails in my inbox in October and I've cut it down to 90. I'll be cutting it down some more. And yes I meant Slik SVN, not Silk SVN, so it should be SL instead of SI.

I have searched every folder that appears in PATH and msys-2.0.dll can't be found in any of those folders.

Anyway I have fixed the issue. My antivirus was blocking one of the files that are used for git. So I opened my antivrus, looked at what files are quarantining or sandboxed, then approved the relevant files.

dscho commented 3 years ago

That resolves it. Excellent!

desbest commented 3 years ago

Well that was one of the things to do, as it fixed the git problem, but it still doesn't work for me as in svn2git. I don't know what happened with my computer in the past 2 months to change things, but now something else doesn't work that previously worked 2 months ago,

If I clone a git repository using git clone it works, but if I use git2svn I get the following error, a different error from what I previously reported.

I found a test SVN repository here to use. This has less than 10 commits and is less than 10MB so it should be easy to clone.

Look at this.

c:\Users\desbest\Desktop\repo4>svn2git https://svn.code.sf.net/p/test-svn-repository/code/ Initialized empty Git repository in C:/Users/desbest/Desktop/repo4/.git/ command failed: git checkout -f master

dscho commented 3 years ago

Maybe you can run that git checkout -f master command manually to find out how it fails?

desbest commented 3 years ago

Sorry for the late reply.

After a long time searching google, I find that the issue is with svn2git itself and not git, and more specifically the way the svn repo is structured beyond the user's personal work files, as in svn2git looking for something about the repo, and what is expected not being found, hence the need to add multiple parameters that begin with -- to the command.

I found this question on Stack Overflow which is helpful, but I'll have to get help about it somewhere else regarding my specific situation, as it's beyond the scope of git for windows.

I have one more question to make sure. If I receive this error after a running a command that's a shortcut for multiple commands....

fatal: refs/remotes/svn/trunk: not a valid SHA1
update-ref HEAD refs/remotes/svn/trunk: command returned error: 128

Is the issue caused by git for windows, or by svn2git?

Thank you for your help! At least I finally got git working.

dscho commented 3 years ago

fatal: refs/remotes/svn/trunk: not a valid SHA1 update-ref HEAD refs/remotes/svn/trunk: command returned error: 128

That sounds as if Git expected a revision to be specified, and refs/remotes/svn/trunk not referring to one. So I would wager a guess that Git is called with incorrect parameters (or at least at a time when those parameters are not yet valid).