Write cargo's config, don't append to a cached one

b46a4bd · Gabriel Morell · 2026-09-16 19:34

3 files +13 -2
Message
{commit_body(@commit)}

Files changed

modified .forgejo/workflows/publish.yml
+13 −2
@@ -82,12 +82,23 @@ jobs:
82 82 # this goes in CARGO_HOME rather than ./.cargo/config.toml on purpose,
83 83 # because `cargo publish` refuses a dirty working tree and writing into
84 84 # the checkout would make it one.
85 + #
86 + # Written whole (`>`), not appended (`>>`). CARGO_HOME is restored from
87 + # the cache, so appending accumulated a second copy of the stanza on
88 + # every run after the first, and cargo rejects a duplicate key outright:
89 + #
90 + # could not parse TOML configuration in …/.home/.cargo/config.toml
91 + # TOML parse error at line 5, column 13: duplicate key
92 + #
93 + # That failed in one second, before the registry was ever contacted,
94 + # which is why it looked like an auth problem. The file is entirely
95 + # ours — rustup writes `env` and `bin/`, never this — so owning it
96 + # outright is both safe and idempotent.
85 97 - name: Point cargo at the forge
86 98 run: |
87 99 set -euo pipefail
88 100 mkdir -p "$CARGO_HOME"
89 − cat >> "$CARGO_HOME/config.toml" <<TOML
90 −
101 + cat > "$CARGO_HOME/config.toml" <<TOML
91 102 [registries.$REGISTRY_NAME]
92 103 index = "sparse+$FORGE_URL/pkg/cargo/${{ github.repository }}/"
93 104 TOML

Parents: 297fe1b