Skip to content

Suggested rust-analyzer config can't run rustfmt #107547

Closed

Description

@jyn514

#107297 broke the rust-analyzer config we suggest in the dev-guide: https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc

    "rust-analyzer.rustfmt.overrideCommand": [
        "./build/host/stage0/bin/rustfmt",
        "--edition=2021"
    ],

since now rustfmt is in build/host/rustfmt/bin/rustfmt instead of build/host/stage0/bin/rustfmt.

Originally posted by @jyn514 in #107297 (comment)

Activity

  1. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    C-bugCategory: This is a bug.
    on Feb 1, 2023
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 1, 2023
  3. zephaniahong commented on Feb 1, 2023

    @zephaniahong
    Contributor

    @rustbot claim

  4. zephaniahong commented on Feb 1, 2023

    @zephaniahong
    Contributor

    Hi! Just to clarify, the idea is to change to code to match the docs?

  5. albertlarsan68 commented on Feb 1, 2023

    @albertlarsan68
    Member

    I think the idea is changing the docs to match the new behavior.

  6. zephaniahong commented on Feb 1, 2023

    @zephaniahong
    Contributor
  7. jyn514 commented on Feb 1, 2023

    @jyn514
    MemberAuthor

    I'd prefer to change the code so that we don't force all contributors to update their config.

  8. Mark-Simulacrum commented on Feb 1, 2023

    @Mark-Simulacrum
    Member

    I don't think we can put the binary back, or at least, that feels iffy - we'd be trying to overlap two different sysroots. rustfmt used to be statically linked to libstd and librustc_driver, but that's no longer the case.

  9. Mark-Simulacrum commented on Feb 1, 2023

    @Mark-Simulacrum
    Member

    I suppose we could try to create a symlink from the old path to the new one? That might work, not sure.

  10. albertlarsan68 commented on Feb 1, 2023

    @albertlarsan68
    Member

    Maybe add a proxy?
    On Linux it might just be

    #!/usr/bin/sh
    exec ../rustdoc $* #FIXME make this syntax correct
  11. jyn514 commented on Feb 1, 2023

    @jyn514
    MemberAuthor

    A symlink seems like a good solution to me.

  12. albertlarsan68 commented on Feb 1, 2023

    @albertlarsan68
    Member

    Does the symlink still finds the correct so?

  13. 3 remaining items

  14. kadiwa4 commented on Feb 1, 2023

    @kadiwa4
    Contributor

    Symlinking also works on macOS.

  15. jyn514 commented on Feb 2, 2023

    @jyn514
    MemberAuthor

    On Windows, creating a symlink does not find the needed DLLs. Trying to execute the symlink pops two msgbox saying that it doesn't find the rustc_driver and std DLLs. You would need to symlink also the DLLs. On Linux, it does find the correct SOs.

    Ok, this is pretty messy. How about doing both:

    • Add the symlink, which will work with both the old and new config on Mac and Linux
    • Update the recommended config in the dev-guide, which will help contributors fix the error message on Windows

    and from there we can work long-term to using the same toolchain for rustfmt and other tools, without having a time pressure.

  16. jyn514 commented on Feb 2, 2023

    @jyn514
    MemberAuthor

    and from there we can work long-term to using the same toolchain for rustfmt and other tools, without having a time pressure.

    cc rust-lang/rustfmt#4884, rust-lang/rustfmt#3900

  17. zephaniahong commented on Feb 2, 2023

    @zephaniahong
    Contributor

    May I get some guidance and the creation of the symlink? Do I use rust to create the symlink in src/bootstrap/download.rs after the rustfmt_path line or do I use a bash command? If I do use a bash command, is there a file I should be adding it to?

    Thank you!

  18. jyn514 commented on Feb 2, 2023

    @jyn514
    MemberAuthor

    @zephaniahong use

    fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, link: Q) -> io::Result<()> {

  19. zephaniahong commented on Feb 2, 2023

    @zephaniahong
    Contributor

    And just to confirm, I use that symlink function here?

    let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
    let rustfmt_stamp = bin_root.join(".rustfmt-stamp");

  20. jyn514 commented on Feb 2, 2023

    @jyn514
    MemberAuthor

    yes

  21. bjorn3 commented on Feb 2, 2023

    @bjorn3
    Member

    I think it would be possible to move rustfmt back to the same sysroot as the bootstrap compiler by only taking libstd.so, librustc_middle.so and libLLVM.so from the nightly rustc component and not copying any other files like the rustc binary. Libstd.so and librustc_middle.so both contain a hash in their name unique for each rustc version. libLLVM.so should contain the rustc version, so that shouldn't conflict either.

  22. albertlarsan68 commented on Feb 2, 2023

    @albertlarsan68
    Member

    Doing the same with the DLLs on Windows could also work.

  23. est31 commented on Feb 5, 2023

    @est31
    Member

    related (different error with rustfmt, but caused by the same change): #107676

  24. jyn514 commented on Feb 8, 2023

    @jyn514
    MemberAuthor

    Hi @zephaniahong, any progress on the symlink? happy to help out if you're running into trouble :)

  25. zephaniahong commented on Feb 8, 2023

    @zephaniahong
    Contributor

    Hey @jyn514 ! Thanks for reaching out! I'll be starting tomorrow and will reach out to you if/when I need help!
    Apologies for the delay!

  26. added a commit that references this issue on Feb 9, 2023
    a8df4b1
  27. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions