Skip to content

Create an isolated virtual environment for Pacman and supported AUR helpers

License

Notifications You must be signed in to change notification settings

jdholtz/pacman-venv

Repository files navigation

Pacman Virtual Environment

A tool to create isolated virtual environments for Pacman. This tool is inspired by Python's virtualenv and therefore works similarly.

Note: pacman-venv is still in its development and testing phase. Not all changes will be backwards compatible. To stay updated with the latest changes, check out the Changelog. Additionally, each update may require you to reinstall your virtual environment for the changes to be applied.

Table of Contents

Overview

Isolating system packages is beneficial for a few reasons:

  • Having two applications with conflicting requirements (one application requires gcc<=11.1.0 while another requires gcc>=12.1.0).
  • Creating isolated development environments for different projects
  • Keeping only necessary packages available system-wide (e.g. not needing to keep track of which packages to remove after testing them)

How It Works

After sourcing the activation script, pacman-venv configures your current environment to correctly use the isolated environment.

  • Most notably, your PATH is configured to look for commands to run in the virtual environment before system-wide commands.
  • Additionally, wrappers are created for all supported package managers and AUR helpers (see Supported AUR Helpers). These wrappers execute their respective package managers with the --root argument pointing to the location of the virtual environment.
  • Last, the name of the virtual environment will appear in the prompt to indicate that the virtual environment is active (similarly to virtualenv).

Installation

The recommended way to install pacman-venv is with an AUR helper. Here is an example with Yay:

yay -S pacman-venv

The development version of this package can be installed with the pacman-venv-git package.

From Source

Pacman-venv can also be installed by cloning the PKGBUILD and building with makepkg:

pacman -S --needed git
git clone https://aur.archlinux.org/pacman-venv.git
cd pacman-venv
makepkg -si

Usage

Create a virtual environment in the current directory:

pacman-venv [name]

Note: If name is not specified, the default name will be used (pacman-venv)

To enter the virtual environment, source the {name}/bin/pacman-venv-active file (Add the .fish extension if you are using the Fish shell). Here is an example for Bash:

source pacman-venv/bin/pacman-venv-activate

Exit the virtual environment by either executing deactivate or exit.

For the full usage of the tool, run:

pacman-venv --help

Additional information on how to use pacman-venv can be found in the man page (man pacman-venv)

Supported Software

Below is a list of all shells and AUR helpers that pacman-venv currently supports

Shells

AUR Helpers

Contributing

If you run into any issues, please file it via GitHub Issues. Additionally, if you have any questions or discussion topics, start a GitHub Discussion.

Contributions are always welcome. Please read Contributing.md if you are considering making contributions.