0

I have a package 'My_Package' in this path /proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/My_Package

I am trying to exectute an Rscript by scheduling a cronjob. Each time cronjob runs I get the following error

Error in eval(expr, envir, enclos) :
could not find function ".getNamespace"
In addition: Warning message:
package 'My_Package' was built under R version 3.2.3
Error : unable to load R code in package 'My_Package'
Error: package/namespace load failed for 'My_Package'
Execution halted

Here is part of my Rscript code:

#!/usr/bin/Rscript
#========================================================================

##clear the memory
rm(list = ls())

##these are the settings for the 'My_Package' local rlib.

lib_path1 = "/proj/users/Rbud"
lib_path2 = "packrat/lib/x86_64-pc-linux-gnu/3.2.3"

## Load the My_Package package
Rlocal_lib = file.path(lib_path1,lib_path2)
.libPaths(c(.libPaths(),Rlocal_lib))

library("My_Package",lib.loc = file.path(lib_path1,lib_path2))
library(hash,lib.loc = file.path(lib_path1,lib_path2))
library(RJDBC,lib.loc = file.path(lib_path1,lib_path2))
##The code continues....

I tried with including install.packages(My_Package, lib = "/proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/") in the Rscript code but I couldn't resolve the issue.

Could you please tell me why I am getting this error and the possible ways to resolve it.

R Bud
  • 261
  • 1
  • 4
  • 16
  • You should probably install the package using `install.packages("location.of.tarball", repos = NULL)` – Andrie May 24 '16 at 13:48
  • Does the package work if you use it within `R` or RStudio (not `RScript`)? If not, it must be a problem of your package, if yes, the `methods` package is probably missing. See http://stackoverflow.com/a/19468533/4468078 for a solution – R Yoda Nov 19 '16 at 00:28

0 Answers0