Package 'rpix'

Title: R package to manage dependencies with pixi
Description: More about what it does (maybe more than one line) Use four spaces when indenting paragraphs within the Description.
Authors: Mikkel Roald-Arbøl
Maintainer: Mikkel Roald-Arbøl <[email protected]>
License: MIT + file LICENSE
Version: 0.3.0
Built: 2026-05-13 07:37:18 UTC
Source: https://github.com/roaldarbol/rpix

Help Index


Add dependencies

Description

add() will add dependencies to the pixi.toml.

For more information, see https://pixi.sh/latest/reference/cli/pixi/add/.

It will only add if the package with its version constraint is able to work with rest of the dependencies in the project. More info on multi-platform configuration.

Usage

add(packages, versions = NULL, channel = NULL, dry_run = FALSE)

Arguments

packages

Package name(s) to be added.

versions

Optional. Version constraints for all packages.

channel

Optional. Defaults to conda-forge, but other conda channels can be specified.

dry_run

Should the command be executed? If TRUE, the final pixi command will be shown but not executed. FALSE (default) executes the command.

Value

Doesn't return any objects.

Examples

## Not run: 
add("tibble")

## End(Not run)

Add pixi to PATH

Description

pixi_to_path() checks if pixi's installation directory is in the current PATH and adds it if not found. The function automatically detects the operating system and uses the appropriate default installation path for each platform.

Usage

pixi_to_path()

Details

The function checks if the pixi binary directory is already present in the PATH environment variable. If not found, it appends the default installation directory:

  • macOS/Linux: ⁠~/.pixi/bin⁠

  • Windows: ⁠%USERPROFILE%\\.pixi\\bin⁠

This modification only affects the current R session.

Value

Invisibly returns NULL. The function is called for its side effects of modifying the PATH environment variable.

See Also

Sys.setenv(), Sys.getenv(), Sys.info()

Examples

## Not run: 
# Check if pixi is available and add to PATH if needed
pixi_to_path()

# Verify pixi is now available
system("pixi --version")

## End(Not run)

Remove dependencies

Description

remove() will remove dependencies from the pixi.toml.

For more information, see https://pixi.sh/latest/reference/cli/pixi/remove/

Usage

remove(packages, dry_run = FALSE)

Arguments

packages

Package name(s) to be removed.

dry_run

Just show command or also run.

Value

Doesn't return any objects.

Examples

## Not run: 
remove("tibble")

## End(Not run)

Reset R library configuration

Description

reset_r_libraries() resets R's library configuration to default settings, removing any pixi-specific configurations. This is useful for troubleshooting or when you want to stop using pixi-managed packages.

Usage

reset_r_libraries(remove_from_rprofile = FALSE, global = FALSE)

Arguments

remove_from_rprofile

Logical. If TRUE, attempts to remove pixi setup from .Rprofile files. Default is FALSE.

global

Logical. If TRUE and remove_from_rprofile = TRUE, removes from global ~/.Rprofile. Default is FALSE.

Examples

## Not run: 
# Reset library paths to default
reset_r_libraries()

# Reset and clean .Rprofile
reset_r_libraries(remove_from_rprofile = TRUE)

## End(Not run)

Restart RStudio with Pixi

Description

To ensure that RStudio uses the correct version of R and avoid errors when loading libraries, use this command to restart RStudio.

Usage

restart_rstudio_with_pixi()

Setup pixi environment safely

Description

setup_pixi() provides a complete pixi setup for R projects. It checks for pixi availability, initializes a pixi project if needed, and configures R to use pixi-managed packages. The function prioritizes safety and uses .libPaths() instead of environment variables to avoid shared library conflicts.

Usage

setup_pixi(add_to_rprofile = TRUE, global = FALSE, init_if_missing = TRUE)

Arguments

add_to_rprofile

Logical. If TRUE, adds the pixi library configuration to .Rprofile for persistence across sessions. Default is FALSE.

global

Logical. If TRUE and add_to_rprofile = TRUE, adds to global ~/.Rprofile instead of project-local .Rprofile. Default is FALSE.

init_if_missing

Logical. If TRUE, runs ⁠pixi init⁠ if pixi.toml is not found. Default is TRUE.

Details

The function performs the following steps:

  1. Checks if pixi is available in PATH (adds it if not found)

  2. Checks for pixi.toml in project root (runs ⁠pixi init⁠ if not found)

  3. Configures R to use the pixi library as the primary package source

  4. Optionally adds the configuration to .Rprofile for persistence

Instead of setting environment variables (which can cause shared library conflicts), this function modifies .libPaths() to prioritize the pixi library.

Value

Invisibly returns a list with the status of each setup step.

See Also

pixi_to_path(), .libPaths()

Examples

## Not run: 
# Basic setup - just configure for current session
setup_pixi()

# Full setup - add to .Rprofile for persistence
setup_pixi(add_to_rprofile = TRUE)

# Setup without auto-initializing pixi project
setup_pixi(init_if_missing = FALSE)

## End(Not run)