Skip to content

rust(feat): read the sift-cli config file from SIFT_CONFIG_FILE - #893

Merged
bill-sift merged 1 commit into
mainfrom
rust/sift-cli-config-file-env
Nov 17, 2026
Merged

bill-sift merged 1 commit into
mainfrom
rust/sift-cli-config-file-env

Conversation

@bill-sift

Copy link
Copy Markdown
Contributor

Description

sift-cli finds sift.toml only through dirs::config_dir(). In Sift Agents the session's sift.toml lives in a private temp directory because the root filesystem is read-only, and today the only way to point sift-cli at it is XDG_CONFIG_HOME, which redirects config for every tool in the agent's shell. sift_client already reads SIFT_CONFIG_FILE (config_file_path in python/lib/sift_client/_internal/credentials.py), so sift-cli now does too.

  • SIFT_CONFIG_FILE wins when it is set and non-empty, and its path is used as given, with no ~ expansion. Otherwise sift-cli uses sift.toml in the user config directory, as before. This matches sift_client. Every command resolves the file through get_config_file_path, so config create and config update write to that path, and every message that prints the path shows it.
  • Reading goes through one loader, load_config, which returns None only for a missing file. Any other failure names the path and keeps the OS error. Before, API commands printed only "failed to read config file", and a directory at the path made config create report an existing file.
  • write_config errors name the directory or file that could not be created or written. config create still creates missing parent directories.
  • Docs and changelog.

The single loader changes a few messages. Non-interactive config create on a file that isn't valid TOML now reports the parse error instead of "already exists". config where errors on an unreadable file instead of printing its path. Parse errors now read "config file '' is invalid TOML" everywhere.

agent install doesn't pass the variable to MCP clients, so sift-cli mcp sees it only when the client runs with it set. In Sift Agents the MCP server inherits the agent server's environment, so that case needs no changes.

Follow-ups, out of scope here: sift_connect's Credentials::Profile loader still reads dirs::config_local_dir()/sift.toml and ignores the variable, and write_config writes the file as 0644 and not atomically.

Verification

Unit tests cover SIFT_CONFIG_FILE set, empty, and unset, the loader on a missing file, a file, and a directory, and parent directory creation. cargo fmt --check --all, cargo clippy --all-features, and cargo test --all-features pass (1,410 tests).

Manual run of a debug build, with <dir> standing in for a temp directory (output trimmed):

$ export SIFT_CONFIG_FILE=<dir>/a/b/sift.toml
$ sift-cli config where
error: '<dir>/a/b/sift.toml' not found.
$ sift-cli config create
An empty config file has been created at '<dir>/a/b/sift.toml'.
$ sift-cli config update -g https://grpc.example.net -r https://api.example.net -k sift_test_key_1234 --app-uri https://sift.example.net
Saved profile 'default'.
$ sift-cli config where
<dir>/a/b/sift.toml

$ SIFT_CONFIG_FILE=<dir> sift-cli ping
error: failed to read config file '<dir>'

Caused by:
    Is a directory (os error 21)

$ SIFT_CONFIG_FILE= sift-cli config where
~/Library/Application Support/sift.toml

@bill-sift
bill-sift merged commit 6b22bc9 into main Nov 17, 2026
22 checks passed
@bill-sift
bill-sift deleted the rust/sift-cli-config-file-env branch November 17, 2026 20:35
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