Configuration
Downloaded parser binaries go in the cache directory. The default:
~/.cache/tree-sitter-language-pack/<version>/libs/You can customize the cache location, pre-download languages on startup, and wire up automatic discovery through a TOML file, the programmatic API, or CLI commands.
Language-pack.toml
Section titled “Language-pack.toml”Create language-pack.toml in your project root:
languages = ["python", "javascript", "typescript", "rust"]
# Optional: language groups (web, systems, data, jvm, functional, scripting)# groups = ["web", "systems"]
# Optional: custom cache directory# cache_dir = ".cache/ts-pack"Run ts-pack init to generate this file interactively, or create it by hand.
Configuration discovery
Section titled “Configuration discovery”The library searches for language-pack.toml in this order:
- Current directory and parent directories (up to 10 levels)
$XDG_CONFIG_HOME/tree-sitter-language-pack/config.toml(~/.config/tree-sitter-language-pack/config.tomlon Linux/macOS)
CLI flags override config file settings.
Monorepo example
Section titled “Monorepo example”# language-pack.toml (at repo root)languages = [ # Backend "python",
# Frontend "javascript", "typescript", "jsx", "tsx",
# Utilities "rust", "bash", "dockerfile", "yaml", "json",]
# Shared cache across all sub-projectscache_dir = ".cache/tree-sitter"Programmatic API
Section titled “Programmatic API”from tree_sitter_language_pack import init, configure, PackConfigfrom pathlib import Path
# Pre-download specific languagesinit(languages=["python", "javascript", "rust"])
# Download by language groupinit(groups=["web"]) # JavaScript, TypeScript, HTML, CSSinit(groups=["systems"]) # C, C++, Rust, Goinit(groups=["data"]) # Python, R, SQL, JSON
# Combine languages and groupsinit(languages=["python"], groups=["web", "systems"])
# Set custom cache directory (call before first parse)configure(cache_dir="/opt/ts-pack-cache")
# Load from language-pack.tomlconfig = PackConfig.from_toml_file(Path("language-pack.toml"))if config.languages: init(languages=config.languages)
# Discover in current dir and parentsconfig = PackConfig.discover()if config and config.languages: init(languages=config.languages)import { init, configure, PackConfig } from "@xberg-io/tree-sitter-language-pack";
await init({ languages: ["python", "javascript", "rust"] });await init({ groups: ["web"] });await configure({ cacheDir: "/opt/ts-pack-cache" });use tree_sitter_language_pack::PackConfig;use std::path::Path;
// Programmatic configurationlet config = PackConfig { cache_dir: Some(Path::new("/opt/cache").to_path_buf()), languages: Some(vec!["python".to_string(), "rust".to_string()]), groups: None,};
// Load from filelet config = PackConfig::from_toml_file(Path::new("language-pack.toml"))?;
// Discover in parent directoriesif let Some(config) = PackConfig::discover() { println!("Found languages: {:?}", config.languages);}Build-time environment variables
Section titled “Build-time environment variables”build.rs reads these at compile time, not at runtime. See Building from source for full details.
| Variable | Description |
|---|---|
TSLP_LANGUAGES |
Comma-separated languages to compile statically into the binary |
TSLP_LINK_MODE |
dynamic (default), static, or both |
PROJECT_ROOT |
Override directory search for sources/language_definitions.json |
WASI_SYSROOT |
WASI sysroot path for wasm32-wasi cross-compilation |
TSLP_BUILD |
Set to 1 to force rebuild of the Elixir NIF native extension |
CLI commands
Section titled “CLI commands”ts-pack init
Section titled “ts-pack init”Create a language-pack.toml:
# Interactivets-pack init
# With specific languagests-pack init --languages python,javascript,typescript,rust
# With custom cache directoryts-pack init --cache-dir ./local-cache --languages pythonts-pack cache-dir
Section titled “ts-pack cache-dir”Print the effective cache directory:
ts-pack cache-dir# /home/user/.cache/tree-sitter-language-pack/<version>/libs/
# Use in scriptsCACHE=$(ts-pack cache-dir)du -sh "$CACHE"ts-pack download
Section titled “ts-pack download”# Languages from configts-pack download
# Specific languagests-pack download python rust javascript
# All available languagests-pack download --all
# Clear cache and re-downloadts-pack download --fresh
# By groupts-pack download --groups web,systemsts-pack list
Section titled “ts-pack list”# All available languagests-pack list
# Cached onlyts-pack list --downloaded
# Filter by namets-pack list --filter pythonTLS trust store
Section titled “TLS trust store”The downloader trusts the host OS trust store by default — the same set of CAs that curl, pip, and git use on each platform (/etc/ssl/certs on Linux, Keychain on macOS, SChannel on Windows). This works out of the box in corp environments where GitHub HTTPS traffic is presented with a chain rooted in a locally trusted CA (TLS-intercepting proxies, internal mirrors, WSL2 with Windows-managed certs, RHEL/UBI with extra anchors).
Set TREE_SITTER_LANGUAGE_PACK_TLS_ROOTS=webpki to force the downloader to trust only the bundled Mozilla webpki roots (the historical pre-fix default). Use this on hosts whose platform trust store is intentionally narrowed or where you need byte-for-byte build reproducibility against a known root set:
TREE_SITTER_LANGUAGE_PACK_TLS_ROOTS=webpki python -c "import tree_sitter_language_pack; tree_sitter_language_pack.get_parser('python')"Set TREE_SITTER_LANGUAGE_PACK_TLS_ROOTS=platform to make the default explicit. Any other value falls back to the default (no hard error).
Troubleshooting
Section titled “Troubleshooting”Downloads failing
ts-pack cache-dir # verify the cache pathts-pack download python # retry the downloadts-pack clean # clear a corrupted cacheUnknownIssuer / invalid peer certificate errors mean the chain GitHub serves is not in the trust store the downloader is configured to use. The default (Platform mode) already reads the host trust store; if you set TREE_SITTER_LANGUAGE_PACK_TLS_ROOTS=webpki explicitly, switch back to platform (or unset the variable). If curl https://github.com also fails on the same host with the same error, fix the host trust store first — the language pack honours it.
For offline environments: pre-download on a machine with network access, then copy the cache directory to the target machine. See Docker for baking parsers into a container image.
Disk space
du -sh ~/.cache/tree-sitter-language-pack
# Move the cache to a larger drivemv ~/.cache/tree-sitter-language-pack /mnt/large-drive/ts-pack-cacheln -s /mnt/large-drive/ts-pack-cache ~/.cache/tree-sitter-language-packNext steps
Section titled “Next steps”- Building from source — compile-time flags and environment variables
- Docker — bake parsers into container images
- Parsing code — syntax trees after languages finish downloading