Switch between different versions of a Program (R)

I have installed R couple years ago and yesterday I compiled a recent version from source.

I now have version 3.4.4 installed, and it's launched with R. Accordingly, I have these command returning like below :

~$ R --version
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
~$ which R
/usr/bin/R

My newest version is installed in a custom directory like so

~/R-3.6.3/bin$ ./R --version
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
~/R-3.6.3/bin$ which R
/usr/bin/R

How can I modify the R version that will be used when I launch R ?

I've tried a modification of the PATH in .bashrc

export PATH="$HOME/R-3.6.3/bin:$PATH"
export PATH=$PATH:$HOME
# result in terminal:
~$ R --version
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
~$ which R
/home/maxime/R-3.6.3/bin/R
# but I don't understand this issue here with sudo
~$ sudo which R
/usr/bin/R
~$ sudo R --version
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"

It work is some way because when I launch R from terminal, I get the 3.6.3 version. But when I launch R from the desktop, I only get the old version.

Should I modify the R.desktop ? I don't understand because it also send the R command...I suppose the .desktop don't get by the .bashrc then...

The ideal solution could be a modification of a line in a file, so I can change this easily and understand which version is used.

Thanks anymay !

1 Answer

You may modify the R.desktop file Exec line to point to /home/maxime/R-3.6.3/bin/R instead of just R.

Instead of modifying the original R.desktop, you may create a copy under ~/.local/share/applications/ and modify that instead. The make it executable for the system to recognise the file.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like