612 private links
You might want to consider integrating Zotero with VSCode (or rather the open source fork Codium) instead.
As for RStudio, it has shown good stability over the years, and so has Zotero. Both are FLOSS (free and libre open source software) and maintained by non-for-profit organizations.
Ensure you have Zotero installed on your desktop, and install the Better BibTeX plugin.
Open the Tools menu, then click Plugins, then click on the gear icon in the right corner and select "Install plugin from file" and use the Better BibTeX xpi file you downloaded.
If you have not already, download and install RStudio Desktop (if you run Windows and have admin privileges the installation will transparently install R itself as well). Otherwise, ensure you have installed R on your machine.
Support for Zotero integration is built-in to RStudio Desktop (although there are also other ways to do it via various plugins or R packages - I hope to add more on that at a later time).
Notes and links
Considered because I was trying to answer the question:
Can we use a different R version per directory/project?
With my R role it has been easy to maintain multiple different R versions on a server. But I have not really been able to pick-and-choose which R version to use with any particular project since there was only one version symlinked globally (/usr/local/bin/R -> ...).
Could we not set a different version locally, in a particular R project?
- https://github.com/r-lib/rig - this would do it, but does much more than I want, would interfere with my Ansible role
- https://www.monicathieu.com/posts/2024-05-21-multiple-r-versions.html
- https://support.posit.co/hc/en-us/articles/200486138-Changing-R-versions-for-the-RStudio-Desktop-IDE -
export RSTUDIO_WHICH_R=/usr/local/bin/R - https://github.com/vubiostat/Renv - good, but last commit 13 yrs ago
- https://direnv.net - this probably fits the bill
- https://github.com/hyperupcall/autoenv - similar to
direnvbut smaller in scope - https://github.com/jdx/mise - direnv, make and asdf all in one tool https://news.ycombinator.com/item?id=34583080
- https://github.com/untitaker/quickenv - like
direnvbut less intrusive, more light-weight - https://asdf-vm.com
- https://modules.sourceforge.net - Environment Modules, the OG in this space
apt install modules - https://github.com/TACC/Lmod - LMod, this is what's used by UPPMAX
asdf
After reading about it a little, I get the feeling it would be more cumbersome than direnv.
I am not sure I understood correctly, but sounds like the R plugin actually wants to manage the
entire R installation (essentially what rig does).
- https://github.com/asdf-vm/asdf
- https://asdf-vm.com/guide/introduction.html
- https://github.com/asdf-community/asdf-r - community plugin for R
direnv
I cannot find anyone talking about direnv with R on the web. Weird.
- https://direnv.net/#man/direnv.1
- https://direnv.net/#man/direnv-stdlib.1
- https://perrotta.dev/2022/01/direnv-automate-your-environment-variables
- https://rnorth.org/practical-direnv
- https://rnorth.org/more-practical-direnv
- https://pinnsg.com/direnv-take-control-of-your-development-environment
- https://www.digitalocean.com/community/tutorials/how-to-manage-python-with-pyenv-and-direnv
- https://shivamarora.medium.com/a-guide-to-manage-your-environment-variables-in-a-better-way-using-direnv-2c1cd475c8e
- https://platfrastructure.life/post/direnv
- https://github.com/direnv/direnv/issues/73 - some quite interesting example code here
- https://thelinuxcode.com/managing-per-directory-environment-variables-effortlessly-with-direnv
[So what I want] is a "shim" binary that dispatch to the desired binary
https://mise.jdx.dev/dev-tools/shims.htmlThe
.envrcfile is treated like a shell script, where you can also list arbitrary
shell commands that you want to be executed when you enter a project directory.
http://rednafi.com/misc/direnv/#why-envrc-file-and-not-just-a-plain-env-file
My direnv example
Machine in question is Ubuntu 22.04 x64.
$ apt install direnv
$ printf 'if hash direnv >/dev/null 2>&1; then\n eval \"$(direnv hook bash)\"\nfi' >> ~/.bashrc
In the R project directory, I created a subdirectory bin (for convenience) and created a symlink to the R binary I wanted, naming it R. Also added this subdirectory to .gitignore (and .Rbuildignore if it's an R package).
In the package directory I created .envrc containing simply:
PATH_add bin
And enabled with direnv allow the first time I cd into the directory.
Now the R command defined in bin successfully overrides the system-wide command:
$ ls -l `which R`
lrwxrwxrwx 1 taha taha 18 maj 3 21:47 /media/bay/R/periodicdata/bin/R -> /opt/R/4.5.0/bin/R
Note that this works in the terminal. I am pretty sure we will need to do more to have IDEs such as RStudio Server or Codium Server take heed on a per-directory basis. Will investigate further as time permits.
Support for direnv in RStudio Server
In RStudio Server the built-in terminal behaves like any terminal and respects our direnv config, but the built-in "R Console" does not, and neither do the other built-in buttons, Knit, etc. So a lot of stuff will use the wrong R version. Unfortunately Posit still to this day lock their "multiple versions of R" functionality behind a "Pro" license, so that cannot help us.
I guess one (really ugly) work-around would be to run multiple RStudio Server instances, each with a different hard-coded R version: export RSTUDIO_WHICH_R=.... For R package development it's primarily R-release and R-devel that matters, so it's not unworkable. And I have been known to run multiple instances anyway (one per LXC container).
Support for direnv in VSCodium or Code Server
You must install the direnv extension.
In addition, I recommend you reset r.rpath.linux setting in the workspace to:
{ "settings": { "r.rpath.linux": "R" } }
because otherwise VSCodium will use the default R version during startup (before direnv takes effect) which causes lots of warnings about missing packages such as jsonlite or languageserver.
This works not only in code-server but also in VSCodium on the desktop (assuming you have installed direnv on the system) and when using VSCodium with the Remote SSH extension.
- https://github.com/direnv/direnv/wiki/VSCode recommends https://open-vsx.org/extension/mkhl/direnv
- https://github.com/direnv/direnv-vscode (source code of mkhl/direnv, also on https://codeberg.org/mkhl/vscode-direnv although slightly outdated compared to github)
- https://github.com/cab404/vscode-direnv - another VSCode extension, but explicitly superseded by mkhl version above
- https://mtlynch.io/notes/zig-vscode-nix
- https://github.com/direnv/direnv/issues/231 https://marketplace.visualstudio.com/items?itemName=Rubymaniac.vscode-direnv
- https://discourse.nixos.org/t/using-direnv-nix-shell-and-vscode/17225/10
direnv executes arbitrary shell scripts so this extension requires trusted workspaces
More links and notes
- https://github.com/rstudio/renv/issues/254 - How to deal with different versions of R?
- https://stackoverflow.com/questions/63291613/how-to-set-r-version-in-rproj-file - that's not possible
- https://support.posit.co/hc/en-us/articles/200486138-Changing-R-versions-for-the-RStudio-Desktop-IDE
- https://docs.ropensci.org/rix - R package
rixhandles per-project environment with Nix, by Bruno Rodrigues. - https://devenv.sh - comes recommended by this speaker https://youtu.be/YXSSgnhnJ1M (Posit Data Science Lab, 2026-11-16)
R versions
At present 2025-05-03:
- R-devel is NA
- R-patched is NA
- R-release is 4.5.0
- R-oldrel is 4.4.3
This is best determined using the rversions:: package!