-
Notifications
You must be signed in to change notification settings - Fork 110
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
Pin version of cargo-leptos #399
Comments
I understand this is not viable for everyone but I'd suggest giving nix a try for this. We use nix to pin and provide all dependencies for everyone and it works for all kinds of dependencies, not only rust/cargo-related. |
It's not a Rust library crate, it's just an ordinary binary CLI tool, so I'm not sure there's a way to do what you're asking from cargo-leptos's end. |
That would be an amazing solution, if there were a straightforward option for Windows. As me and a lot of my collaborators are in the field of computer graphics, having Windows support is the expectation. |
I'm suggesting using a cargo script named #!/usr/bin/env cargo
//! ```cargo
//! [dependencies]
//! cargo-leptos = { version = "0.2.21" }
//! clap = "4.5.21"
//! tokio = "1.41.1"
//! ```
use cargo_leptos::{config::Cli, ext::anyhow::Result, run};
use clap::Parser;
use std::env;
#[tokio::main]
async fn main() -> Result<()> {
let args = Cli::parse_from(&env::args().collect());
run(args).await
}
// Ideally this setup would require even less code (e.g. by having cargo-leptos expose a helper function just for this) Then I could drop that script into any of my projects and invoke it. And from there I'd go a step further: Please make this the officially recommended option, especially once cargo-script stabilizes. |
Ultimately this seems to concern the same issue described in leptos-rs/leptos#3186: Minor versions of A solution was also suggested there by @DanielleHuisman
|
I figured I'd put my money where my mouth is, and demonstrate that it's absolutely doable with the upcoming cargo-script. Here is the trunk vanilla demo, tweaked to run with cargo-script. To do that, I did the following
Notably, at no point did I have to do The cargo-leptos stuff should work analogously. #!/usr/bin/env cargo +nightly -Zscript
---cargo
[package]
edition = "2024"
[dependencies]
trunk = { git = "https://github.com/stefnotch/trunk" }
tokio = { version = "1.42.0" }
---
/// Run with
/// cargo +nightly -Zscript trunk.rs serve --open
///
/// Eventually we will be able to do
/// cargo trunk.rs serve --open
///
/// And in an even nicer future, we can do
/// ./trunk.rs serve --open
#[tokio::main]
async fn main() {
let a = trunk::run_cli().await;
println!("{:?}", a);
} (P.S. Currently Trunk needs extra dependencies on most Windows systems, thanks to OpenSSL and RustTLS demanding some extra dependencies outside of cargo.) |
In case anyone finds this interesting: I opened an equivalent issue on the Trunk repository. |
For my projects, I would like to have cargo-leptos behave more like a regular Rust dependency. This means
cargo xtask leptos --help
, orcargo leptos.rs --help
Number one would let me guarantee that every team member uses the same version of cargo-leptos, instead of "works on my machine". It also guarantees that the CI uses the correct version of cargo-leptos.
Number two means that onboarding new contributors is as frictionless as possible. Repeatedly having to tell people to install cargo-leptos (or trunk), and to keep it up-to-date, is a pain point for me.
And finally, if done well, I could juggle different projects that depend on different versions of cargo-leptos. Usually this happens when one project hasn't updated its dependencies just yet.
The text was updated successfully, but these errors were encountered: