setup_carbon_tracker: Install codecarbon into a dedicated conda environment

View source: R/setup.R

setup_carbon_trackerR Documentation

Install codecarbon into a dedicated conda environment

Description

Installs Miniconda if it isn't already present, then creates the "r-codecarbon" conda environment and installs codecarbon into it. Run this once per machine before using carbon_tracker() or with_emissions_tracked(). Nothing is installed without confirmation, and the function refuses to run outside an interactive session.

Usage

setup_carbon_tracker(force = FALSE)

Arguments

force

Reinstall codecarbon even if it's already available.

Details

Installs codecarbon ⁠>= 2.2.2⁠ – a floor, not an exact pin. That's the oldest version this package has actually been validated against (see comparison/coverage_matrix.md and NEWS.md for exactly which versions were validated, and where); newer codecarbon releases are expected and welcome, since they bring updated carbon-intensity data along with whatever bug fixes landed upstream. codecarbon's behavior has changed between versions before (see carbon_tracker()'s docs on tracker restart), so if something about CodeCarbonR's output looks different after a codecarbon upgrade, that's the first thing to check. Keep the floor here in sync with DESCRIPTION's SystemRequirements field if it changes.

Value

Invisibly, TRUE if codecarbon is ready to use after the call, FALSE if setup was cancelled.

Examples

## Not run: 
# Installs software and prompts for confirmation, so this never runs
# under R CMD check (or any other non-interactive session) -- call it
# once, by hand, from an interactive R console.
setup_carbon_tracker()

## End(Not run)

CodeCarbonR documentation built on Sept. 21, 2026, 5:08 p.m.