How to install 2 different R versions on Debian?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 12:18:12

As I mentioned in comments, this is theoretically possible just like some package families (Emacs, PostgreSQL, ...) allow multiple concurrent versions.

I cannot offer that right now as we use /usr/{share,lib}/R which conflicts. If I were to make that /usr/{share,lib}/R-$version and then use dpkg-alternatives to flip to a default preferred one, we could possibly do it. The problem is the transition. This feature is used by a minority of user, getting to it may introduce bugs for a majority til this is stable. Plus, I do not have the spare time (but if someone else wants to do it, please do so).

In the meantime, you can

  1. possibly use an advanced feature of dpkg and unpack to a local directory rather the default below / -- so /opt/R/oldversions/2.12.1 should be possible. R could even run, you need to redefine $RHOME accordingly.

  2. just build local variants into /usr/local if you really must

  3. if a particular CRAN / non-CRAN package claims to need a particular version of R, fix the damn package already! ;-)

Finally, this is a topic for r-sig-debian as eg the CRAN maintainer Michael and Johannes won't read this thread here.

You can install different versions of ANY software using proper compile flags. When you run the configure script with --help you should see an option to see the install root.

Take a look at

./configure --help
...
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]

so you could install R-2.14 to:

/usr/local/R/2.14

and you could install R-2.12 to:

/usr/local/R/2.12

when you launch the configure script do:

./configure --prefix=/usr/local/R/2.14

and so on.

I think that if there is no debian repo that provides multiple versions, it is hard to keep two versions of R running smoothly without compiling R from source.

What I often do is install R in my home dir as our institute does not give us root privileges. To install a source version of R systemwide, you could install this in a separate directory (e.g. /opt/R2.14) and use:

./configure --prefix=/opt/R2.14/

The final step is to create a symbolic link to the R binary:

ln -s /opt/R2.14/bin/R /usr/bin/R2.14

Users can than start two versions of R (R and R2.14). Hope this helps!

It's true that building R from source is very very easy (even I can do it!), as long as you know the following command to run first :

apt-get build-dep r-base

otherwise you might get missing library type errors from make. Thanks to Dirk posting that gem in the past. I haven't seen that in the manual, README or FAQ.

Then, it's just :

./configure
make

I suppose this might be a consideration for you then: does R use static or dynamic system libraries? Might a self-built R link to different libraries than the pre-packaged binary R? (I don't know). How much you go into that depends on how critical your application of R is I guess and which system libraries are critical to you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!