Feat: Add environment variables for path customization and centralize config#79
Feat: Add environment variables for path customization and centralize config#79bsirak wants to merge 5 commits intonbafrank:mainfrom
Conversation
Moves UVR_LIBRARY, UVR_EXTRA_LIBS, UVR_INSTALL_TIMEOUT, and UVR_PROGRESS to crates/uvr-core/src/config.rs to keep all environment variable definitions in one place and alphabetically sorted. Updates all call sites to use config::*() getters, and adds detailed docstrings for each.
|
I kept |
|
Hey @bsirak ! Thanks so much for this! You are totally right about I have a few things for you! Naming — you're right! Let's rename UVR_R_VERSIONS_DIR → UVR_R_INSTALL_DIR as discussed above! CI — formatting only CI is failing on cargo fmt --all -- --check across all three platforms. No compile or test failures — just rustfmt. Running cargo fmt Blocking — correctness crates/uvr-core/src/registry/cran.rs:346 — silent CRAN cache invalidation. The .join("cran") moves the CRAN package-index from crates/uvr/src/commands/self_update.rs — UVR_INSTALL_DIR footgun. When UVR_INSTALL_DIR differs from current_exe.parent(), the new self_update.rs — lost error. The old code errored if current_exe.parent() was None; the new code silently falls back to Polish
Tests Could you add a small mod tests in config.rs covering: (1) defaults when env vars are unset, (2) override when set, (3) empty-string **Out of scope (Bonus!!!) ** uvr doctor should ideally print the effective values of UVR_CACHE_DIR / UVR_R_INSTALL_DIR / UVR_INSTALL_DIR so users can debug "where More importantly-> Thank you so much for your help and work here! |
|
@nbafrank, thank you for the info! I'll make the suggested changes, clean it up, and try to get to adding the output to Do you have an opinion on |
|
Go for it regarding |
|
hey, sorry. i should've mentioned in my reply that i was just pulling the changes you made into the pr branch. Nothing should've changed yet on my end. I'll post when I think it's ready for another pass. And no worries, I'm new to most of this too. Certainly on anything this scale. |
|
No worries. Please write here when ready! Also there are some failing CI tests so check on those as well. Thanks for the help! |
|
@nbafrank
if you want to take a quick look and let me know if you have any other comments or suggestions, I'd greatly appreciate it. Otherwise, I'll take a second pass at the testing for |
Description:
This PR introduces the ability to customize core
uvrdirectory paths via environment variables (similar to howuvhandles them) and centralizes all environment variable reads into a singleconfig.rsmodule for better maintainability and documentation.New Features:
Added support for overriding previously hardcoded paths using the following new environment variables:
UVR_CACHE_DIR: Customizes the directory where packages, environments, and tarballs are cached (default:~/.uvr/cache/).UVR_R_VERSIONS_DIR: Customizes the directory where managed R versions are installed (default:~/.uvr/r-versions/).UVR_INSTALL_DIR: Customizes the directory where theuvrbinary itself is installed during aself-update.Refactoring & Consolidation:
To keep configuration consistent, previously existing environment variables scattered throughout the codebase have been moved into
crates/uvr-core/src/config.rs:UVR_EXTRA_LIBS(moved fromrun.rs)UVR_INSTALL_TIMEOUT(moved fromr_cmd_install.rs)UVR_LIBRARY(moved fromsync.rs)UVR_PROGRESS(moved fromprogress.rs)Changes:
crates/uvr-core/src/config.rswith alphabetically sorted accessor functions for allUVR_*variables.manager.rs,downloader.rs,cache.rs,sync.rs, etc.) to use the new centralized getters instead of hardcoded paths or inlinestd::env::varchecks.