From 63353f1e800bab364446ce8bb49f9bc87076baba Mon Sep 17 00:00:00 2001 From: grabowski Date: Sat, 17 Oct 2026 22:39:45 +0700 Subject: [PATCH] build(rust): declare rust-version 1.88; rustup setup for the server --- rust/Cargo.toml | 3 +++ rust/README.md | 17 +++++++++++++---- rust/collector/Cargo.toml | 1 + scripts/install_collector.sh | 3 ++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 454ab99..21a0f2b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -3,7 +3,10 @@ resolver = "3" members = ["collector"] [workspace.package] +# 1.88: edition 2024 let-chains, and dependencies (home, icu_*) need it. Distro +# cargo packages are older: install the toolchain with rustup (rust/README.md). edition = "2024" +rust-version = "1.88" license = "MIT" publish = false repository = "https://git.b4l.co.th/B4L/Northern-Thailand-Ping-River-Monitor" diff --git a/rust/README.md b/rust/README.md index 1610284..80f6b99 100644 --- a/rust/README.md +++ b/rust/README.md @@ -72,12 +72,21 @@ Linux needs `pkg-config` and `libssl-dev`. ### Deploy -On the server, after `git pull` (the Python side of the switch ships in the -same commit): +Needs Rust >= 1.88. Distro `cargo` packages are older (`resolver 3 is not +valid` / `edition 2024` errors), so install the toolchain once with rustup: ```bash -cargo build --release --locked --manifest-path rust/Cargo.toml # as a normal user, - # or BIN= +apt-get install -y build-essential pkg-config libssl-dev curl +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal +. "$HOME/.cargo/env" # puts ~/.cargo/bin before /usr/bin/cargo +cargo --version # >= 1.88 +``` + +Then on the server, after `git pull` (the Python side of the switch ships in +the same commit): + +```bash +cargo build --release --locked --manifest-path rust/Cargo.toml # or BIN= sudo bash scripts/install_collector.sh # install + dry run, nothing switched sudo bash scripts/install_collector.sh --cutover # Rust collects from now on sudo bash scripts/install_collector.sh --rollback # back to Python collection diff --git a/rust/collector/Cargo.toml b/rust/collector/Cargo.toml index d27749e..07e5fdd 100644 --- a/rust/collector/Cargo.toml +++ b/rust/collector/Cargo.toml @@ -3,6 +3,7 @@ name = "ping-collector" version = "0.1.0" description = "Ping River Monitor data collector: RID gauges, HII/ThaiWater, RID dams, Open-Meteo rain -> PostgreSQL" edition.workspace = true +rust-version.workspace = true license.workspace = true publish.workspace = true repository.workspace = true diff --git a/scripts/install_collector.sh b/scripts/install_collector.sh index b4ca649..8dfd1a6 100755 --- a/scripts/install_collector.sh +++ b/scripts/install_collector.sh @@ -12,7 +12,8 @@ # linux-x86_64" CI artifact) or from rust/target/release/ping-collector, built # beforehand as a normal user: # cargo build --release --locked --manifest-path rust/Cargo.toml -# (needs rustup, pkg-config and libssl-dev). +# (needs Rust >= 1.88 from rustup -- distro cargo is too old -- plus pkg-config +# and libssl-dev; see rust/README.md). set -euo pipefail APP_DIR="${APP_DIR:-/opt/thailand-water-monitor}"