2.6 KiB
2.6 KiB
SmartCane Project - Package Management
Quick Start
For New Team Members
- Open R/RStudio
- Set working directory to the project root:
setwd("path/to/smartcane") - Run:
source("r_app/package_manager.R") - Type
ywhen prompted - Wait for completion ✅
For Existing Team Members (After Git Pull)
Same steps as above - the script will check for updates automatically.
What This Script Does
- Initializes renv - Creates isolated package environment
- Checks package versions - Compares installed vs required
- Installs/Updates packages - Only if needed
- Creates lockfile -
renv.lockfor exact reproducibility - Generates reports - Console output +
package_manager.log
Key Features
- ✅ Minimum version requirements (allows patch updates)
- ✅ Critical package locking (tmap v4 for new syntax)
- ✅ Automatic installation of missing packages
- ✅ Console + Log output for debugging
- ✅ Cross-platform compatibility
Required Packages & Versions
| Package | Min Version | Purpose |
|---|---|---|
| tmap | 4.0.0 | CRITICAL - New syntax used |
| tidyverse | 2.0.0 | Data manipulation |
| sf | 1.0.0 | Spatial data |
| terra | 1.7.0 | Raster processing |
| rmarkdown | 2.21.0 | Report generation |
Workflow
Development Workflow
1. 👨💻 Developer: Make changes → run package_manager.R → test → commit + push
2. 👥 Teammate: Pull → run package_manager.R → test
3. 🚀 Production: Pull → run package_manager.R → deploy
Files Created
renv.lock- Exact package versions (commit this!)package_manager.log- Installation log (don't commit)renv/folder - Package cache (don't commit)
Troubleshooting
"Package failed to install"
- Check internet connection
- Update R to latest version
- Install system dependencies (varies by OS)
"Version conflicts"
- Delete
renv/folder - Run script again for clean install
"renv not working"
- Install manually:
install.packages("renv") - Restart R session
- Run script again
Team Guidelines
- Always run
package_manager.Rafter pulling changes - Commit
renv.lockto git (notrenv/folder) - Don't modify package versions in scripts - use this manager
- Report issues in the log file to team
Advanced Usage
Restore from lockfile only:
renv::restore()
Add new package requirement:
- Edit
REQUIRED_PACKAGESinpackage_manager.R - Run the script
- Commit updated
renv.lock
Check status without changes:
source("r_app/package_manager.R")
# Then just read the log or run generate_package_report()