Skip to content

OUT_DIRs value has changed in nightly. - #2223

Closed
ltratt wants to merge 1 commit into
ykjit:masterfrom
ltratt:out_dir_change
Closed

OUT_DIRs value has changed in nightly.#2223
ltratt wants to merge 1 commit into
ykjit:masterfrom
ltratt:out_dir_change

Conversation

@ltratt

@ltratt ltratt commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This was changed in rust-lang/cargo#17272. This might change back for all I know, but at least for now this unbreaks things.

@ltratt
ltratt enabled auto-merge July 31, 2026 17:21
@ltratt
ltratt added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
This was changed in rust-lang/cargo#17272. This
might change back for all I know, but at least for now this unbreaks
things.
@ltratt
ltratt enabled auto-merge July 31, 2026 17:30
@ltratt
ltratt added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
Comment thread tests/src/lib.rs
Path::new(&out_dir)
.components()
.nth_back(3)
.nth_back(4)

@Pavel-Durov Pavel-Durov Aug 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do something like:

pub fn full_cargo_profile() -> String {
    let target_dir = target_dir();
    let out_dir = PathBuf::from(env!("OUT_DIR"));
    out_dir
        .ancestors()
        .find(|p| p.parent() == Some(target_dir.as_path()))
        .and_then(|p| p.file_name())
        .and_then(|n| n.to_str())
}

Way more code, but then we don't need to rely on dir layout

Comment thread ykbuild/src/lib.rs
Comment on lines 13 to 24
pub fn target_dir() -> PathBuf {
Path::new(env!("OUT_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.to_owned()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use cargo_metadata for that:

Suggested change
}
pub fn target_dir() -> PathBuf {
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_owned());
let metadata = cargo_metadata::MetadataCommand::new()
.cargo_path(cargo)
.no_deps()
.exec()
.expect("failed to run `cargo metadata`");
metadata.target_directory.into_std_path_buf().clone()
}

Comment thread tests/src/lib.rs
Comment on lines 110 to 118
pub fn full_cargo_profile() -> String {
let out_dir = std::env::var("OUT_DIR").unwrap();
Path::new(&out_dir)
.components()
.nth_back(3)
.nth_back(4)
.map(|x| x.as_os_str().to_str().unwrap())
.unwrap()
.to_owned()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn full_cargo_profile() -> String {
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
out_dir
.strip_prefix(ykbuild::target_dir())
.expect("OUT_DIR is not inside cargo's target directory")
.components()
.next()
.map(|x| x.as_os_str().to_str().unwrap())
.unwrap()
.to_owned()
}

@Pavel-Durov

Copy link
Copy Markdown
Contributor

Alternative PR github.com//pull/2224

@ltratt

ltratt commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Right now, I don't think we can work around this problem other than by setting the CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT=false variable, so I'm closing this PR.

@ltratt ltratt closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants