Bump rust nightly

From caffeinelabs/motoko · View interactive version

Bump rust nightly is an AI agent skill from the GitHub repository caffeinelabs/motoko. This skill guides you through bumping the `rustc-nightly` version used to build

How to use this skill

Skill file

Bumping the Rust Nightly Toolchain

This skill guides you through bumping the rustc-nightly version used to build

the Motoko RTS.

Files to Change

| File | What to update |

|------|----------------|

| nix/pkgs.nix | Nightly date string in rust-bin.nightly."YYYY-MM-DD" |

| nix/rts.nix | rustStdDepsHash (fixed-output derivation hash) |

| flake.lock | Run nix flake update rust-overlay to get latest overlay |

| rts/motoko-rts/Cargo.toml | Bump any exact-pinned crate versions if vendoring fails |

| rts/motoko-rts/Cargo.lock | Run cargo update in rts/motoko-rts/ |

| rts/motoko-rts-tests/Cargo.lock | Run cargo update in rts/motoko-rts-tests/ |

Step-by-Step

1. Reset the bump branch to master

The branch is <you>/bump-nightly-rustc, with your usual branch prefix (e.g.

gabor/). Don't derive it from $USER: on machines whose home directory

follows company naming policy, the login (e.g. gabor.greif) differs from the

prefix. Find the branch with git branch -a --list '*bump-nightly-rustc'.

The previous bump normally landed on master via squash-merge, so the

branch's old commits are orphaned: present locally, never ancestors of

origin/master, carrying a nightly date master already has. Then reset and

redo the bump fresh:

git fetch origin master
git checkout -B <you>/bump-nightly-rustc origin/master

Only if git log origin/master..<you>/bump-nightly-rustc shows real WIP

(rather than the last, already-merged bump, which

gh pr list --head <you>/bump-nightly-rustc --state merged confirms) keep it

and git rebase origin/master instead.

2. Update rust-overlay

cd ~/motoko && nix flake update rust-overlay

3. Set nightly date in `nix/pkgs.nix`

rust-nightly = self.rust-bin.nightly."YYYY-MM-DD".default.override {

Start with a recent date (e.g. a few weeks before today). If tests hang or

fail, bisect backwards by 2-4 weeks at a time.

4. Get new `rustStdDepsHash`

Set it to a dummy value first:

rustStdDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";

Then run:

nix build .#rts 2>&1 | grep "got:"

Paste the got: hash back into nix/rts.nix. Note: this hash is often

identical across several months of nightly dates.

5. Update Cargo lockfiles

cd rts/motoko-rts       && cargo update
cd rts/motoko-rts-tests && cargo update

If nix build .#rts fails with "failed to select version for foo = =X.Y.Z",

bump that exact pin in rts/motoko-rts/Cargo.toml and re-run cargo update foo.

6. Build and test

nix build .#rts

nix build hides the compiler output; to check a newer nightly for new

warnings (e.g. newly deprecated APIs), read the build log. It is colored, so

strip the ANSI codes first, or ^warning never matches:

nix log "$(nix path-info --derivation .#rts)" | sed 's/\x1b\[[0-9;]*m//g' | grep '^warning'

Watch for compiler errors — common ones encountered and their fixes:

`.json target specs require -Zjson-target-spec`

Add -Zjson-target-spec to NIGHTLY_CARGO_OPTIONS in rts/Makefile.

`target-pointer-width: invalid type: string "32", expected u16`

Change "target-pointer-width": "32" → "target-pointer-width": 32 (integer)

in rts/motoko-rts/wasm64-none-shared.json.

`panic_immediate_abort is now a real panic strategy`

Remove panic_immediate_abort from -Zbuild-std-features and add

-Zunstable-options -Cpanic=immediate-abort to RTS_RELEASE_COMPILE_FLAGS.

Use NIGHTLY_RELEASE_CARGO_OPTIONS in rts/Makefile.

`failed to select version for rustc-literal-escaper = "^0.0.7"`

The vendored std deps are stale — re-run the rustStdDepsHash probe (step 4).

7. `.#rts` vs `.#rts-checked` on macOS

flake.nix distinguishes two derivations:

test suite, so nix build .#rts` is fast and is what you iterate on locally.

exercises the wasm64 debug tests under wasmtime in the nix sandbox, which

can be ~10× slower than Linux (likely due to XProtect/MRT intercepting

wasm memory ops). Triggered in CI by the nightly-macos-test workflow's

rts-checked job; not normally needed locally.

Local bump loop: nix build .#rts until green. Then push and **manually

dispatch** nightly-macos-test to exercise the slow rts-checked path — it

triggers only on schedule + workflow_dispatch, so a branch push does NOT

run it automatically (see step 9).

If nightly-macos-test jobs fail or time out, re-trigger — each run

caches more derivations, so subsequent runs make progress:

gh workflow run nightly-macos-test.yml --repo caffeinelabs/motoko --ref <you>/bump-nightly-rustc

Two known failure modes that are not code regressions:

  1. OOM on systems-go-tests — fails in ~4 min with `patch: **** out of

memory while building ocaml4.14.2-merlin-*` from scratch (before any

tests run). Runner memory pressure. Re-trigger.

  1. Slow common-tests — same XProtect/wasm64 malaise; it

eventually finishes. Be patient, don't cancel.

8. Commit

chore: bump rustc-nightly to YYYY-MM-DD

- nightly date: old → new
- rust-overlay: updated to YYYY-MM-DD
- rustStdDepsHash: updated for new nightly
- rts/Makefile: <list any Makefile fixes>
- wasm64-none-shared.json: <if changed>
- motoko-rts: bump foo =X.Y.Z → =X.Y+1.Z
- cargo update: motoko-rts, motoko-rts-tests

9. Push, open a PR and watch CI

git push --force-with-lease origin <you>/bump-nightly-rustc
# nightly-macos-test does NOT run on push — dispatch it explicitly:
gh workflow run nightly-macos-test.yml --repo caffeinelabs/motoko --ref <you>/bump-nightly-rustc
gh run watch <run-id> --repo caffeinelabs/motoko

Pushing the branch alone runs no Linux CI either: test.yml runs on

push only for master, otherwise on pull_request. Open the PR (a draft

until both sides are green) to get the Linux matrix.

Gotcha — first push after a reset (step 1): if the old remote branch was

deleted when the previous bump merged, --force-with-lease fails with

! [rejected] ... (stale info) because your local

origin/<you>/bump-nightly-rustc tracking ref is stale (points at a branch

that no longer exists remotely). Fix:

git remote prune origin
git push -u origin <you>/bump-nightly-rustc   # plain push re-creates the branch

Makefile Structure (as of 2026-10-16, unchanged since 2026-04-01)

RTS_COMPILE_FLAGS=-C target-feature=+bulk-memory
RTS_RELEASE_COMPILE_FLAGS=$(RTS_COMPILE_FLAGS) -Zunstable-options -Cpanic=immediate-abort
NIGHTLY_CARGO_OPTIONS=-Zjson-target-spec -Zbuild-std=core,alloc
NIGHTLY_RELEASE_CARGO_OPTIONS=$(NIGHTLY_CARGO_OPTIONS) --release -Zbuild-std-features="optimize_for_size"

Notes

probe it (step 4). Observed: ZMCepUZN… for nightlies 2026-02-15 to

2026-03-31, OTZ3LG84… at 2026-07-25, 5WWAIRvi… at 2026-10-10.

cargo update in motoko-rts-tests moves it and the vendor fails.

wasmtime version doesn't regress performance between nixpkgs bumps.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.