Where Is the Build Cache for cadgen Located?
The build cache for cadgen is stored in the directory returned by cadgen_cache_root_dir(), which defaults to ~/.cache/cadgen on Linux and macOS, %LOCALAPPDATA%\cadgen on Windows, or any path specified by the CADGEN_CACHE_DIR environment variable.
Understanding the cadgen build cache location is critical when working with the earthtojake/text-to-cad repository to manage disk usage, clean corrupted caches, or configure persistent storage in containerized environments. The cache directory houses compiled geometry, step scene data, and intermediate build artifacts generated during CAD processing pipelines.
How cadgen Determines the Build Cache Location
The resolution logic for the build cache is centralized in a single utility function that respects platform conventions and user overrides.
The cadgen_cache_root_dir() Function
In packages/cadgen/src/cadgen/store/paths.py, the cadgen_cache_root_dir() function implements the canonical algorithm for determining where build artifacts persist. This function is the single source of truth used throughout the cadgen package, including the viewer subsystem which re-exports it from packages/cadgen/src/cadgen/viewer/store_paths.py.
Cache Resolution Order
The function resolves the build cache location through the following precedence hierarchy:
CADGEN_CACHE_DIRenvironment variable — If set, the function returns this path verbatim, allowing absolute control over cache placement.- XDG Base Directory specification — On Unix-like systems, if
XDG_CACHE_HOMEis defined, the cache resides at$XDG_CACHE_HOME/cadgen. - Platform-specific defaults — When no environment variables are set:
- Linux/macOS:
~/.cache/cadgen - Windows:
%LOCALAPPDATA%\cadgen(typicallyC:\Users\<username>\AppData\Local\cadgen)
- Linux/macOS:
Locating the Cache Directory at Runtime
You can programmatically retrieve the active build cache path without guessing platform defaults. Import cadgen_cache_root_dir from either the core paths module or the viewer's store_paths wrapper:
from cadgen.store.paths import cadgen_cache_root_dir
# Get the current build cache directory
cache_dir = cadgen_cache_root_dir()
print(f"cadgen build cache: {cache_dir}")
Alternatively, if working within the viewer context:
from cadgen.viewer.store_paths import cadgen_cache_root_dir
build_cache_path = cadgen_cache_root_dir()
Overriding the Default Cache Path
To redirect the build cache to a custom location—such as a high-speed NVMe scratch disk or a shared network drive—set the CADGEN_CACHE_DIR environment variable before importing cadgen:
export CADGEN_CACHE_DIR="/mnt/fast_storage/cadgen_cache"
python your_script.py
On Windows PowerShell:
$env:CADGEN_CACHE_DIR="D:\CAD\Cache"
python your_script.py
The cadgen_cache_root_dir() function checks this variable first, ensuring all subsequent cache operations write to your specified directory.
Key Source Files in the text-to-cad Repository
The build cache logic is defined and exported from these specific locations in the earthtojake/text-to-cad codebase:
packages/cadgen/src/cadgen/store/paths.py— Contains the primary implementation ofcadgen_cache_root_dir()and the platform detection logic.packages/cadgen/src/cadgen/viewer/store_paths.py— Re-exports the cache path utilities for the viewer subsystem, ensuring consistency across the package.
These files demonstrate that the build cache is distinct from the tessellation cache (which manages mesh data in viewer/tess_cache), though both may reside under the same root directory if no environment overrides are active.
Summary
- The build cache for cadgen is determined exclusively by the
cadgen_cache_root_dir()function. - Default locations are
~/.cache/cadgenon Unix systems and%LOCALAPPDATA%\cadgenon Windows. - Set
CADGEN_CACHE_DIRto override the default path for custom deployments or CI pipelines. - Source code resides in
packages/cadgen/src/cadgen/store/paths.pywith viewer re-exports inpackages/cadgen/src/cadgen/viewer/store_paths.py.
Frequently Asked Questions
What is the default build cache directory for cadgen on Linux?
On Linux, the default build cache directory is ~/.cache/cadgen. The cadgen_cache_root_dir() function checks for XDG_CACHE_HOME first; if that environment variable is unset, it falls back to the standard ~/.cache/cadgen path according to the XDG Base Directory Specification.
How do I change the cadgen build cache location?
Export the CADGEN_CACHE_DIR environment variable with your desired absolute path. This variable takes precedence over all platform defaults and XDG settings, causing cadgen_cache_root_dir() to return your custom directory for all cache operations.
Where is the tessellation cache stored compared to the build cache?
While the build cache resides in the directory returned by cadgen_cache_root_dir(), tessellation caches are typically managed separately within the viewer subsystem (referenced as viewer/tess_cache in the source). However, both systems respect the same root directory resolution logic when determining their respective subdirectories.
Can I programmatically query the cache location from the cadgen viewer module?
Yes. The cadgen.viewer.store_paths module re-exports cadgen_cache_root_dir() from the core paths implementation. Import the function from cadgen.viewer.store_paths to query the active build cache location without directly accessing the store package internals.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →