Skip to content

replace <commit> placeholder with the actual commit in vendoring error #120499

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

Closed
onur-ozkan opened this issue Jan 30, 2024 · 7 comments · Fixed by #139060
Closed

replace <commit> placeholder with the actual commit in vendoring error #120499

onur-ozkan opened this issue Jan 30, 2024 · 7 comments · Fixed by #139060
Assignees
Labels
E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@onur-ozkan
Copy link
Member

onur-ozkan commented Jan 30, 2024

Currently, vendoring error related to missing vendor directory is as follows:

eprint('ERROR: vendoring required, but vendor directory does not exist.')
eprint(' Run `cargo vendor {}` to initialize the '
'vendor directory.'.format(sync_dirs))
eprint(' Alternatively, use the pre-vendored `rustc-src` dist component.')
eprint(' To get a stable/beta/nightly version, download it from: ')
eprint(' '
'https://forge.rust-lang.org/infra/other-installation-methods.html#source-code')
eprint(' To get a specific commit version, download it using the below URL,')
eprint(' replacing <commit> with a specific commit checksum: ')
eprint(' '
'https://ci-artifacts.rust-lang.org/rustc-builds/<commit>/rustc-nightly-src.tar.xz')
eprint(' Once you have the source downloaded, place the vendor directory')
eprint(' from the archive in the root of the rust project.')

It would be more appropriate to replace the placeholder in the URL provided in error message with an actual commit hash (The one we use for downloading ci rustc. See fn download_ci_rustc_commit). This way, the link can be copied and used without requiring extra effort to manually replace the placeholder with the commit hash.

@onur-ozkan onur-ozkan added E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 30, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 30, 2024
@onur-ozkan onur-ozkan removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 30, 2024
@carlosguealv
Copy link

I'd like to work on this

@carlosguealv
Copy link

@onur-ozkan Can you assign me to this issue please?

@onur-ozkan
Copy link
Member Author

I'd like to work on this

Amazing!

@onur-ozkan Can you assign me to this issue please?

Sure, I just did. You can also claim issues using rustbot (see https://rustc-dev-guide.rust-lang.org/rustbot.html?highlight=cla#issue-claiming).

@carlosguealv
Copy link

Perfect, thank you!

@onur-ozkan
Copy link
Member Author

Some instructions about what can be done for this task:

1- If source is not a git tree, leave the placeholder as is.

2- Use git to obtain the commit hash of the CI Rustc (the one we use for download-rustc config). For guidance on how to get this commit hash, there is a good reference in bootstrap/src/core/config/config.rs:

fn download_ci_rustc_commit(&self, download_rustc: Option<StringOrBool>) -> Option<String> {
// If `download-rustc` is not set, default to rebuilding.
let if_unchanged = match download_rustc {
None | Some(StringOrBool::Bool(false)) => return None,
Some(StringOrBool::Bool(true)) => false,
Some(StringOrBool::String(s)) if s == "if-unchanged" => true,
Some(StringOrBool::String(other)) => {
panic!("unrecognized option for download-rustc: {other}")
}
};
// Handle running from a directory other than the top level
let top_level = output(self.git().args(&["rev-parse", "--show-toplevel"]));
let top_level = top_level.trim_end();
let compiler = format!("{top_level}/compiler/");
let library = format!("{top_level}/library/");
// Look for a version to compare to based on the current commit.
// Only commits merged by bors will have CI artifacts.
let merge_base = output(
self.git()
.arg("rev-list")
.arg(format!("--author={}", self.stage0_metadata.config.git_merge_commit_email))
.args(&["-n1", "--first-parent", "HEAD"]),
);
let commit = merge_base.trim_end();
if commit.is_empty() {
println!("ERROR: could not find commit hash for downloading rustc");
println!("HELP: maybe your repository history is too shallow?");
println!("HELP: consider disabling `download-rustc`");
println!("HELP: or fetch enough history to include one upstream commit");
crate::exit!(1);
}
// Warn if there were changes to the compiler or standard library since the ancestor commit.
let has_changes = !t!(self
.git()
.args(&["diff-index", "--quiet", &commit, "--", &compiler, &library])
.status())
.success();
if has_changes {
if if_unchanged {
if self.verbose > 0 {
println!(
"WARNING: saw changes to compiler/ or library/ since {commit}; \
ignoring `download-rustc`"
);
}
return None;
}
println!(
"WARNING: `download-rustc` is enabled, but there are changes to \
compiler/ or library/"
);
}
Some(commit.to_string())
}

3- Replace the placeholder with the commit hash obtained in the previous step.

@carlosguealv
Copy link

Sounds good! Will commit as soon as I get it to work!

@Shourya742
Copy link
Contributor

@rustbot claim

@rustbot rustbot assigned Shourya742 and unassigned carlosguealv Mar 25, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 29, 2025
…it-with-actual-value, r=onur-ozkan

replace commit placeholder in vendor status with actual commit

closes: rust-lang#120499
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 1, 2025
…it-with-actual-value, r=onur-ozkan

replace commit placeholder in vendor status with actual commit

closes: rust-lang#120499
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 1, 2025
…it-with-actual-value, r=onur-ozkan

replace commit placeholder in vendor status with actual commit

closes: rust-lang#120499
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 1, 2025
…-with-actual-value, r=<try>

replace commit placeholder in vendor status with actual commit

closes: rust-lang#120499

try-job: dist-x86_64-illumos
@bors bors closed this as completed in 8420a55 Apr 2, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 2, 2025
Rollup merge of rust-lang#139060 - Shourya742:2025-03-28-replace-commit-with-actual-value, r=onur-ozkan

replace commit placeholder in vendor status with actual commit

closes: rust-lang#120499

try-job: dist-x86_64-illumos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
4 participants