How to install rust command line programme and pre requisites automatically

I am writing a small command line program for my client. I want to give such a script to the client, that may install all the pre requisite (rust compiler) and my command line programme in one command.

How can I achieve that?

There are advanced solutions, but if it's on, consider something simple like

(curl --proto '=https' --tlsv1.2 -sSf | sh) \
&& cargo install YOUR_PACKAGE_NAME

That is missing a source ~/.cargo/bin/env (or equivalent on Windows) to set PATH correctly.

1 Like

Providing a pre-compiled executable (+ source if they need to change it in the future) may be significantly easier for your client.


The best way is to use the native package manager of the operating system your client are using. Unfortunatley, there are lots of different package managers for different linux distros, the BSD:s have their own, and since MacOS don't really have one there is even different ones to choose from there. And as far as I know, Windows still don't have one, the the best you can do there is to put your binary (and other relevant files) in a self-extracting archive with a "wizard" for selecting a base directory.

1 Like

What if I do not want to publish my solution to

It induce another question. Should we publish personal projects to even if has very special use case and have no use for any user other than you/your client?

If it's for personal or organisation use, you may want to consider running a private registry such as Shipyard and then having your client setup their Rust as shown here.

I'm not sure if you're aware of this (based on the wording of your post), so I wanted to emphasise this just in case:

Rust is a compiled language, not an interpreted one. Typically, you are not expected to ship the compiler and other tools with your program, like you would need to with Python, Java, C#, etc. Instead, you compile the program to a standalone executable (which can absolutely be a single file), and distribute that. Depending on your specific target system and what libraries you are using, you can get away without needing any dependencies to be installed.

It's also worth noting that even if you ship the source code and the build tools to your clients, they would still need to compile the code to an executable before they could run it; Rust does not support directly executing code like in Python.

Finally, there's nothing stopping you from distributing the compiled program (which they can run directly) and the source code with instructions on how to build it from scratch if they so choose.


Perhaps distibute the git repo itself and inside a small script that will install rust and build it?

There are also tools to create an MSI installer, like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.