Lazy tool fetching under Bazel
Blog post from Aspect Build
The text discusses a common pattern in software development known as "lazy downloading", where tools autonomously download necessary components to enhance developer experience, as exemplified by the pkg tool which packages Node.js projects into standalone executables. This process involves downloading and caching large files or third-party resources to avoid repeated fetches and ensure content integrity through hashes. However, this approach faces challenges when integrated with Bazel, a build tool that prefers a more prescriptive method by modeling external downloads as "repository rules" and managing its own cache, leading to issues with non-hermetic builds and cache misses during remote execution. To address this, the text proposes a solution that separates the fetching and building processes, using Bazel's features to create a network-isolated build environment and manipulate the file paths to align with pkg's expectations, ultimately enhancing compatibility with Bazel while maintaining efficient caching and execution.