I installed Rust version 1.61 some time ago. Yesterday I wanted to test a Rust application called Annou when I want to launch an example I get the following error:
error: package `rustix v0.38.11` cannot be built because it requires rustc 1.63 or newer, while the currently active rustc version is 1.61.0
.
I installed the latest version of Rustup. However, if I look at the Rust version with the rustc --version
command, it returns version 1.61. Would someone be so kind to tell me how to fix this problem?
Is your rustc
installed through rustup
? You can check e.g. via which rustc
on Linux/MacOS or where rustc
on Windows that your rustc
command is the one that rustup
places into the .cargo/bin
path in your home directory.
If it isn’t the rustc
installed via rustup
, but e.g. one from a system package, it’s usually best practice to just uninstall that package. Possibly (and perhaps even alternatively) you could adjust the PATH
environment variable to just make rustc
refer to the right place. (“.cargo/bin/rustc” in your HOME directory; ideally the whole .cargo/bin
directory should be in the path).
If it is the one installed via rustup
, just a very long time ago, then all that’s needed might be rustup update
. If rustup
isn’t configured to have the latest stable
as active toolchain, then that something to look into as well; rustup show
can give an overview over what’s installed and what’s the “active” toolchain.
Have you ran rustup update
and/or rustup default stable
?
You might have the latest rustup, but still an older Rust set as default.
hello, i don't remember when i installed Rust on my computer, because i did it some time ago to test this Language. i did what you wrote to me, when i write which rustc
/opt/local/bin/rustc
when I type rustup update
I get back :
(base) sdcarr@MacBook-Pro-de-Silvino my-project % rustup update
**info:** syncing channel updates for 'stable-aarch64-apple-darwin'
**stable-aarch64-apple-darwin unchanged** - rustc 1.72.0 (5680fa18f 2023-08-23)
**info:** cleaning up downloads & tmp directories
**info:** self-update is disabled for this build of rustup
**info:** any updates to rustup will need to be fetched with your system package manager
when I type rustup show
:
(base) sdcarr@MacBook-Pro-de-Silvino my-project % rustup show
**Default host:** aarch64-apple-darwin
**rustup home:** /Users/sdcarr/.rustup
stable-aarch64-apple-darwin (default)
Finally, when I write rustc --version
:
rustc 1.72.0 (5680fa18f 2023-08-23)
(base) sdcarr@MacBook-Pro-de-Silvino my-project % rustc --version
rustc 1.61.0
To clarify: Is the reported rustc
version different when running it from your home directory vs from the my-project
? (Because if that’t the case, there could be multiple reasons for that that we can address.)
From a project:
sdcarr@MacBook-Pro-de-Silvino my-project % rustc --version
rustc 1.61.0
From my home
(base) sdcarr@MacBook-Pro-de-Silvino ~ % rustc --version
rustc 1.61.0
Ah, okay, nevermind then
I’m not super familiar with MacOS; given that an /opt/local/bin
path is involved, I suppose your Rust is installed through some kind of package manager?
Some light googling later… I suppose it might be homebrew
? If you use homebrew, does brew list
contain (one or multiple) rust-related packages? (E.g. anything in your brew list
output named similar to rust
or rustup
; I’m not asking you do share the whole output of all your installed packages ).
Assuming it’s through homebrew, I’m not familiar with the rust packages there. You could try uninstalling some of them, in case there’s multiple effectively conflicting ones, e.g. keeping only a “rustup” package – or you could consider uninstalling all of them and once that’s done re-installing rustup afterwards via the command from https://rustup.rs/
Brew List -> rustup-init is the only rust I have on the list
Hmm, I wonder what this /opt/local/bin/rustc
belongs to. From what I could read here in that location, it wouldn’t be the one managed by rustup
.
You could also try just changing / re-ordering your PATH to have ~/.cargo/bin
take precedence
Oh!! I’ve had a little conversation with ChatGPT and apparently things in /opt/local/bin
may be related to macports, not homebrew? If so, maybe something like sudo port uninstall rust
is all that’s needed to remove that second Rust installation? Excuse me if this happens to be totally off – as mentioned before, I don’t know much about macos
Thank you! Finally was macports installation.
Now I get this:
% rustc --version
rustc 1.72.0 (5680fa18f 2023-08-23)
Great I hope the application you’re trying to compile/install works now, too!
One question, I come from python and Supercollider (audio)..I've learned a little c++..I see that Rust has things from c++ and Javascript, isn't it? Is it a good language to learn? What positive things about c++ do you see?
Rust should be a lot easier to master than C++ because it removes many pitfalls, and C++ suffers a lot from many parts of the language (and library) design that are the way they are due to historical reasons and compatibility. (This is mainly just saying, Rust is younger, and that has advantages on its own.)
Compared to languages like Javascript, most people would note that there are performance benefits… but it’s not the only thing. Rust is in many ways somewhat harder to learn than your typical more dynamical languages though.
In terms of influences from other languages, I’d say – besides obviously many concepts from C++
– Rust has a significant influence from functional programming. Like functional programming, Rust limits mutability, though less severely (i.e. in a more accurate manner “only when it’s necessary”, identifying the core idea that mutation is completely fine for data that isn’t also shared). And concretely, the type system and trait system has a huge influence from Haskell in particular.
My personal learning experience when learning Rust (about 3-4 years ago) was that from prior knowledge on C++ (which I knew a bit) and Haskell (which I knew quite well), I felt like I was relatively familar with most of the concepts that Rust has taken from other languages… be it: strict typing, generics, programming without the full OOP+inheritence game, algebraic data types (in Rust called enum
), the trait system, destructors & RAII, probably more I’m forgetting.
What made it very worthwhile as a language to learn is that beyond this it offers a number of novel concepts I had never seen before.
From just improvements on existing concepts, such as the way the module system works; the way orphan rules work; the way integer types work (using explicit sizes by default, not offering an unnecessarily overused “int” type with platform-dependent size); the macro system (admitted, that’s probably an area where there’s a lot more prior work I wasn’t so familiar with, so I guess I should qualify my C++&Haskell knowledge did not teach all things not original to Rust); I guess the build-system cargo
is also quite neat, I don’t know if – and how – it’s better than those of other languages (I do feel it’s better than what Haskell has, and for C++ … I don’t know if C++ even has a commonly used build system at all, but in any case, nothing in C/C++ comes as fully included and well-promoted as cargo
for Rust)…
… and then we can come to completely novel ideas (at least as far as I was concerned – who knows what more niche research languages might have already had to some degree): the ownership system and the borrow checker, as a way to have C++-style memory management without any chance of double-free or reading invalid memory; the story of thread-safety via the Send
and Sync
traits – it honestly takes some time to learn and appreciate just how effective this system is, turning multi-threaded programming from an advanced topic with many pitfalls into something almost trivial. (Maybe “almost trivial” is too extreme, but the term “fearless concurrency” is very very true.)
TL;DR, I think Rust is a good language to learn, if nothing else to get exposed to interesting and powerful new concepts in programming langues – as well as to a collection of established concepts you may or may not be familiar with depending on whether you’ve looked into functional programming.
I personally also like Rust as a language to use, but that’s a personal choice, and I think learning it, at least to some degree, is worthwhile anyways.
If you want to hear more people give a quick teaser / intro / look into Rust, I can recommend some really nice videos on YouTube. (Okay, “quick” means some hour-long video; but realistically, that’s not actually a lot of time, and one cannot really expect to actually take away too much from shorter 5 or 10 minutes intros that certainly exist, too.)
The first this one:
and then also this one:
They are IMO must-watch for anyone interested in Rust… though the latter is conceptually requiring a little bit of familiarity with C++ to be easier to follow (which seems to apply to you).
Then in case you are interested in actually reading about what the language is like / learning it, the link to start at is https://www.rust-lang.org/learn, where you’ll find in particular “The book” which is what I myself focused on as a first learning material – but there’s also more example and exercise rich material which may appeal more to people who prefer that, or may be valuable as a complementary resource.
Positive things about C++ is a thing I haven’t really addressed. I feel somewhat under-qualified to answer this with full confidence as I’m not that familiar with it after all – but C++ certainly has a lot of good properties, too. It does have a long legacy, but it’s quite successful, and as far as I understand, there’s a huge community that does try to further modernize it in the future, too. One of it’s pros is also that there’s a lot of software written in it, and a lot of libraries and tooling, i.e. a fully mature ecosystem, so you can essentially realize almost any kind of software in C++ today.
Obviously, the features Rust “copied” from C++ must be good language features, too; and it’s more typically OOP than Rust (in particular allowing true inheritance) which many people may really prefer. C++ also is less strict during compilation – i.e. Rust is a bit infamous for you having to “fight” the compiler (the borrow-checker in particular) in order to get your program to be accepted. This may be a trade-off though, as an incorrect program being accepted in C++ may lead to the need to do more debugging down the line. This is about where my limited C++ expertise prevents me from giving too many further insights
Thank you very much for your explanation. The times I tried Rust a bit, I found it intimidating, especially when you are faced with data types and variables. But I think I'm going to dive right into learning it, although I don't have much time right now and the learning curve seems steep. Furthermore, what brought me here is the Rust Framework, which I found very interesting and lighter than the c++ Openframeworks.
A tender greeting !
I've been programming Python for about 20 years, and discovered Rust only about half a year ago - in the HuggingFace ML code which has its tokenizers in Rust (and then has that wrapped up for Python). Since I discovered Rust, I started pestering my managers and co-workers to also use Rust because of the double promise of performance + safety. (I also found out that there was already a vibrant Rust culture in other parts of the company I worked for...go figure...)
@steffahn wrote
… and then we can come to completely novel ideas (at least as far as I was concerned – who knows what more niche research languages might have already had to some degree): the ownership system
This was also an eye opener for me - but now, with a bit of hindsight, I believe that the concepts of ownership and lifetimes are not entirely new. What is new, imo, is that Rust elevates those concepts, makes them central to its core design, and kind of forces you to be explicit about them.
Applying lifetimes and move semantics in actual code is still a bit painful, though...
If your Rust version magically changes depending on which directory you're in, your directory has a rustup toolchain override file.