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

Merging branch produces path error #2677

Closed
JoelLeach opened this issue May 12, 2023 · 9 comments
Closed

Merging branch produces path error #2677

JoelLeach opened this issue May 12, 2023 · 9 comments
Assignees
Labels
bug Something isn't working verified ✔ Verified
Milestone

Comments

@JoelLeach
Copy link

Description

I updated VS Code and GitLens to the latest versions today on Windows 11, and I am now receiving an error when I merge a branch into the current branch. I'm not sure which versions I was on before, but I did not have the issue until updating. Note that I have Git installed in an odd location (D:\Program Files), but I think the same issue would occur if installed in C:\Program Files. To reproduce:

  1. Right-click on the desired branch and select Switch to Branch...
  2. Right-click on the branch to merge and select Merge Branch into Current Branch...
  3. Confirm the merge. The following appeared in the GitLens terminal:
PS D:\AppsWeb\nexus-angular> D:/Program Files/Git/cmd/git.exe -C "d:/AppsWeb/nexus-angular" -c "core.editor=code --wait --reuse-window" merge dev
D:/Program : The term 'D:/Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At line:1 char:1
+ D:/Program Files/Git/cmd/git.exe -C "d:/AppsWeb/nexus-angular" -c "co ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:/Program:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I restarted VS Code after I encountered the error the first time, but that did not help. It's obvious that Windows doesn't like the spaces in the path name. (I thought that Windows cmd could find paths like this even without quotes, but apparently that is no longer the case). I expected that adding quotes around the path would fix the issue, but instead it caused git parsing errors:

PS D:\AppsWeb\nexus-angular> "D:/Program Files/Git/cmd/git.exe" -C "d:/AppsWeb/nexus-angular" -c "core.editor=code --wait --reuse-window" merge dev
At line:1 char:36
+ "D:/Program Files/Git/cmd/git.exe" -C "d:/AppsWeb/nexus-angular" -c " ...
+                                    ~~
Unexpected token '-C' in expression or statement.
At line:1 char:39
+ ... /Program Files/Git/cmd/git.exe" -C "d:/AppsWeb/nexus-angular" -c "cor ...
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"d:/AppsWeb/nexus-angular"' in expression or statement.
At line:1 char:66
+ ... ogram Files/Git/cmd/git.exe" -C "d:/AppsWeb/nexus-angular" -c "core.e ...
+                                                                ~~
Unexpected token '-c' in expression or statement.
At line:1 char:69
+ ... eb/nexus-angular" -c "core.editor=code --wait --reuse-window" merge d ...
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"core.editor=code --wait --reuse-window"' in expression or statement.
At line:1 char:110
+ ... /nexus-angular" -c "core.editor=code --wait --reuse-window" merge dev
+                                                                 ~~~~~
Unexpected token 'merge' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

The merge was successful after removing the full path from git.exe, because D:\Program Files\Git\cmd is in my Windows path.
git.exe -C "d:/AppsWeb/nexus-angular" -c "core.editor=code --wait --reuse-window" merge dev

GitLens Version

13.6.0

VS Code Version

Version: 1.78.2 (system setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: Yes

Git Version

git version 2.37.3.windows.1

Logs, Screenshots, Screen Captures, etc

No response

@JoelLeach JoelLeach added bug Something isn't working triage Needs to be looked at labels May 12, 2023
@frg2089
Copy link

frg2089 commented May 13, 2023

you should add & before your string in powershell.

& "D:/Program Files/Git/cmd/git.exe" -C "d:/AppsWeb/nexus-angular" -c "core.editor=code --wait --reuse-window" merge dev

https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.2#call-operator-

@eamodio
Copy link
Member

eamodio commented May 13, 2023

@JoelLeach Sorry for the trouble -- this broke as part of another fix to run the Git command without relying on it being in the PATH. It looks like when we are trying to get the short version of "D:\Program Files\Git\cmd\git.exe" we are failing. Can you run this command from the Windows Command Prompt and post the output? Thanks!

for %I in ("D:\Program Files\Git\cmd\git.exe") do @echo %~sI

@eamodio
Copy link
Member

eamodio commented May 13, 2023

@JoelLeach Another question -- does D:\Program Files\Git\cmd\git.exe exist?

eamodio added a commit that referenced this issue May 13, 2023
@eamodio
Copy link
Member

eamodio commented May 13, 2023

I just published a new pre-release version with more logging and a fallback for Powershell (assuming I can detect it properly). Can you please see if this issue is still reproducible in the pre-release edition of GitLens? Thanks!

You can switch to the pre-release edition of GitLens, by clicking on the "Switch to Pre-Release version of this extension" from the Extensions view.

image

@eamodio eamodio added needs-more-info Needs further information, steps, details, etc. and removed triage Needs to be looked at labels May 13, 2023
@eamodio eamodio added this to the 13.6-patch milestone May 13, 2023
@eamodio eamodio self-assigned this May 13, 2023
@JoelLeach
Copy link
Author

Thanks for jumping on this quickly. I have switched to the pre-release version, and I will let you know what happens with my next merge. In the meantime, here are answers to your other questions:

@JoelLeach Sorry for the trouble -- this broke as part of another fix to run the Git command without relying on it being in the PATH. It looks like when we are trying to get the short version of "D:\Program Files\Git\cmd\git.exe" we are failing. Can you run this command from the Windows Command Prompt and post the output? Thanks!

for %I in ("D:\Program Files\Git\cmd\git.exe") do @echo %~sI

Here is the result:
D:\Program Files\Git\cmd\git.exe

Yes, that file/path does exist on my system. FYI, I manually created D:\Program Files (with similar permissions to C:\Program Files) for development tools, but Windows does not produce a shortened path without spaces for it. dir /x reveals that short paths are only produced for my C: and not the other drives. There is a way to force it (https://superuser.com/a/792852), but it's probably not something you want to depend upon.

@github-actions
Copy link

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

@github-actions github-actions bot added the inactive Issue has not had recent required feedback label May 23, 2023
@eamodio eamodio added pending-release Resolved but not yet released to the stable edition needs-verification Request for verification and removed needs-more-info Needs further information, steps, details, etc. inactive Issue has not had recent required feedback labels May 25, 2023
@eamodio eamodio closed this as completed May 25, 2023
@IceBjerg
Copy link

Hey everyone!

I was getting the exact same issue for a couple of weeks now.
My problem occurred while "deleting" a local branch.

I can confirm, switching to the Pre-Release version solved the issue.

Output with released version:
image

Output with pre-release version:
image

@eamodio eamodio added verified ✔ Verified and removed needs-verification Request for verification labels May 31, 2023
@JoelLeach
Copy link
Author

Sorry for the delay. Merging a branch now works for me as well with the latest pre-release version.

@github-actions
Copy link

github-actions bot commented Jul 1, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2023
@eamodio eamodio removed the pending-release Resolved but not yet released to the stable edition label Jul 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working verified ✔ Verified
Projects
None yet
Development

No branches or pull requests

4 participants