The sysroot can't be built for the Stable channel

Hello guys!

I am new to the world of rust and in particular to rust drivers.

I'm trying to compile an example driver found on the web but for some reason I am not able to achieve it

When I try to run the command:

cargo xbuild --target x86_64-linux-kernel-module

I get the following error:

error: The sysroot can't be built for the Stable channel. Switch to nightly.

Reading about it on the web, I think I have understood that I must use the nightly version in order to compile. I have followed several steps including downloading the nightly version toolchain and setting it up.

rustup toolchain install nightly

info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'

nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.51.0-nightly (c5a96fb79 2021-01-19)

rustup override set nightly

If I run: rustup show

I get:
Default host: x86_64-unknown-linux-gnu
rustup home: /path/to/snap/rustup/common/rustup

nightly-x86_64-unknown-linux-gnu (directory override for '/path/to/my/directory/linux-kernel-module-rust')
rustc 1.51.0-nightly (c5a96fb79 2021-01-19)

But, when I try to compile again I keep getting the same error.

Fun fact is that when I run: rustc --version

I get: rustc 1.43.0

Shouldn't it be rustc 1.51.0-nightly?

Any help will help me a lot.

Thank you!

What is the output of

$ which rustc

on your system? There's probably another rustc binary on your PATH that's stepping on the toes of the rustup-managed version, which lives in ~/.cargo/bin.

which -a rustc will show all of them in your PATH, in the order they are found.

2 Likes

the output for whic rustc and which -a rust is the same, it's /usr/bin/rustc.

How can I fix this?

If you installed Rust through your distro's package manager, uninstall that and just use rustup. Packaged versions of Rust tend to be significantly out of date. (And make sure ~/.cargo/bin is in your PATH.)

1 Like

Thanks guys!! Removing the other binary resolved the problem!

Thanks!!!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.