Morning all!

Okay, let me start out by saying that I know absolutely sweet F.A. about Rust. There’s simply something I’m trying to get working and it’s required me to make a few changes. And with every change, it’s getting closer to building successfully… or so I hope.

Anyway, I’m here to bother you for a reason, not just to waffle. I was wondering if someone could be kind enough to explain this rust toolchain malarkey?

When I started trying to “fix” this thing (it’s a dockerfile), I updated it to build from the latest and greatest rust and then updated to the latest and… I digress, point being it’s failing some cargo stuff and I have reason to believe it’s because of the rust toolchain which is set as nightly-2022-07-19 now, I thought I could just set that to stable, but upon reading some docs, I need to set the date. I was just wondering if someone could explain why? Why can’t I just have the toolchain set to latest? It seems complicated for nothing.

  • 5C5C5C@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    edit-2
    7 months ago

    Nightly is for language features of Rust that are still being tested or experimented with. It should only be used by developers who are eager for the latest bleeding edge capabilities and are willing to adapt if those capabilities change or get dropped entirely. Or you might use nightly if you’re a good citizen and testing out the experimental capabilities so that you can give feedback on them.

    A later version of nightly could potentially change or drop the features of an earlier version of nightly in ways that are not backwards compatible. That’s why you might have to specify which version of nightly you need (potentially an older version), if you’re building something that depended on nightly features.

      • 5C5C5C@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        7 months ago

        I’m not familiar enough with what you’re trying to do to offer any specific advice. I’ve spent very little time with writing dockerfiles, and have never needed to set up a Rust toolchain in a dockerfile.

        I think the first step is figuring out if nightly is really needed. If there aren’t any nightly features needed then the latest stable toolchain should work fine, and worrying about what version of the toolchain to use is a red herring.

    • sabreW4K3@lazysoci.alOP
      link
      fedilink
      arrow-up
      3
      ·
      7 months ago

      I’m not sure. But I don’t think it’s any as it fails on these two lines

      RUN cargo install --path ./ --force --no-default-features --features postgres
      RUN cargo install --path plume-cli --force --no-default-features --features postgres
      

      But I have zero experience, so I’m basically just trying things until it stops failing 🫣

      • BB_C@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        7 months ago

        You could have just mentioned the project in question since its code is public.

        https://git.joinplu.me/plume/plume

        % git grep '#!\[feature'
        plume-common/src/lib.rs:#![feature(associated_type_defaults)]
        plume-front/src/lib.rs:#![feature(decl_macro, proc_macro_hygiene)]
        plume-models/src/lib.rs:#![feature(never_type)]
        plume-models/src/lib.rs:#![feature(proc_macro_hygiene)]
        plume-models/src/lib.rs:#![feature(box_patterns)]
        src/main.rs:#![feature(decl_macro, proc_macro_hygiene)]
        
        % cat rust-toolchain
        nightly-2022-07-19
        
        % rm -f rust-toolchain
        % cargo check
        

        No errors from plume crates, but we get errors in a couple of locked dependencies:

        error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
           --> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/wrapper.rs:479:33
            |
        479 |                 let proc_macro::LineColumn { line, column } = s.start();
            |                                 ^^^^^^^^^^ not found in `proc_macro`
            |
        help: consider importing one of these items
            |
        1   + use crate::LineColumn;
            |
        1   + use crate::fallback::LineColumn;
            |
        help: if you import `LineColumn`, refer to it directly
            |
        479 -                 let proc_macro::LineColumn { line, column } = s.start();
        479 +                 let LineColumn { line, column } = s.start();
            |
        
           Compiling generic-array v0.14.6
        error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
           --> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/wrapper.rs:496:33
            |
        496 |                 let proc_macro::LineColumn { line, column } = s.end();
            |                                 ^^^^^^^^^^ not found in `proc_macro`
            |
        help: consider importing one of these items
            |
        1   + use crate::LineColumn;
            |
        1   + use crate::fallback::LineColumn;
            |
        help: if you import `LineColumn`, refer to it directly
            |
        496 -                 let proc_macro::LineColumn { line, column } = s.end();
        496 +                 let LineColumn { line, column } = s.end();
            |
        
            Checking once_cell v1.17.0
        error[E0635]: unknown feature `proc_macro_span_shrink`
          --> /home/user64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.49/src/lib.rs:92:30
           |
        92 |     feature(proc_macro_span, proc_macro_span_shrink)
           |                              ^^^^^^^^^^^^^^^^^^^^^^
        
        

        Let’s see if a full (semver-compatible) deps update works:

        % cargo update
        % cargo check
        

        This succeeds.

        I will let you pick it from here.
        Should be a good learning experience.