Skip to content

Conversation

@Hahihula
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Hahihula, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust mechanism for handling ESP-IDF version data. It ensures that the application has access to the idf_versions.json file even in scenarios where a direct download might fail. By caching this critical data during the build phase and providing a fallback to this cached data at runtime, the change significantly enhances the application's resilience and offline capabilities regarding IDF version management.

Highlights

  • Build-time Caching of IDF Versions: The idf_versions.json file is now downloaded and cached as a compile-time environment variable (CACHED_IDF_VERSIONS) during the application's build process.
  • Runtime Fallback Mechanism: If the application fails to download the IDF versions at runtime, it will now gracefully fall back to using the previously cached build-time version, improving resilience and offline capability.
  • Asynchronous Build Process: The build script (build.rs) has been updated to use tokio for asynchronous operations, specifically for downloading the IDF versions, making the build process more robust.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Hahihula Hahihula changed the title EIM-370 minimal change approach EIM-370 embed idf_versions file on build time Dec 10, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fallback mechanism to use a cached version of idf_versions.json from build time if fetching it at runtime fails. This is a great addition for offline usability. The implementation in build.rs is sound. However, I've found a critical issue in the fallback logic within src/lib/idf_versions.rs that would cause a panic. I've also included a couple of medium-severity suggestions to improve code quality by removing duplication and a minor inefficiency.

Comment on lines +52 to +57
let versions: Releases = serde_json::from_str(&cached_idf_versions).map_err(|e| {
format!(
"Error parsing cached IDF versions JSON: {}",
e.to_string()
)
})?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This fallback logic will fail at runtime. When download_idf_versions fails, build.rs sets CACHED_IDF_VERSIONS to "{}". Deserializing an empty JSON object into the Releases struct will fail because its fields (VERSIONS, IDF_TARGETS, RELEASES) are not marked with #[serde(default)].

To fix this, you need to update the Releases struct definition (around line 32) to allow deserialization from an empty object:

#[derive(Debug, Deserialize, Clone, Default)]
pub struct Releases {
    #[serde(default)]
    pub VERSIONS: Vec<Version>,
    #[serde(default)]
    pub IDF_TARGETS: Vec<IDFTarget>,
    #[serde(default)]
    pub RELEASES: std::collections::HashMap<String, Release>,
}

}

async fn download_idf_versions() -> Result<String, Box<dyn Error>> {
let url = "https://dl.espressif.com/dl/esp-idf/idf_versions.json";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This URL is hardcoded here and also defined as a constant in src/lib/idf_versions.rs. This duplication can lead to inconsistencies. Consider defining the constant in this build script and passing it to the library crate as a compile-time environment variable to maintain a single source of truth.

For example, you could define const IDF_VERSIONS_URL: &str = "..."; at the top of build.rs, use it here, and also pass it to the crate with println!("cargo:rustc-env=IDF_VERSIONS_URL={}", IDF_VERSIONS_URL);. Then, in src/lib/idf_versions.rs, you can define the constant as pub const IDF_VERSIONS_URL: &str = env!("IDF_VERSIONS_URL");.

@Hahihula Hahihula force-pushed the EIM-370-embed-idf-versions-file-on-build-time branch 8 times, most recently from b5f2542 to 0306ac1 Compare December 11, 2025 14:36
@Hahihula Hahihula force-pushed the EIM-370-embed-idf-versions-file-on-build-time branch from a9d62da to ff13c16 Compare December 15, 2025 13:41
@Hahihula Hahihula force-pushed the EIM-370-embed-idf-versions-file-on-build-time branch from ff13c16 to 7dd5c12 Compare December 15, 2025 13:48
Copy link
Collaborator

@Fabricio-ESP Fabricio-ESP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working, offline installation now does not require any internet connection.
Offline packages tested on Windows, Ubuntu and MacOS.

@Hahihula Hahihula merged commit 5d6d796 into master Dec 15, 2025
39 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants