0

I've been going round in circles on the web for several hours now so I've given up and need to ask the pros.

I'm trying to install a newer version of R in a local folder on a Ubuntu server. I need a specific package (Phangorn), but the system wide copy of R is too old, and I can't upgrade it because it will break too many other people's dependencies (and I'm not the admin).

So, I downloaded the R-devel latest version and followed these excellent instructions (http://pj.freefaculty.org/blog/?p=315). I had to install my own copies of zlib, liblzma (XZ) and pcre (now in ~/packages). I didn't need to do curl and bzip2 it seems. This caused enough problems as it is, but after much faffing, I was able to successfully compile R.

However, when I try to install Phangorn within it, it gives me the following errors:

/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [igraph.so] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/home/wms_joe/bin/R-devel/library/igraph’
ERROR: dependency ‘igraph’ is not available for package ‘phangorn’
* removing ‘/home/wms_joe/bin/R-devel/library/phangorn’

The downloaded source packages are in
    ‘/tmp/RtmpahSdck/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("phangorn") :
  installation of package ‘igraph’ had non-zero exit status
2: In install.packages("phangorn") :
  installation of package ‘phangorn’ had non-zero exit status

So from what I can tell Phangorn depends on igraph which depends on gfortran, and R can't find it.

It looks to be the same problem as detailed in this thread: Building R package getting error "ld: cannot find -lgfortran "

But the solutions all seem to need softlinking and therefore requiring sudo which totally defeats the point of me doing a local install :/

What are my options here? If I download lgfortran for my own directory (assuming that even fixes the problem) where should I be linking it to?

Community
  • 1
  • 1
Joe Healey
  • 1,232
  • 3
  • 15
  • 34

1 Answers1

1

Those are not 'excellent instructions' as they are for RHEL6, not Ubuntu. So you have an impedance mismatch.

On Ubuntu, your fastest bet (if you have src-dep dependencies) is

sudo apt-get build-dep r-base

The second fastest is to look at the package metadata source to read the Build-Depends from debian/control (but there doesn't seem to be an online copy).

As for phanghorn, you could also try to download its source and just edit away the requirement for a particular R version and see what happens -- sometimes this is just for changes with, say, vignettes and will not affect your usability at all.

Lastly, your build failed because igraph could not be built because gfortran components were missing. Install, if you can, the libgfortran-*-dev package corresponding to your compiler version -- and installing r-base-dev should guarantee it.

Last but not least, consider something like Docker to run local variants of installed programs.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • I couldn't find any instructions for Ubuntu specifically, and those instructions got me to a version of R that would at least compile (hadn't even got that far up to that point). `sudo apt-get` is out because I don't have admin rights. – Joe Healey Apr 11 '17 at 17:43
  • `apt-get r-base` tries to get a 2.14 version of R which is even older than the old version I'm trying to avoid... – Joe Healey Apr 11 '17 at 17:54
  • You misread: `apt-get install r-base` is what you, but `apt-get install r-base-dev` is what I asked you to do. – Dirk Eddelbuettel Apr 11 '17 at 17:59
  • And without help from your admins you won't get a complete build chain. Rock, meet hard place. – Dirk Eddelbuettel Apr 11 '17 at 18:00
  • In general, the `r-sig-debian` list is your best (and very friendly !!) bet for all questions pertaining to using, building, ... with R on Debian-based system, obviously also including Ubuntu as well as Mint and others. – Dirk Eddelbuettel Apr 11 '17 at 18:01
  • Yep I can't `apt-get install r-base-dev` -permissions denied. I'll try what you suggested about possible hacking the phangorn package source (and I've been looking for an excuse to check out Docker too so maybe you're on to something). Thanks for the help so far. – Joe Healey Apr 11 '17 at 18:15
  • Docker would be the _perfect_ solution for your problem, but because of insults compounding injuries, that very Ubuntu host may just be too old to run Docker :-/ – Dirk Eddelbuettel Apr 11 '17 at 18:40