-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update getting-started.sh to install the specific rust version specified in .github/env file #5317
base: master
Are you sure you want to change the base?
Update getting-started.sh to install the specific rust version specified in .github/env file #5317
Conversation
… specified in .github/env file
User @Wolfenheimm, please sign the CLA here. |
…sion wasn't found.
…thub.com/Wolfenheimm/polkadot-sdk into wolfenheimm/getting-started-rust-version
Updated the code to include installing the latest version of rust if the required version wasn't found.I've chosen to do a check on the version that is retrieved for an empty string or if the string doesn't contain dots - if the variable passes those constraints, it just defaults to the latest version of rust. My original fix didn't take into account for a bad version fetch. |
scripts/getting-started.sh
Outdated
@@ -114,8 +114,16 @@ if command -v rustc >/dev/null 2>&1; then | |||
echo "\n✅︎🦀 Rust already installed." | |||
else | |||
if prompt_default_yes "\n🦀 Rust is not installed. Install it?"; then | |||
echo "🦀 Installing via rustup." | |||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |||
version=`cat ../.github/env | grep IMAGE | cut -d'-' -f3` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems flaky to me, any change to the other file will break this.
I think the nicer thing to do is to store this in a nicely discover-able variable, and have it be used in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect @alvicsam to know if my worry here is real or not, perhaps it is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine as a temporary solution for now, in the future it should be switched to using rust-toolchain.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the future it should be switched to using rust-toolchain.toml
is this tracked in an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, here: #5335
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for @alvicsam for chiming in.
Review required! Latest push from author must always be reviewed |
@alvicsam & @kianenigma, sorry for the inconvenience here, I just wanted to keep the branch updated and clear some fails - will refrain from touching it from now on. |
scripts/getting-started.sh
Outdated
@@ -114,8 +114,16 @@ if command -v rustc >/dev/null 2>&1; then | |||
echo "\n✅︎🦀 Rust already installed." | |||
else | |||
if prompt_default_yes "\n🦀 Rust is not installed. Install it?"; then | |||
echo "🦀 Installing via rustup." | |||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |||
version=`cat ../.github/env | grep IMAGE | cut -d'-' -f3` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also, this won't if you are not in the polkadot sdk repo right? this .github/env
is not available otherwise.
In other words, have you tried the outcome, and does it actually works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just now noticing that the curl, even if the version is defined, will always grab latest.
It requires something like:
rustup default 1.77.0
I pushed some changes.
Also you are right in that if you run this script from outside the repo, you will not get the required version, and it will default to using latest, tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that 99% of the users running this script are outside of the repo (recall the script is meant to onboard a new user), so I think the solution presented here is really marginally better than not having it.
I think that having a rust-toolchain file is probably the better approach. In that case all devs can inspect this file and adjust their rust versions accordingly. Hopefully IDEs can even automatically warn you about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, and it could create complications if my proposed script (God forbid) finds "1.2.0" and installs + uses that version.
It might then be useful to add the following line to fetch the toml file directly from polkadot-sdk, once it's added in:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/paritytech/polkadot-sdk/contents/rust-toolchain.toml | grep 'channel =' | awk -F'"' '{print $2}'
I pushed an example of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kianenigma - After some guidance from Nazar, a decision was made to pull the rust-toolchain.toml
from polkadot-sdk straight into the minimal-template fetched at the end of the script, which should satisfy the requirement. This PR now contains a base toml file with the required version to support this.
scripts/getting-started.sh
Outdated
echo "🦀 Setting up Rust environment." | ||
rustup default stable | ||
rustup default $version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command is not necessary at all, it'll use version from rust-toolchain.toml
. In fact by running this command you revert the effect of rust-toolchain.toml
, inviting user confusion down the line as the version in rust-toolchain.toml
keeps changing, while this override stays the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I originally decided to pull the toml file in completely, however Kian raised a point earlier that folks could grab this script and run it from anywhere, not necessarily in their project, but simply as a means to set up their dev env. Suppose that they don't have a rust-toolchain.toml
in their project, then it would use the latest stable - which we want to avoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're right, since the script potentially brings in the minimal template, maybe the rust-toolchain.toml
could be added to the minimal template as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, having this line alone defeats the purpose of having rust-toolchain.toml
completely. They will get an unexpected version of the toolchain and if they are really as unexperienced as this script assumes, they will have no idea why.
Maybe consider copying rust-toolchain.toml
if it does not yet exists or something, though except for contributions to polkadot-sdk they don't have to use the same exact version, any current or newer stable toolchain will work just fine, hence suggestion to remove this completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the input, I've pushed some changes to accommodate that. It will pull the toml directly into the minimal template folder that gets generated by the script.
Co-authored-by: Nazar Mokrynskyi <[email protected]>
…thub.com/Wolfenheimm/polkadot-sdk into wolfenheimm/getting-started-rust-version
scripts/getting-started.sh
Outdated
echo "🦀 Setting up Rust environment." | ||
rustup default $version | ||
rustup default stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is still setting default toolchain 😕
This line should not be necessary, just like the rest of commands in this block, rust-toolchain.toml
will take care of it all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was so sure I fixed that... One moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the entire block, as discussed
Good morning @kianenigma & @alvicsam, You two and @nazar-pc have all raised some fantastic points when I picked this up, big thanks to all of you -> I believe this solves both issues (#5263 and #5335). I tested the fetch via test on a different repo that had a |
@kianenigma would you need any extra features for this? |
Changed the rust version to reflect [paritytech#5676](paritytech#5676)
We need another review @nazar-pc, @alvicsam, @kianenigma, but perhaps we wait for #5676👍 |
Description
Add a means to fetch and install the expected rust version defined in .github/env for the getting-started script, as requested in Issue #5263. Discussions were made and the use of a
rust-toolchain.toml
file was decided.Integration
The implementation relies on fetching the rust-toolchain.toml found within the polkadot-sdk repo.
Review Notes
rust-toolchain.toml
file - but an issue has been made to create one #5335. The file has been added to this PR with basic requirements.Checklist
T
required)