flox in 5 minutes¶
Flox is a virtual environment and package manager all in one. With Flox you create development environments that layer and replace dependencies just where it matters (Flox won't mess with your setup!), making them portable across the full software lifecycle.
Follow the quick start steps to see how easy it is to get started on any project, on any system, with an existing Flox environment.
git clone https://github.com/flox-examples/rust-env-demo.git
cd rust-env-demoto enter the project directory where a flox environment has been pre-configured.
flox activateto layer this project's dependencies onto current shell with a single command.
cargo runto play with one of the rust dependencies that came with this project.
flox search justto search for packages.
flox install justto install the missing dependency.
just profileto test the newly installed dependency by creating a flame graph.
exitto leave the environment.
Detail about each of these steps is below.
Start by installing
Clone the example rust project¶
rust-env-demo repository and
cd into it. This repository contains a Rust crate (package) that displays raw HTML for the Rust homepage and a Flox environment for working as a developer on the project.
Activate the environment¶
flox activate to enter the development environment defined in the repository's
Let's build and run the crate with
cargo run to verify that everything is working properly:
List the environment's contents¶
To see a list of everything in this environment, run
flox list. The Flox command line interface (CLI) has made all the dependencies this project needs available to your terminal as long as we are inside the environment.
Use the dependencies like normal¶
Let's see if Rust's linter (
clippy) has anything to say about our code quality. Run the linter with
Search & install missing dependencies¶
This project uses a
just profile command to generate performance trace flamegraphs. However, the maintainer didn't include
just in the environment:
Let's search for it and install it to our Flox environment with
flox search just:
We want that top search result. Let's install it with
flox install just and run the
just profile command.
Exit the environment¶
Now that we've worked on this project we can leave the Flox environment by typing
exit and can see we no longer have access to packages we were just using: