vercel-community / rust

🦀 Rust runtime for ▲ Vercel Serverless Functions
https://rust-runtime.vercel.app
MIT License
816 stars 50 forks source link

Is the `.cargo/config.toml` necessary in CI? #134

Closed PaulRBerg closed 7 months ago

PaulRBerg commented 7 months ago

Requiring users to have a .cargo/config.toml file with the following content:

[build]
target = "x86_64-unknown-linux-musl"

Is quite a bad developer experience.

A better approach would be to manage environment-specific configurations in a way that doesn't interfere with the local development process.

But maybe I misunderstood how this works and there's no need for this file if the user doesn't intend to make a prebuilt deployment from their local machine?

We only want to deploy from CI.

dglsparsons commented 7 months ago

If you only want this to kick in as part of CI, i'd recommend writing the .cargo/config.toml file as part of your Github Actions.

e.g.

      - name: Write cargo config (forces a specific target)
        run: mkdir .cargo && printf "[build]\ntarget = \"x86_64-unknown-linux-musl\"\n" > .cargo/config.toml

It's not an easy one to workaround, as the configuration is Rust-specific. We'd have to have the ability to pass target info through the CLI, into the builder API, and then through to the cargo commands that are run. And of course, this would only apply to Rust builds at that point.

I get that this is not ideal, but it's well-documented in the README.

PaulRBerg commented 7 months ago

Thanks, @dglsparsons. Writing the file in CI is precisely what we ended up doing.

get that this is not ideal, but it's well-documented in the README.

Yes, but the way it is currently explained leads to a bad local developer experience (because of that .cargo/config.toml file).

IMO, the README should be updated to recommend creating the Cargo file programmatically, as suggested here.