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

Run trunk without manual installation #924

Open
stefnotch opened this issue Dec 11, 2024 · 0 comments
Open

Run trunk without manual installation #924

stefnotch opened this issue Dec 11, 2024 · 0 comments

Comments

@stefnotch
Copy link
Contributor

stefnotch commented Dec 11, 2024

Background

A package manager such as Cargo solves two major problems

  1. Getting all libraries and tools that are required to build a project.
  2. Reproducible builds. If I pick up a project, I know exactly what dependencies were used.

Problems

  1. Trunk needs to be manually installed. When cargo binstall trunk is used, then one first has to install binstall. Alternatively, cargo install trunk --locked can be used, provided that one doesn't run into the current OpenSSL/Rustls issues. Ideally, this step would be automatic.
  2. In a team, one has to make sure everyone uses the same version of the tools. Setting the version in the Trunk.toml partially gets there. Ideally, this would instead be left to Cargo.

Request

With the upcoming cargo-script support, both of these issues could be solved eventually.

  1. I can add a single trunk.rs script to my repositories, and tell my team members to use cargo trunk.rs serve --open instead of cargo run. They do not need to do anything else. cargo trunk.rs --help, cargo trunk.rs build, etc would just work.

  2. The script can depend on an exact version of Trunk. Support for lockfiles is planned.

An experimental version of this is possible today. A file with the following contents would be checked into source control, and then everyone can run Trunk without needing to manually install it.

#!/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 
#[tokio::main]
async fn main() {
    let a = trunk::run_cli().await;
    println!("{:?}", a);
}
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

1 participant