Skip to content
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

version 2.8.0 - printing wrong version #65

Closed
daniejstriata opened this issue Aug 22, 2023 · 12 comments
Closed

version 2.8.0 - printing wrong version #65

daniejstriata opened this issue Aug 22, 2023 · 12 comments

Comments

@daniejstriata
Copy link

The --version output is still 2.7.2 instead of 2.8.0.

image

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

Oh sh. And I know I'll fall into this one again, the project's structure is too painful...

@daniejstriata
Copy link
Author

daniejstriata commented Aug 22, 2023

Where is the version of a cli set in a rust project? When you build it or in the code?

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

For most projects, everything is built from one Cargo.toml version. But for dysk, in order to be able to automatically build a man page, I had to split it with most of the code in a sub project. It means I have to set the version at 4 places (in 2 Cargo.toml files).

I'll probably need to set up something like a git hook to check they're equal...

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

In retrospect, the automatic man page wasn't worth the pain

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

This should be fixed at most places now (not when you use crates.io, ie cargo install dysk).

Please don't close the issue, I need to set up a reliable solution to avoid this problem on next deploys.

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

Made the build impossible when a version is different:
image

Canop added a commit that referenced this issue Aug 22, 2023
partial fix of #65
@Canop Canop closed this as completed in b475e93 Aug 22, 2023
@Stargateur
Copy link

For most projects, everything is built from one Cargo.toml version. But for dysk, in order to be able to automatically build a man page, I had to split it with most of the code in a sub project. It means I have to set the version at 4 places (in 2 Cargo.toml files).

That weird haha.

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

That weird haha.

Yeah. If you find a cleaner way to generate the man page, it's welcome

@daniejstriata
Copy link
Author

daniejstriata commented Aug 22, 2023

What about using environment variables during the build process to inject the version information?

in Cargo.toml

[package]
name = "project"
version = "0.1.0"  # Placeholder version

Use Environment Variables

use std::env;

fn main() {
    // Fetch the version environment variable, defaulting to a fallback if not set
    let version = env::var("PROJECT_VERSION").unwrap_or_else(|_| "unknown".to_string());

    println!("Building version: {}", version);

    // The rest of your build logic
}

Can you then build it with cargo like this?

export PROJECT_VERSION="1.2.3" 
cargo build

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

@daniejstriata The Cargo.toml file is used in all kind of processes and tools, it should stay correct. I should rather look for another man page generator when I have some free time.

@daniejstriata
Copy link
Author

@daniejstriata The Cargo.toml file is used in all kind of processes and tools, it should stay correct. I should rather for another man page generator when I have some free time.

That makes sense. Thanks.

@Canop
Copy link
Owner

Canop commented Aug 22, 2023

Hint for bored FOSS authors: there's some market for a convenient man page generator for rust projects ;)

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

No branches or pull requests

3 participants