Closed HenrikBengtsson closed 2 years ago
We also need to create that folder automagically, which may be a bit tricky. Might have to hardcode the architecture and infer x.y from x.y.z version string (using Lua code). Alternatively, one could call Rscript --vanilla -e "Sys.getenv('R_LIBS_USER')"
UPDATE 2019-08-15: There's no need to pre-created this folder;
> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[3] "/usr/lib/R/library"
> install.packages("startup")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("startup") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) yes
Would you like to create a personal library
‘/home/alice/R/x86_64-pc-linux-gnu-library/3.6-CBI’
to install packages into? (yes/No/cancel)
A backward compatible action that can be take right now is to have at least new users use the new R_LIBS_USER
folder:
local rlibsuser = ... -- the built-in R_LIBS_USER folder
if (not isdir(rlibsuser))
setenv("R_LIBS_USER","~/R/%p-library/%v-CBI")
end
Where isdir()
is from https://stackoverflow.com/a/40195356/1072091:
--- Check if a file or directory exists in this path
function exists(file)
local ok, err, code = os.rename(file, file)
if not ok then
if code == 13 then
-- Permission denied, but it exists
return true
end
end
return ok, err
end
--- Check if a directory exists in this path
function isdir(path)
-- "/" works on both Unix and Windows
return exists(path.."/")
end
-- Checks if R_LIBS_USER folder exists
function r_libs_user_is_dir()
local f = io.popen("Rscript -e \"cat(utils::file_test('-d', Sys.getenv('R_LIBS_USER')))\"", "r")
local s = assert(f:read('*a'))
f:close()
return(s == "TRUE")
end
This works:
-- Checks if R_LIBS_USER folder exists, i.e. is already used.
-- If not, then it's safe to use one specific to the CBI stack
local r_libs_user = capture("Rscript -e \"cat(Sys.getenv('R_LIBS_USER'))\"")
if (not isDir(r_libs_user)) then
setenv("R_LIBS_USER", path .. "-CBI")
end
crancache: Set CRANCACHE_DIR
to be CBI specific
crancache: Set
CRANCACHE_DIR
to be CBI specific
Basically moot, because no one should be running R 3.6.0 that is on the system.
Issue
R packages built from native code when using the CBI build of R may not be compatible with the CentOS build of R.
Suggestion
Have the CBI build of R install packages in a different location;
Roadmap
If we add this now, people will have to re-install all their R packages. Do we have to wait for R 3.7.0 (Spring 2020)?