Skip to content

Instantly share code, notes, and snippets.

@samcofer
Last active February 14, 2025 20:05
Show Gist options
  • Save samcofer/7163a92ab93f643e2394ce63b267e453 to your computer and use it in GitHub Desktop.
Save samcofer/7163a92ab93f643e2394ce63b267e453 to your computer and use it in GitHub Desktop.
Update local renv and python cache
#Placeholder to change the name of the gist
#!/bin/bash
# Activate the existing venv
source .venv/bin/activate
# Make note of all installed packages
python -m pip freeze > requirements-freeze.txt
# Deactivate the venv and delete
deactivate
rm -rf .venv/
# Create a new virtual environment
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip wheel setuptools
python -m pip install -r requirements-freeze.txt
# snapshot renv.lock to bring it in sync with the library
renv::snapshot()
# Delete the existing libraries
unlink("renv/library", recursive=TRUE)
# Restart R session
.rs.restartR()
# Re-install libraries
renv::restore(rebuild = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment