Commit f1c3928
committed
fix(release): bundle macos-bundle-updater.sh inside freenet crate
## Problem
`cargo install freenet --version 0.2.61` (and every subsequent
published version) fails to build from crates.io with an
`include_str!` "file not found" error on
`crates/core/src/bin/commands/update.rs`.
The line
`include_str!("../../../../../scripts/macos-bundle-updater.sh")`
walks five levels up — out of the freenet crate and into the
workspace-root `scripts/` directory. That path is valid in a
workspace checkout, but `cargo publish` only bundles files inside
the crate directory, so the script is absent from the registry
tarball and `cargo build` aborts before linking.
This blocks anyone installing freenet from the registry rather than
from source, including River's `cargo make sign-webapp` flow, which
shells out to `cargo install freenet` to obtain `fdev`.
## Approach
Move `scripts/macos-bundle-updater.sh` into the freenet crate at
`crates/core/scripts/macos-bundle-updater.sh` so `cargo publish`
ships it. Shorten the `include_str!` path accordingly.
Why this over alternatives — the script is the only file the
freenet binary embeds via `include_str!`; the rest of the
workspace-root `scripts/` directory is build/CI tooling that
shouldn't ride along in the published crate. A `[package].include`
allowlist or a `build.rs` that copies the file would add
configuration to maintain but would not surface the rule at the
filesystem level. Co-locating the embedded resource with its
consumer crate is the convention `cargo` was designed around.
## Testing
A bug in this class is the published `.crate` tarball missing an
embedded resource — that can't be caught by a runtime `#[test]`
alone, so this PR closes the gap with TWO tests:
1. **Unit test** — a new `#[test]` in `update.rs::tests`
re-includes the script via `include_str!` and asserts its shape
(shebang + header). Locks the path: any future refactor that
walks back outside the crate breaks compilation right here.
2. **CI gap test** — a new step in the `fmt_check` job runs
`cargo package --list -p freenet` and fails the build if
`scripts/macos-bundle-updater.sh` is missing from the would-be
tarball. This is the assertion that would actually have caught
the 0.2.61 regression before publish, and it generalizes to any
future embedded resource that gets added to the include list.
The workspace e2e harness
(`scripts/macos-bundle-swap-e2e.sh` and its `.c` stub comment)
was updated to point at the new path.
Local validation:
- `cargo fmt -- --check` clean.
- `cargo clippy -p freenet --bin freenet --tests -- -D warnings`
clean.
- New test passes:
`cargo test embedded_updater_script_resolves_inside_freenet_crate`.
- `cargo package --list -p freenet | grep -Fx scripts/macos-bundle-updater.sh`
resolves — the script is in the package contents.
The `#[cfg(target_os = "macos")]` gate on `write_updater_script`
is unchanged, so Linux builds remain unaffected.
## Why didn't CI catch this?
CI ran `cargo build` / `cargo test` against the workspace
checkout, where the workspace-root `scripts/` directory is on disk
and `include_str!` resolves. CI never built the crate from its
published `.crate` tarball, so the packaging gap was invisible. The
new `fmt_check` step closes that gap and would have failed the
0.2.61 release PR before it merged.
## Fixes
Unblocks `cargo install freenet` from crates.io and downstream
tooling that depends on it (River's `cargo make sign-webapp`).
Recommend cutting a `0.2.63` patch release after merge so
downstreams can stop vendoring around this.
[AI-assisted - Claude]
Entire-Checkpoint: 046245fb49051 parent ac2bc76 commit f1c3928
5 files changed
Lines changed: 45 additions & 4 deletions
File tree
- .github/workflows
- crates/core
- scripts
- src/bin/commands
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
151 | 178 | | |
152 | 179 | | |
153 | 180 | | |
| |||
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1552 | 1552 | | |
1553 | 1553 | | |
1554 | 1554 | | |
1555 | | - | |
| 1555 | + | |
1556 | 1556 | | |
1557 | 1557 | | |
1558 | 1558 | | |
| |||
1748 | 1748 | | |
1749 | 1749 | | |
1750 | 1750 | | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
1751 | 1765 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments