sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.35k stars 460 forks source link

Fix hardcoding of paths in R binary #9668

Closed kcrisman closed 11 years ago

kcrisman commented 14 years ago

See this thread on sage-support.

Here is how I got the optional package automap to install into a 
binary sage R. 
Go into the sage directory and edit the following files: 
local/bin/R and local/lib/R/bin/R 
and change all the hard-set user variables "/scratch/...." to the true 
locations of R_HOME_DIR, R_HOME, R_INCLUDE_DIR, R_SHARE_DIR and for 
good measure, R_DOC_DIR. Replace the default string EVERYWHERE in the 
file. 
I then exported SAGE_HOME as well (Not sure that this is needed.), and 
run local/bin/R 
Inside R, install.packages("automap") 
No more build errors, and when I restart R, automap loads using 
library. Just have to try it out from sage now. 
Any chance there's a script to find all of these hard-set strings and 
change them to correct values? 

Related (R package):


New spkg: http://boxen.math.washington.edu/home/palmieri/SPKG/r-2.15.2.p2.spkg

CC: @nexttime @jhpalmieri

Component: packages: standard

Keywords: R spkg R.sh.in libR.pc pkg-config hard-coded package installation R_HOME_DIR sd32 r-project

Author: John Palmieri

Reviewer: Karl-Dieter Crisman, Jeroen Demeyer

Merged: sage-5.9.rc0

Issue created by migration from https://trac.sagemath.org/ticket/9668

jhpalmieri commented 11 years ago
comment:41

For what it's worth, someone reported on ask.sagemath.org that this spkg fixed their problem with installing an R package.

kcrisman commented 11 years ago
comment:42

I think that sounds like a positive review, combined with Jeroen's good comments... What do you think?

jhpalmieri commented 11 years ago
comment:43

I think that someone should confirm that with the new spkg, in the script local/bin/R, the variables R_SHARE_DIR, R_INCLUDE_DIR, and R_DOC_DIR are now defined in terms of R_HOME_DIR rather than being hard-coded paths as they are with the current spkg.

kcrisman commented 11 years ago
comment:44

I think that someone should confirm that with the new spkg, in the script local/bin/R, the variables R_SHARE_DIR, R_INCLUDE_DIR, and R_DOC_DIR are now defined in terms of R_HOME_DIR rather than being hard-coded paths as they are with the current spkg.

I can do this.

kcrisman commented 11 years ago

Changed reviewer from Karl-Dieter Crisman to Karl-Dieter Crisman, Jeroen Demeyer

kcrisman commented 11 years ago
comment:45

I confirmed that moving a Sage install (not just binary) caused installing an R package to fail with precisely the problems one would expect if these were incorrectly defined (e.g.

Warning: R include directory is empty -- perhaps need to install R-devel.rpm or similar

with appropriate nonexistent directory referenced). The script local/bin/R had the (now incorrect) paths.

Then installing this spkg and retrying caused success, and local/bin/R looks right now too. Nice work!

kcrisman commented 11 years ago
comment:46

One question, though... when I move Sage back and run Sage, it doesn't change R_HOME_DIR back.

R_HOME_DIR=/Users/.../Downloads/tempR/sage-5.9.beta5/local/lib/R

when it should be

R_HOME_DIR=/Users/.../Downloads/sage-5.9.beta5/local/lib/R

So this was changed, presumably, when I reinstalled the spkg. It doesn't impact installing new R packages, by the way, nor functionality of R.

In particular, moving a different Sage installation and starting Sage changes some things, but doesn't change the location of R_HOME_DIR in local/bin/R. I'm not sure why that doesn't affect functionality, but presumably this should somehow be taken care of. On this ticket?

jhpalmieri commented 11 years ago
comment:47

It took me a little while to understand this, too. Right before the lines defining R_SHARE_DIR, etc., there are lines

if test x$SAGE_BUILDING_R = x; then
    R_HOME_DIR="$SAGE_LOCAL/lib/R/"
fi

If you're not building the R spkg, then this will be executed, overriding the hard-coded path earlier in the script, and setting R_HOME_DIR to the desired portable setting. I don't know R, so I don't know how to test this: if you run sage -R, can you execute some R command to tell you the current setting of R_HOME_DIR?

kcrisman commented 11 years ago
comment:48

Well, that is a Sage-specific thing, I think, but we have

R_HOME="${R_HOME_DIR}"

later on and also

$ ./sage -R RHOME
/Users/.../Downloads/sage-5.9.beta5/local/lib/R/

So all is well, I think.

jdemeyer commented 11 years ago

Merged: sage-5.9.rc0