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

Cached git path is wrong #2877

Closed
drok opened this issue Aug 23, 2023 · 4 comments
Closed

Cached git path is wrong #2877

drok opened this issue Aug 23, 2023 · 4 comments
Assignees
Labels
bug Something isn't working needs-verification Request for verification
Milestone

Comments

@drok
Copy link

drok commented Aug 23, 2023

Description

VScode: 1.77.3 on Windows 10
Remote SSH to OS: CentOS 7 (sclo-git212 installed but not active)
GitLens v13.5.0
On the CentOS 7, PATH=/home/radu/bin/git/bin:/usr/local/bin:/usr/bin

I encounter this error:

[2023-08-22 20:19:01.583] GenerateCommitMessageCommand
Error: Command failed: /opt/rh/sclo-git212/root/usr/bin/git -c core.quotepath=false -c color.ui=false -c log.showSignature=false diff -U3 --staged --
error: bad index version 5

The error: bad index version 5 is expected, but running the sco-git212 is not expected.
I expected the ~/bin/git/bin/git (which supports "index version 5") binary to run, not /opt/rh/sclo-git212/root/usr/bin/git

Using strace, I found that the git process is forked by the /home/radu/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/bootstrap-fork --type=extensionHost --transformURIs --useHostProxy=false process, and confirmed that the git process's PATH environment is /home/radu/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/remote-cli:/home/radu/bin/git/bin:/usr/local/bin:/usr/bin - ie, does not contain the sclo path.

When I initially installed GitLens, the CentOS7 host was configured to use sclo-git212 for vscode. After installing GitLens, I removed the sclo-git212 version and switched to my local experimental git, ~/bin/git/bin/git, which implements the index version 5 that sclo-git212 is unable to understand.

The problem seems to be that the GitLens extension somehow caches the path of the git binary at installation time, making it impossible to later change the underlying git version.

A workaround is:

  1. uninstall GitLens
  2. exit vscode
  3. killall node on CentOS,
  4. start vscode
  5. install GitLens

After this, GitLens is able to use my local, experimental git ~/bin/git/bin/git.

