arduino / libraries-repository-engine

Arduino Library Manager index manager
GNU Affero General Public License v3.0
12 stars 3 forks source link

"CRC doesn't match, file is corrupted" when installing library via Library Manager #146

Closed khoih-prog closed 2 years ago

khoih-prog commented 2 years ago

We currently can't install / update the AsyncWebServer_RP2040W v1.1.0 via Arduino IDE Library Manager. Installing the old v1.0.3 is OK.

Is this the issue of corrupted GitHub, or I have to recreate a new version ?

Selection_082

khoih-prog commented 2 years ago

Thanks @per1234

I created the v1.1.1 to bypass this error, and it's all OK now to install now. I guess we can forget the v1.1.0 Possibly just some transient issue, making files corrupted. I'm afraid it's not worth your time to investigate this, and I'm closing this now.

per1234 commented 2 years ago

Thanks @khoih-prog. I verified that the cause is the checksum in the library index is incorrect:

$ export ARDUINO_DIRECTORIES_DOWNLOADS="/tmp/arduino-cli-directories/downloads"

$ export ARDUINO_DIRECTORIES_DATA="/tmp/arduino-cli-directories/data"

$ arduino-cli lib update-index

[...]

$ arduino-cli lib install AsyncWebServer_RP2040W@1.1.0

[...]

Downloading AsyncWebServer_RP2040W@1.1.0...
AsyncWebServer_RP2040W@1.1.0 downloaded
Installing AsyncWebServer_RP2040W@1.1.0...
Error installing AsyncWebServer_RP2040W: Library install failed: testing local archive integrity: testing archive checksum: archive hash differs from hash in index

$ jq '.libraries[] | select(.name == "AsyncWebServer_RP2040W" and .version == "1.1.0").checksum' "${ARDUINO_DIRECTORIES_DATA}/library_index.json"
"SHA-256:25d9f18e4a768da0b19e0f8a0b67243a02f83b14e5da74e7c93a553edcd8160f"

$ shasum --algorithm 256 "${ARDUINO_DIRECTORIES_DOWNLOADS}/libraries/AsyncWebServer_RP2040W-1.1.0.zip"
51eeff5a10a74f47e6339a97ec9d7e058f256ccb2d280abc813f08a7d77c6813 */tmp/arduino-cli-directories/downloads/libraries/AsyncWebServer_RP2040W-1.1.0.zip

$ jq '.libraries[] | select(.name == "AsyncWebServer_RP2040W" and .version == "1.1.0").size' "${ARDUINO_DIRECTORIES_DATA}/library_index.json"
537171

$ stat --printf="%s" "${ARDUINO_DIRECTORIES_DOWNLOADS}/libraries/AsyncWebServer_RP2040W-1.1.0.zip"
537171

I ran the checksum generation code from the engine and it gives me the same checksum for the downloaded file as shasum does.

I ran libraries-repository-engine locally and it produced a correct checksum for the AsyncWebServer_RP2040W@1.1.0 release.

I guess we can probably work around the problem by removing the release from the index and hoping the next scheduled run of libraries-repository-engine will produce correct data for the release, but it would be better to figure out what caused this. I don't have any ideas about how to proceed though.