0

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

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.

| improve this answer | |
  • Okay it work when I launch it from desktop (I did this modification for previous soft and understand how it works). But why does it keep using R 3.4.4 when I launch sudo R? – Gowachin Mar 11 at 12:28
  • 1
    @Gowachin sudo is configured to use its own secure_path - if you want to run a local version of R with sudo the easiest way will be to use its full path. Although I don't see why you'd want to run a personal version of R with sudo (that sounds like a recipe to mess up the ownership of your files). – steeldriver Mar 11 at 12:57
  • I just want to understand which file is used when I launch R (and Rstudio). The sudo part of the question is more of personnal interest. My principal worries is that however the method I launch R, it's always a chosen version. At this point to set the version I need to modify .bashrc and R.desktop, which I find prone to error if I miss the edition in on file. – Gowachin Mar 11 at 13:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.