forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
491 stars 79 forks source link

Salesforce CLI Local Git Repository Corruption #2483

Closed bjconover closed 1 year ago

bjconover commented 1 year ago

This has been an issue for the past couple of Salesforce CLI updates, but occasionally when you go to deploy an update to your org you will receive the following error or something similar:

An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: Invalid checksum in GitIndex buffer: expected 746e672f6173736574732f69636f6e732f737461 but saw 83e736f3a0e62161efb4e92134ffe7e8e7cafa9e

I found that when you rename a file or create a new file it can cause this system to get into this state.

To fix the issue, you need to go to the .sf\orgs(Org Id)\localSourceTracking directory and delete the index file that is populated. Once that is done when you deploy\retrieve files again the index file will be regenerated and the issue will be resolved.

I have fixed this issue several times, but it keeps popping back up again from time to time and I have to repeat the steps I listed up above to fix it.

github-actions[bot] commented 1 year ago

Hello @bjconover :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

github-actions[bot] commented 1 year ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

bjconover commented 1 year ago

{ "cliVersion": "@salesforce/cli/2.7.11", "architecture": "win32-x64", "nodeVersion": "node-v18.14.2",
"osVersion": "Windows_NT 10.0.19044", "shell": "cmd.exe", "rootPath": "C:\Users\bconover\AppData\Roaming\npm\node_modules\@salesforce\cli", "pluginVersions": [ "@oclif/plugin-autocomplete 2.3.6 (core)", "@oclif/plugin-commands 2.2.24 (core)", "@oclif/plugin-help 5.2.18 (core)", "@oclif/plugin-not-found 2.4.0 (core)", "@oclif/plugin-plugins 3.3.2 (core)", "@oclif/plugin-search 0.0.22 (core)", "@oclif/plugin-update 3.2.0 (core)", "@oclif/plugin-version 1.3.9 (core)", "@oclif/plugin-warn-if-update-available 2.0.49 (core)", "@oclif/plugin-which 2.2.32 (core)", "@salesforce/cli 2.7.11 (core)", "apex 2.3.12 (core)", "auth 2.8.14 (core)", "data 2.5.7 (core)", "deploy-retrieve 1.17.6 (core)", "info 2.6.40 (core)", "limits 2.3.32 (core)", "login 1.2.28 (core)", "marketplace 0.1.1 (core)", "org 2.10.5 (core)", "schema 2.3.24 (core)", "settings 1.4.27 (core)", "sobject 0.2.6 (core)", "source 2.10.32 (core)", "telemetry 2.3.1 (core)", "templates 55.5.10 (core)", "trust 2.6.7 (core)", "user 2.3.31 (core)" ] }

mdonnalley commented 1 year ago

I found that when you rename a file or create a new file it can cause this system to get into this state.

@bjconover does this occur every time that you rename or create a file? Have you noticed if it's a specific metadata type that triggers the issue?

If you're able to provide replication steps that would be a huge help. Thanks!

github-actions[bot] commented 1 year ago

Hello @bjconover :wave: None of the versions of sf you shared match the latest release.

Shared: 2.7.11 Latest: 2.9.8

Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue. You can also try the rc and nightly releases! (docs)

After updating, share the full output of sf version --verbose --json

ImJohnMDaniel commented 1 year ago

FWIW, I have been seeing this occur more and more frequently over the past few weeks. I have other developers seeing the same thing. Deleting the source tracking folder does help sometimes.

bjconover commented 1 year ago

FWIW, I have been seeing this occur more and more frequently over the past few weeks. I have other developers seeing the same thing. Deleting the source tracking folder does help sometimes.

If you just rename the index file in the local source tracking that will fix the issue too. The system will generate a new index file and that will let you start making deployments again.

bjconover commented 1 year ago

I found that when you rename a file or create a new file it can cause this system to get into this state.

@bjconover does this occur every time that you rename or create a file? Have you noticed if it's a specific metadata type that triggers the issue?

If you're able to provide replication steps that would be a huge help. Thanks!

