Guix Shell - Create Isolated Development Environments

Learn how to use Guix Shell to create isolated development environments with specific package versions. Easily manage dependencies for your projects.

Guix Shell

The guix shell command is a powerful tool for creating isolated development environments. It allows you to download or build specified packages and make their executables available in your current shell session without installing them globally. This is crucial for managing project dependencies, ensuring reproducible builds, and avoiding conflicts between different software versions.

Creating an Interactive Shell with Packages

To create an interactive shell where the executables from specified packages are available, use the following syntax:

guix shell <package-name> <package-name> ...

This command will download or build the listed packages and then launch a new shell. Within this new shell, you can run commands provided by these packages. For example, to get a shell with the git and python executables available:

guix shell git python

Invoking a Command in a Specific Environment

If you only need to run a single command within an environment that includes specific packages, you can use the -- separator:

guix shell <package-name> -- <command>

This is useful for scripting or running one-off tasks that require particular tools. For instance, to run a Python script using a specific version of Python:

guix shell python@3.9 -- python my_script.py

Benefits of Using Guix Shell

  • Reproducibility: Ensures that your development environment is consistent across different machines and over time.
  • Isolation: Prevents package conflicts by creating separate environments for each project.
  • Dependency Management: Easily specify and manage exact versions of required packages.
  • Clean System: Avoids cluttering your global system with project-specific dependencies.

Further Resources