ropensci / redland-bindings

Redland librdf language bindings
http://librdf.org/bindings/
Other
17 stars 3 forks source link

configure has hardcoded path to R #85

Closed GerardTromp closed 4 years ago

GerardTromp commented 4 years ago

The configure script tries to find R in /bin, i.e., /bin/R. For many versions of UNIX and Linux the convention is to put programs in /usr/bin/ not in /bin (has been that way since at least the early 1980s for UNIX both BSD and SYSV).

A quick solution, if one has root access is to temporarily make a soft link in /bin. A better solution would be for the configure script to find R wherever it is located.

Error:

Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/rasqal -I/usr/include/raptor2
Using PKG_LIBS=-lrdf
./configure: line 48: /bin/R: No such file or directory
./configure: line 49: /bin/R: No such file or directory
./configure: line 50: /bin/R: No such file or directory
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because redland was not found. Try installing:
 * deb: librdf0-dev (Debian, Ubuntu, etc)
 * rpm: redland-devel (Fedora, EPEL)
 * brew: redland (OSX)
If redland is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a redland.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

After soft link to make R available in /bin:

Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/rasqal -I/usr/include/raptor2
Using PKG_LIBS=-lrdf
gothub commented 4 years ago

@GerardTromp the configure script is using the R_HOME environment variable to refer to R, so that is not being set for some reason:

CC=$(${R_HOME}/bin/R CMD config CC)
CFLAGS=$(${R_HOME}/bin/R CMD config CFLAGS)
CPPFLAGS=$(${R_HOME}/bin/R CMD config CPPFLAGS)

The R_HOME env var appears to be set by default (vs being set by the user), as this is available from a freshly installed version of R:

> Sys.getenv("R_HOME")
[1] "/usr/lib/R"

If you have any idea why this env var wasn't set, please comment below. Thanks for your help!

jeroen commented 4 years ago

@GerardTromp I think you are mis-understanding how to install R packages. You should not invoke ./configure yourself but instead if you run R CMD INSTALL pkg_0.1.tar.gz R will automatically run the configure script, with the proper environment variables set.

GerardTromp commented 4 years ago

@jeroen

Thank you for your comment.

That is indeed what I do, although I usually start with invoking install.packages(PACKAGE) in the R environment.

Redland was being install as a dependency and was failing. Only after packages fail to install using base R or devtools, do I invoke R CMD INSTALL "package.tar.gz" on the downloaded packages to debug.

If there still is a failure (after installing any system dependencies, e.g., shared object libraries and include files, i.e., dev or devel packages), I unpack the R package to try to determine what arguments and configure variables need to be passed to the --configure-vars and --configure-args "parameters".

If that fails, I usually ensure that the environment is set up correctly by setting environment variables in the R command script (essentially the R script without invoking the R binary).

Anyway. This morning, I downloaded the redland package again and it installed without a hitch. There have been many updates of both the system libraries and the R side (version and package), making further debugging of the behavior at the time nearly impossible.

I remain a tad puzzled by the behavior, but it is solved now.