Install CLI in Build Command [Native Rust Runtime]

Hey! I want to run an app in a Rust runtime. This app requires access to a Rust toolchain and a CLI tool which must be installed via a curl command. Currently, I’m unable to access the CLI tool when running the “start command”, causing my app to fail.

Here’s my “build command”:

(curl -L https://sp1.succinct.xyz | bash) && ~/.sp1/bin/sp1up && echo "export PATH=$HOME/.sp1/bin:$PATH" >> /opt/render/.bashrc && source /opt/render/.bashrc && cargo prove --version
  • The initial curl script pulls an install script: sp1up. This install script then installs the cargo prove toolchain to ~/.sp1
  • cargo prove --version in this command works as intended.

Here’s my start command:

export PATH=$HOME/.sp1/bin:$PATH && cargo prove --version
  • This command simply tests that the cargo prove CLI is installed.

In native runtimes, is it possible to install a CLI tool in the “build command” which can be used in the “start command”?

For context, I’ve been able to get this working with Docker, but I wanted to move to the native Rust runtime for better caching.

A Docker image installing Rust is the better idea. What makes Docker suboptimal for caching as opposed to injecting it into a native environment?

The Rust caching in Render is fairly straightforward and doesn’t require manual modification which Docker requires in order to improve caching. Why is it not recommended to use the Rust runtime?

I think I misunderstood the issue, I still don’t understand why sp1 isn’t in Crates (though I did find zkp there, and sp1’s site says “Use SP1 or any proof system to write a ZKP for your application.”), but I have no active knowledge in Rust to inform why one would use zkp, sp1, etc.

In short, I believe the issue here is that the execution of the Build Command, Start Command, and even processing of Environment Variables isn’t POSIX, or more specifically, it doesn’t expand variables. I believe what you want to do is to throw those lines in a build script, probably headed with #!/usr/bin/env bash, which should then allow you to stuff things like $PATH changes into processing, then set your Build Command as ./build.sh or something of the sort.

I believe that adding the path change into ~/.bashrc will then persist in the environment’s boot process, leaving you to only need to run cargo prove --version as your Start Command.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.