The problem is intermittent, but I've had it happen on several occasions right after I renamed a LWC. But I've also had it happen when I make a code change and go to deploy it. I mentioned that I was having this issue to one of the consultants that was manning the Salesforce CLI station at Dreamforce 2023 on Tuesday, and he said he ran into the same issue and was able to fix it by deleting the index file. This is the fifth or six time this has happened to me over the past couple of CLI versions.

Here are a couple of other related errors I have gotten: I have had it mention that the index file was empty. (Index file is empty (.git/index))

I've also seen it mention that the magic number is invalid. (Invalid dircache magic file number)

github-actions[bot] commented 1 year ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

iowillhoit commented 1 year ago

We believe that this issue has been resolved. Please make sure you are using the latest version of sf (currently 2.11.8) and the latest version of the Salesforce VSCode extension. If you are still having issues, please open a new issue.

lucabezerra commented 4 weeks ago

I was getting the following error all the time when trying to "SFDX: Deploy This Source to Org" or "SFDX: Retrieve This Source from Org":

An internal error caused this command to fail. isomorphic-git error:
Index file is empty (.git/index)

After deleting the file suggested by the OP, the commands started working again. Is the error back?

github-actions[bot] commented 4 weeks ago

Hello @bjconover :wave: None of the versions of sf you shared match the latest release.

Shared: 2.7.11 Latest: 2.57.7

Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue. You can also try the rc and nightly releases! (docs)

After updating, share the full output of sf version --verbose --json

nileshndethe commented 6 days ago

I am facing similar issue when trying to retrieve the metadata using package.xml (using right click retrieve metadata from org option) even after updating the SF CLI to latest version i.e. 2.60

Error details: Metadata API request failed: An internal error caused this command to fail. isomorphic-git error: Invalid checksum in GitIndex buffer: expected 169525ad9d6cc253f93b56a90051666f7263652d but saw 023e48b5e7966dd73e6fa09121ab74b7c1eb366f

here is the details of the "sf version --verbose --json" { "architecture": "win32-x64", "cliVersion": "@salesforce/cli/2.60.13", "nodeVersion": "node-v20.17.0", "osVersion": "Windows_NT 10.0.22631", "rootPath": "AppData\Local\sf\client\2.60.13-0cbb3a0", "shell": "powershell", "pluginVersions": [ "@ind-rcg/modeler-sfdx-cli-plugin 250.1019.0 (user) published 99 days ago (Thu Jun 27 2024)", "@oclif/plugin-autocomplete 3.2.4 (core)", "@oclif/plugin-commands 4.0.15 (core)", "@oclif/plugin-help 6.2.12 (core)", "@oclif/plugin-not-found 3.2.21 (core)", "@oclif/plugin-plugins 5.4.9 (core)", "@oclif/plugin-search 1.2.9 (core)", "@oclif/plugin-update 4.5.9 (core)", "@oclif/plugin-version 2.2.13 (core)", "@oclif/plugin-warn-if-update-available 3.1.17 (core)", "@oclif/plugin-which 3.2.14 (core)", "@salesforce/cli 2.60.13 (core)", "apex 3.4.10 (core)", "api 1.2.2 (core)", "auth 3.6.62 (core)", "community 3.2.32 (user) published 20 days ago (Sat Sep 14 2024) (latest is 3.2.33)", "data 3.6.7 (core)", "deploy-retrieve 3.12.11 (core)", "info 3.4.9 (core)", "limits 3.3.32 (core)", "marketplace 1.2.26 (core)", "org 4.5.10 (core)", "packaging 2.8.7 (core)", "schema 3.3.32 (core)", "settings 2.3.21 (core)", "sobject 1.4.38 (core)", "source 3.5.21 (core)", "telemetry 3.6.15 (core)", "templates 56.3.21 (core)", "trust 3.7.31 (core)", "user 3.5.31 (core)" ] }

what should be done to resolve this issue?

github-actions[bot] commented 6 days ago

Hello @bjconover :wave: None of the versions of sf you shared match the latest release.

Shared: 2.7.11 Latest: 2.60.13

Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue. You can also try the rc and nightly releases! (docs)

After updating, share the full output of sf version --verbose --json