Unable to install nloptr / nlopt on a cluster without root rights

2.5k Views Asked by At

I am trying to install (on a linux based cluster) the R package FactoMineR, which requires nloptr, which in turn requires nlopt. Just using install.packages("nloptr") does not work and yields the following error:

> install.packages("nloptr")
Installing package into ‘/beegfs/group/home/username/.R/3.3.2/R_LIBS_USER’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/x-gzip' length 353957 bytes (345 KB)
==================================================
downloaded 345 KB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking nlopt.h usability... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz",  : 
  cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/usr/bin/gtar: This does not look like a tar archive

gzip: stdin: unexpected end of file
/usr/bin/gtar: Child returned status 1
/usr/bin/gtar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
  '/usr/bin/gtar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to /tmp/RtmpazbyAy/R.INSTALL2d6f734a93606/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory

At this point R freezes and has to be restarted. Therefore, I tried to manually install nlopt and followed the guide on the official website. I installed everything in my home folder because I have no root rights on the cluster. The nloptr installation still fails with the same error of not finding nlopt. This issue seemed to be the same, but using

install.packages('nloptr', dependencies = TRUE, 
                 configure.args = "--with-nlopt-cflags='-I/$HOME/include' --with-nlopt-libs='-L/$HOME/lib64 -lnlopt'")

still yields the same error.
The folder $HOME/include contains these files: nlopt.f nlopt.h nlopt.hpp and $HOME/lib64 contains the following: cmake/ libnlopt.so@ libnlopt.so.0@ libnlopt.so.0.9.0* pkgconfig/ python2.7/.

I already retried several times, using several other tips on related issues, but so far nothing worked and any hints would be greatly appreciated. Thanks!

Edit: Does anyone have ideas?

3

There are 3 best solutions below

1
On

I was seeing a similar error, but installing the github version worked for me.

The README at https://cran.r-project.org/web/packages/nloptr/README.html says:

library(devtools)
devtools::install_github("jyypma/nloptr")

This worked for me. I did install nlopt locally as a module, but I don't know if that made a difference or not; the version of nlopt I installed is 2.5.0.

Hope this is useful!

0
On

If you can not use install.packages("nloptr") to install R package in Cluster, I suggest 2 ways worth trying.

  1. Locally install that package

    • you first load the module for the R version you want to install the package;
    • download package "nloptr_1.0.4.tar.gz" and save it to the directory in VSC;
    • next, make sure you are in the directory that contains the package;
    • last, run command R CMD install nloptr_1.0.4.tar.gz (run outside R)
  2. Try to directly load NLopt module by running a command: module load Nlopt/2.4.2-foss-2015a normally it will work, otherwise you have to contact a technical staff to help you build that with C++.

0
On

The question may be a little old, but I would like to clarify for future references.

I had the same problem when transferring a project created with packrat, at the time of doing the unbundle() in the cluster of the company I saw that I needed to install the package nloptr, as you mention it is just an interface for the nlopt library.

"NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information."

This library is necessary to install it in the system and for this it is necessary to have root permissions. Otherwise, you will have an error message when installing nloptr or you will not be able to complete the installation and stay in that stage blocking the R / Rstudio session.

I do not know of any possibility of doing an installation of that library in "local" for a user and use it to install nloptr or any other package that depends on it.

The only solution I see is that you should contact the IT manager and ask him to install it.

I hope I have been clear and able to help a little.