From f9f9b969bbc6852b35d2121a217162907f5b2629 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 7 Feb 2021 19:07:41 +0100 Subject: [PATCH] Specify dependency on `rust-src` component in `rust-toolchain` --- .../edition-3/posts/01-minimal-kernel/index.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/blog/content/edition-3/posts/01-minimal-kernel/index.md b/blog/content/edition-3/posts/01-minimal-kernel/index.md index 23cca89f..446b8d03 100644 --- a/blog/content/edition-3/posts/01-minimal-kernel/index.md +++ b/blog/content/edition-3/posts/01-minimal-kernel/index.md @@ -637,7 +637,19 @@ unable to build with the standard library, try: It still fails. The problem is that cargo needs a copy of the Rust source code in order to recompile the `core` crate. The error message helpfully suggest to provide such a copy by installing the `rust-src` component. -After running the suggested `rustup component add rust-src` command, the build should now finally succeed: +Instead of running the suggested `rustup component add rust-src` command, we an also record the dependency on the `rust-src` component in our `rust-toolchain` file: + +```toml +# in rust-toolchain + +[toolchain] +channel = "nightly" +components = ["rust-src"] +``` + +This way, `rustup` will automatically download the required components so that no manual steps are necessary. + +After installing the `rust-src` component (either manually or automatically), the build should finally succeeds: ``` > cargo build --target x86_64-blog_os.json -Z build-std=core