Streamlit project-local config.toml resolution and STREAMLIT_CONFIG
0 reputation · 21 Apr 2023, 05:38 UTC
0 reputation · 21 Apr 2023, 05:38 UTC
A repeatable local development setup is desired where server settings such as port, headless mode, and file watcher behavior are defined alongside the repository and behave consistently across macOS, Linux, and Windows contributors.
Streamlit resolves configuration from a user home directory by default, ~/.streamlit/config.toml on macOS and Linux and %USERPROFILE%\.streamlit\config.toml on Windows. A .streamlit/config.toml committed inside the application repository is not used automatically. Configuration can be redirected with STREAMLIT_CONFIG, and values may be overridden by STREAMLIT_SECTION_OPTION environment variables and by flags passed to streamlit run.
The permission boundary between user-level defaults and project-level intent is unclear, and the interaction of OS-specific default paths with a shared repository makes repeatability uncertain.
Does Streamlit provide a documented way to prefer a repo-local .streamlit/config.toml without requiring each developer to set STREAMLIT_CONFIG? What is the documented precedence between user home config, STREAMLIT_CONFIG, environment variables, and CLI flags? How should cross-platform teams keep configuration repeatable given differing OS default paths?
Streamlit does not automatically prefer a repository-local .streamlit/config.toml. The documented way to use a project-level file is to set the STREAMLIT_CONFIG environment variable to its absolute path. Without that variable, Streamlit reads the user-home config (~/.streamlit/config.toml on macOS/Linux, %USERPROFILE%\.streamlit\config.toml on Windows) or built-in defaults.
Based on documented Streamlit behavior, higher-priority sources override lower-priority ones:
streamlit run app.py --server.port 8503STREAMLIT_SERVER_PORT=8502STREAMLIT_CONFIGEnvironment variables override values from any config file, including the project file. CLI flags override environment variables.
.streamlit/config.toml in the repository root.STREAMLIT_CONFIG to the repository-relative path before running Streamlit.streamlit config show to verify effective values on each contributor's machine.#!/usr/bin/env bash
export STREAMLIT_CONFIG="$(pwd)/.streamlit/config.toml"
exec streamlit run "$@"
param([string[]]$Args)
$env:STREAMLIT_CONFIG = "$PWD\.streamlit\config.toml"
& streamlit run @Args
streamlit config show
Confirm the values match the repository file. Temporarily set STREAMLIT_SERVER_PORT or pass --server.port to confirm that environment variables and CLI flags take precedence as expected.
Please confirm the Streamlit version in use (streamlit --version). Newer releases may change config resolution or add automatic project-level support, so the version determines whether this guidance applies without adjustment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.