Comments (7)
This isn't possible (yet?). Virtual environments are either global, or project-local.
Project-local environments will be created with renv::create(..., local = TRUE)
but it looks like this isn't working as expected just yet.
The cache location is configurable with the RENV_PATHS_CACHE
environment variable. I haven't yet thought about the best way for users to declaratively set this if e.g. they want this set for all users on a system, or specific projects, and so on. (Maybe just in .Renviron
s? Still thinking about it)
from renv.
We've decided to eschew the concepts of 'global' vs. 'local' virtual environments. Instead, we just have the Packrat default baseline of a project-local library.
from renv.
The conversation in this issue is now outdated -- the way renv
works has been re-architected since then. Previously, we were considering decoupling projects and environments, so projects could 'bind' to arbitrary environments; now, each project gets their own environment that is normally automatically activated through a project .Rprofile
.
What you're doing is exactly what we would suggest with the current architecture :-)
from renv.
I've added some code to allow for absolute paths to environments, but need to think this through a bit more.
In Python, a virtual environment is a directory of 'stuff' -- including a Python binary (usually as a symlink), as well as related utilities. Normally, the intention is that one 'activates' a Python virtual environment by running the Python binary in that virtual environment.
In renv
, the files within ~/.renv/environment
are really just blueprints for creating / activating R virtual environments. They aren't self-contained directories on their own. That is, when running in an R session, calling
renv::activate("environment")
you're writing the infrastructure to load that environment into the current project, so that the associated environment can be automatically loaded. This is opposed to the Python model, when that infrastructure lives within the virtual environment itself.
Just to drive the point home, let's compare the layout for a Python virtual environment:
kevin@zordon:~/.virtualenvs
$ tree -L 2 testenv
testenv
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── activate_this.py
│ ├── easy_install
│ ├── easy_install-2.7
│ ├── pip
│ ├── pip2
│ ├── pip2.7
│ ├── python -> python2.7
│ ├── python-config
│ ├── python2 -> python2.7
│ ├── python2.7
│ └── wheel
├── include
│ └── python2.7 -> /usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/include/python2.7
├── lib
│ └── python2.7
└── pip-selfcheck.json
And for an renv
:
$ tree renv
renv
├── activate.R
├── activate.dcf
└── manifest
└── 2019-01-19
└── 2019-01-19T10-16-17PST
With the actual pieces of the virtual environment (the R library) living in ~/.renv
(by default).
The intention is that R sessions launched in the project directory will use the .Rprofile
to source activate.R
on startup. activate.dcf
is the metadata needed to initialize things as needed.
I think one nice thing about the renv
approach is that the infrastructure is minimal, and can easily be version controlled alongside the project, whereas I'm less sure about how version control + Python virtual environments are handled.
It sounds like users just call pip freeze
and pip install -r
as required? But that doesn't really encode the state of the virtual environment; just the Python packages that were installed. The onus is still on the user in that case to create a virtual environment, activate it, and then install packages into that environment.
from renv.
All that said -- a virtual environment should probably just be a directory; I'm already confusing myself trying to explain the semantics here so it could probably be simplified.
from renv.
Ahh I see. Very interesting. I think my desire for arbitrary directories is more a holdover from the Python virtualenv way of doing things, where the naming of the environment is (and probably should be) arbitrary lest there are naming collisions across projects. For instance, I am not a huge fan of Python virtualenv "home directory" behavior where you have to name the environment for storage at the home directory level and naming collisions are possible. I much prefer to name the project at the project level, with some type of state stored at the home directory or some other location for optimization.
At very least, I think the exercise of simplifying / explaining the semantics will be valuable, as users will need to work with many of these varied constructs across languages.
from renv.
What code did @kevinushey add?
I've added some code to allow for absolute paths to environments.
To point a project to another projects environment locally, I add the line to the ".Rprofile" : renv::load("dir_with_renv")
but wasn't sure if there was another way I should be doing this...?
from renv.
Related Issues (20)
- renv::install("fmesher") failes with a segfault HOT 2
- error code 60 leds renv to ask to reinstall packages HOT 4
- Error: renv looks for project's DESCRIPTION file HOT 3
- renv::use() requires R restart after updating loaded packages HOT 2
- renv::restore() does not restore lockfile package versions HOT 9
- renv::init() terra installation fails HOT 4
- renv::restore() doesn't create python virtualenv HOT 1
- renv::restore() getting "un-done" by "the dependency tree was repaired" HOT 8
- Cannot install bioconductor Rhtslib using Dockerfile and renv - without renv works fine HOT 3
- Running Renv in Docker HOT 1
- renv::load(other_project) fails if autoload is disabled HOT 1
- creates renv/library folders for each date HOT 2
- Restoring older versions of r-universe packages doesn't work anymore? HOT 4
- renv does not include remote libraries in lock file HOT 2
- Opt users into using PPM when using default repos on Positron HOT 2
- Investigate suspicious looking repos code
- separate download step from install step in `renv::restore`? HOT 2
- `checkout()` breaks restoring if checking out older snapshots HOT 5
- Bioconductor packages wrongly detected to be out-of-sync HOT 2
- checkout with action "snapshot" does not generate the standard renv snapshot HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from renv.