My home directory is mounted on a CentOS host, as well as other Ubuntu hosts (hence, the vscode workspace is shared among hosts of different OS's). The ~/bin/git/bin/git path, which GitLens caches after installing it on CentOS, is valid on CentOS, but not on Ubuntu. The Ubuntu hosts should be using a different git binary, not the cached path that GitLens insists on running.

In short, GitLens appears to cache the path to the git binary at extension installation time, and reuses the same path on subsequent invocation. It should not cache the path at all, but simply run 'git', allowing the underlying configuration dictate, via $PATH, which executable to run.

GitLens Version

v13.5.0

VS Code Version

Version: 1.77.3 (user setup)
Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710
Date: 2023-04-12T09:16:02.548Z
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Windows_NT x64 10.0.17763
Sandboxed: No

Git Version

private experimental version: "git version 2.36.0.rc0.287.g77b638f.dirty" and others

Logs, Screenshots, Screen Captures, etc

No response

@drok drok added bug Something isn't working triage Needs to be looked at labels Aug 23, 2023
@brct-james
Copy link

brct-james commented Dec 8, 2024

I am experiencing a similar issue. I have git installed in both windows and WSL. My default shell profile is WSL, and my git.path setting reflects this by pointing to /usr/bin/git. The path for both shells includes git pointing to the correct respective locations. Regardless, gitlens attempts to use "c:/Program Files/Git/cmd/git.exe" as my git path in a WSL terminal, obviously failing.

As drok identified, gitlens should simply run 'git', or at minimum respect the git.path configured in settings.

Upon further investigation, my issue appears to be caused by the inability to locate git at my specified path:

[2024-12-08 13:52:36.133] [            1] GitLens v16.0.5  activating in Visual Studio Code (1.95.3) on the desktop; language='en', logLevel='debug', defaultDateLocale='null' (10b237276e09d87dbd272cc930b868da7414df5aded14a37abec5935d0ca0fdc|61034bca-4651-41c7-b046-1ded1ce127f91733665950941)
[2024-12-08 13:52:36.135] [    5 →     6] SubscriptionService.changeSubscription(e={"plan":{"actual":{"id":"community","name":"GitLens","bundle":false,"cancelled":false,"trialReactivationCount":0,"startedOn":"2024-11-26T13:52:55.193Z"},"effective":{"id":"community","name":"GitLens","bundle":false,"cancelled":false,"trialReactivationCount":0,"startedOn":"2024-11-26T13:52:55.193Z"}},"state":2,"previewTrial":{"startedOn":"1970-01-01T00:00:00.000Z","expiresOn":"1970-01-01T00:00:00.000Z"}}, t={"silent":true})
[2024-12-08 13:52:36.135] [    5 →     6] SubscriptionService.changeSubscription(e={"plan":{"actual":{"id":"community","name":"GitLens","bundle":false,"cancelled":false,"trialReactivationCount":0,"startedOn":"2024-11-26T13:52:55.193Z"},"effective":{"id":"community","name":"GitLens","bundle":false,"cancelled":false,"trialReactivationCount":0,"startedOn":"2024-11-26T13:52:55.193Z"}},"state":2,"previewTrial":{"startedOn":"1970-01-01T00:00:00.000Z","expiresOn":"1970-01-01T00:00:00.000Z"}}, t={"silent":true}) completed [0ms]
[2024-12-08 13:52:36.135] [    7 →     8] SubscriptionService.ensureSession(e=false)
[2024-12-08 13:52:36.135] [    8 →     9] SubscriptionService.getOrCreateSession(e=false, t={})
[2024-12-08 13:52:36.135] [    9 →     a] AccountAuthenticationProvider.getSessions(e=[gitlens])
[2024-12-08 13:52:36.136] [    a →     b] GitProviderService.setEnabledContext(e=false)
[2024-12-08 13:52:36.136] [    d →     e] DeepLinkService.processPendingDeepLink(e=undefined)
[2024-12-08 13:52:36.141] [    e →     f] WebviewsController.registerWebviewView(e=gitlens.views.commitDetails) completed [0ms]
[2024-12-08 13:52:36.141] [   10 →    11] WebviewsController.registerWebviewView(e=gitlens.views.graph) completed [0ms]
[2024-12-08 13:52:36.141] [   12 →    13] WebviewsController.registerWebviewView(e=gitlens.views.graphDetails) completed [0ms]
[2024-12-08 13:52:36.141] [   14 →    15] WebviewsController.registerWebviewView(e=gitlens.views.home) completed [0ms]
[2024-12-08 13:52:36.142] [   16 →    17] WebviewsController.registerWebviewView(e=gitlens.views.patchDetails) completed [0ms]
[2024-12-08 13:52:36.142] [   18 →    19] WebviewsController.registerWebviewView(e=gitlens.views.timeline) completed [0ms]
[2024-12-08 13:52:36.147] [   1d →    1e] WebviewsController.registerWebviewPanel(e=gitlens.showGraphPage, t=gitlens.graph) completed [0ms]
[2024-12-08 13:52:36.147] [   1f →    20] WebviewsController.registerWebviewPanel(e=gitlens.showTimelinePage, t=gitlens.timeline) completed [0ms]
[2024-12-08 13:52:36.148] [   21 →    22] WebviewsController.registerWebviewPanel(e=gitlens.showSettingsPage, t=gitlens.settings) completed [0ms]
[2024-12-08 13:52:36.148] [   23 →    24] WebviewsController.registerWebviewPanel(e=gitlens.showPatchDetailsPage, t=gitlens.patchDetails) completed [0ms]
[2024-12-08 13:52:36.153] [   25 →    26] Container.registerGitProviders
[2024-12-08 13:52:36.154] [    a →     b] GitProviderService.setEnabledContext(e=false) completed [18ms]
[2024-12-08 13:52:36.154] [    d →     e] DeepLinkService.processPendingDeepLink(e=undefined) completed [18ms]
[2024-12-08 13:52:36.156] [   31 →    32] GitHubIntegration.isConnected
[2024-12-08 13:52:36.156] [   34 →    35] LocalGitProvider.openRepositoryInitWatcher completed [0ms]
[2024-12-08 13:52:36.157] [   35 →    36] GitProviderService.fireProvidersChanged(e=(1) git)
[2024-12-08 13:52:36.157] [   35 →    36] GitProviderService.fireProvidersChanged(e=(1) git) completed [0ms]
[2024-12-08 13:52:36.157] [   33 →    34] GitProviderService.register(e=git) completed [0ms]
[2024-12-08 13:52:36.157] [   37 →    38] VslsGitProvider.openRepositoryInitWatcher completed [0ms]
[2024-12-08 13:52:36.157] [   38 →    39] GitProviderService.fireProvidersChanged(e=(1) vsls)
[2024-12-08 13:52:36.157] [   38 →    39] GitProviderService.fireProvidersChanged(e=(1) vsls) completed [0ms]
[2024-12-08 13:52:36.157] [   36 →    37] GitProviderService.register(e=vsls) completed [0ms]
[2024-12-08 13:52:36.157] [   3a →    3b] GitProviderService.fireProvidersChanged(e=(1) github)
[2024-12-08 13:52:36.157] [   3a →    3b] GitProviderService.fireProvidersChanged(e=(1) github) completed [0ms]
[2024-12-08 13:52:36.157] [   39 →    3a] GitProviderService.register(e=github) completed [0ms]
[2024-12-08 13:52:36.157] [   3c →    3d] GitProviderService.discoverRepositories(e=1)
[2024-12-08 13:52:36.157] [   3d →    3e] GitProviderService.discoverRepositoriesCore(e=WorkspaceFolder(APT, index=0, file:///m:/APT))
[2024-12-08 13:52:36.157] [   3e →    3f] LocalGitProvider.discoverRepositories(e=Uri(file:///m:/APT))
[2024-12-08 13:52:36.157] [   3f →    40] LocalGitProvider.findGit
[2024-12-08 13:52:36.157] [   40 →    41] LocalGitProvider.getScmGitApiCore
[2024-12-08 13:52:36.157] [           42] findSpecificGit(/usr/bin/git) 
[2024-12-08 13:52:36.158] [   40 →    41] LocalGitProvider.getScmGitApiCore completed [0ms]
[2024-12-08 13:52:36.158] [   25 →    26] Container.registerGitProviders completed [5ms]
[2024-12-08 13:52:36.160] [   42 →    43] LineAnnotationController.resume
[2024-12-08 13:52:36.160] [   44 →    45] LineTracker.resume(e={"force":true,"silent":true})
[2024-12-08 13:52:36.160] [   44 →    45] LineTracker.resume(e={"force":true,"silent":true}) completed [0ms]
[2024-12-08 13:52:36.160] [   43 →    44] LineTracker.subscribe completed • starting line tracker... [0ms]
[2024-12-08 13:52:36.160] [   42 →    43] LineAnnotationController.resume completed [0ms]
[2024-12-08 13:52:36.160] [   45 →    46] LineAnnotationController.refresh(e=undefined)
[2024-12-08 13:52:36.160] [   46 →    47] LineTracker.subscribe completed • already started... [0ms]
[2024-12-08 13:52:36.161] [   47 →    48] LineTracker.subscribe completed • already started... [0ms]
[2024-12-08 13:52:36.169] [            1] GitLens v16.0.5 activated, syncedVersion=16.0.5, localVersion=16.0.5, previousVersion=16.0.5 [36ms]
[2024-12-08 13:52:36.169] [   3f →    40] LocalGitProvider.findGit Found built-in Git env
[2024-12-08 13:52:36.170] GitProvider(git).onDidOpenRepository(e=file:///m%3A/APT)
[2024-12-08 13:52:36.170] [   4a →    4b] GitProviderService.getOrOpenRepository(e=Uri(file:///m:/APT))
[2024-12-08 13:52:36.170] [   4b →    4c] GitProviderService.getRepository(e=Uri(file:///m:/APT))
[2024-12-08 13:52:36.170] [   4b →    4c] GitProviderService.getRepository(e=Uri(file:///m:/APT)) returned undefined [0ms]
[2024-12-08 13:52:36.170] [           4d] findSpecificGit(C:\Program Files\Git\cmd\git.exe) 
[2024-12-08 13:52:36.172] [   45 →    46] LineAnnotationController.refresh(e=undefined) completed [11ms]
[2024-12-08 13:52:36.174] [           42] findSpecificGit(/usr/bin/git)  • Unable to find git: Error: spawn /usr/bin/git ENOENT [16ms]
[2024-12-08 13:52:36.174] [           4f] findSpecificGit(C:\Program Files\Git\cmd\git.exe) 
[2024-12-08 13:52:36.303] [           4f] findSpecificGit(C:\Program Files\Git\cmd\git.exe)  • Found 2.47.1.windows.1 in C:\Program Files\Git\cmd\git.exe; git version 2.47.1.windows.1
 [129ms]
[2024-12-08 13:52:36.303] [   3f →    40] LocalGitProvider.findGit completed • Git (2.47.1.windows.1) found in C:\Program Files\Git\cmd\git.exe [146ms]

It seems the issue is specifically a cross-OS challenge in that run uses child_process.exec which is processed by windows, rather than my preferred shell/OS. A cursory search suggest perhaps the project could use spawn instead of exec to check git's availability in the preferred shell, but I've not investigated further. The immediate solution to my problem appears to be developing fully within one OS or the other, using the WSL Extension or using PS/git bash instead of WSL.

@eamodio
Copy link
Member

eamodio commented Dec 10, 2024

GitLens (over aggressively) caches the Git path per-workspace (folder) if the git.path setting isn't used. You can use the GitLens: Reset Stored Data... command from the Command Palette, and then select the Workspace Storage.... This

Image

Hope that helps!

@eamodio eamodio removed the triage Needs to be looked at label Dec 10, 2024
@drok
Copy link
Author

drok commented Dec 10, 2024

@eamodio thanks for the proposed workaround, but it would not work for me.

The need is to access the workspace from two (or more) different OS's, more or less simultaneously, for example with one vscode instance editing the workspace, and debugging on a CentOS host, then alt-tabbing to another vscode instance editing the same workspace but mounted under Ubuntu, etc.

Your workaround would require me to clear the stored data every time I alt-tab - a very work-disrupting operation. I no longer use GitLens because any convenience is far outweighed by having to deal with the errors. This bug is a show stopper, at least for me.

@eamodio eamodio self-assigned this Dec 10, 2024
@eamodio eamodio added this to the 16.1 milestone Dec 10, 2024
@eamodio
Copy link
Member

eamodio commented Dec 10, 2024

I've added a new gitlens.advanced.caching.gitPath setting which can be set to false to disable the Git path caching.

Can you please verify that this change will work for you in tomorrow's (v2024.12.10xx) pre-release edition of GitLens? Thank you so much!

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

@axosoft-ramint axosoft-ramint added pending-release Resolved but not yet released to the stable edition needs-verification Request for verification labels Dec 19, 2024
@d13 d13 removed the pending-release Resolved but not yet released to the stable edition label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-verification Request for verification
Projects
None yet
Development

No branches or pull requests

5 participants