Skip to content

fix(lib_deps): install the archive of a GitHub URL's #ref (#2018) - #2031

Merged
zackees merged 1 commit into
mainfrom
fix/lib-deps-github-ref-2018
Nov 17, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/lib-deps-github-ref-2018

Conversation

@zackees

@zackees zackees commented Nov 17, 2026

Copy link
Copy Markdown
Member

Fixes #2018

Root cause

library_downloader::download_github_library appended /archive/refs/heads/main.zip to the raw lib_deps string. With https://github.com/schreibfaul1/ESP32-audioI2S.git#3.0.12 the #3.0.12 made everything after it a URL fragment, so the request went to the repository page. GitHub answered 200 with HTML, and the zip reader failed with "Could not find EOCD". LibrarySpec's own GitHub parser only stripped a trailing .git, so the ref also leaked into the library name and install dir (esp32-audioi2s.git#3.0.12). Without a ref, the code guessed main and then master.

Fix

New fbuild-library/src/library/github_source.rs (GitHubSource). It reuses existing parsers instead of adding a third GitHub URL parser:

  • fbuild_core::platformio_package::parse_package_spec splits off the #ref and git+ prefix (the shared PlatformIO grammar).
  • fbuild_packages_fetch::platformio_repository::github_owner_repo, now pub, splits owner/repo for platform repositories.

Behaviour:

  • Accepted forms: https://github.com/O/R[.git][#ref], git+https://…, http:// and www. spellings, and PlatformIO's Name=<url> custom-name form (checked against platformio/package/meta.py _parse_custom_name). O/R#ref stays a registry spec, as it is in PlatformIO.
  • Download: https://github.com/O/R/archive/<ref>.zip, which GitHub serves for tags, branches and commit SHAs. Ref segments are percent-encoded. With no ref it downloads archive/HEAD.zip (the default branch) instead of guessing main and then master.
  • Install dir: LibrarySpec::install_dir_name() = <name>-<safe ref>, e.g. esp32-audioi2s-3.0.12. Changing the ref no longer reuses the previous ref's checkout. A ref that needs characters replaced also gets a short digest, so a/b and a_b don't collide.
  • The download is checked for a zip signature. An HTML page now fails with <url> returned an HTML page, not a zip archive; check that the repository and ref exist.
  • library.json metadata records the owner and the ref as version. The fbuild install row shows the ref and the archive URL.
  • Mirror layer: unchanged. The bucket mirrors only dl.registry.platformio.org, so GitHub archives are fetched from the primary, as before.

Tests

github_source_tests.rs:

  • every URL form
  • tag, branch and SHA refs
  • no ref → HEAD.zip
  • percent-encoding
  • install dir names and collisions
  • the Name= form
  • rejected inputs
  • tempfile tests: HTML and empty bodies give the clear error; a real zip passes
  • an #[ignore = "network: downloads from github.com"] test that installs the tag and checks src/Audio.cpp is 273879 bytes (the size in the 3.0.12 archive; upstream never bumps its manifest version)

Red first: before the fix, LibrarySpec::parse(<issue URL>).name was ESP32-audioI2S.git#3.0.12.

Validation

  • soldr cargo fmt --all: clean.
  • soldr cargo clippy --workspace --all-targets -- -D warnings: passes.
  • bash test -p fbuild-library, -p fbuild-packages-fetch, -p fbuild-build-engine: all pass.
  • The ignored network test passes locally.

E2E

Ran the issue's project (esp32dev blink + lib_deps = https://github.com/schreibfaul1/ESP32-audioI2S.git#3.0.12) with FBUILD_DEV_MODE=1 and freshly built CLI and daemon.

  • fbuild install: fetched library schreibfaul1/ESP32-audioI2S 3.0.12 … https://github.com/schreibfaul1/ESP32-audioI2S/archive/3.0.12.zip. Installed into libs/esp32-audioi2s-3.0.12. src/src/Audio.cpp is 273879 bytes, matching the tag archive.
  • fbuild build --clean: succeeded (firmware 259 KB). libesp32-audioi2s.a was built.

Secondary ("unused lib_deps library is still built")

No change here. This is PlatformIO parity, not a divergence. In PlatformIO's ProjectAsLibBuilder.process_dependencies (platformio/builder/tools/piolib.py), every lib_deps entry is added as a dependency with depend_on(...) whatever the includes say. lib_ldf_mode affects only the libraries' own dependency search (search_deps_recursive) and the scan of lib/ and global storage. So PlatformIO also compiles fastled/FastLED listed in lib_deps for a blink that includes only Arduino.h. Skipping such libraries would make fbuild diverge from PlatformIO, so it is a design decision and not part of this fix.

`lib_deps = https://github.com/O/R.git#3.0.12` kept the `#3.0.12`
fragment in the URL it appended `/archive/refs/heads/main.zip` to, so
the request went to the repository page, GitHub answered with HTML, and
the zip reader failed with "Could not find EOCD". The ref also ended up
in the library name and install directory (`r.git#3.0.12`).

GitHub lib_deps now go through the shared PlatformIO spec parser
(parse_package_spec) and the platform-repository owner/repo split
(github_owner_repo, now pub). The new GitHubSource:
- accepts https/http/www, `.git` or not, `git+https://`, and the
  `Name=<url>` custom-name form;
- downloads `archive/<ref>.zip` (tags, branches and SHAs alike), or
  `archive/HEAD.zip` without a ref instead of guessing main/master;
- puts a filesystem-safe ref in the install dir
  (`esp32-audioi2s-3.0.12`), so changing the ref never reuses the old
  checkout;
- checks the download is a zip and names an HTML response clearly.

Fixes #2018
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 17, 2026
@zackees
zackees added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit e218404 Nov 17, 2026
31 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

lib_deps: a GitHub URL with a #ref downloads main.zip and fails (2.5.51)

1 participant