HenrikBengtsson / R.oo

R package: R.oo - R Object-Oriented Programming with or without References
https://cran.r-project.org/package=R.oo
20 stars 1 forks source link

Error: Could not create generic function. There is already a non-generic function named trim() ... #25

Open bersbersbers opened 3 years ago

bersbersbers commented 3 years ago

This happens on Linux upon package installation when I have library(glue) in my .Rprofile:

> install.packages("R.oo")
Installing package into ‘/data2/bers/opt/R/4.1/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/R.oo_1.24.0.tar.gz'
Content type 'application/x-gzip' length 383514 bytes (374 KB)
==================================================
downloaded 374 KB

* installing *source* package ‘R.oo’ ...
** package ‘R.oo’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in setGenericS3.default(name, export = exportGeneric, envir = envir,  : 
  Could not create generic function. There is already a non-generic function named trim() in package base with the same name as an existing default function trim.default() in base.
Error: unable to load R code in package ‘R.oo’
Execution halted
ERROR: lazy loading failed for package ‘R.oo’
* removing ‘/data2/bers/opt/R/4.1/library/R.oo’
* restoring previous ‘/data2/bers/opt/R/4.1/library/R.oo’

The downloaded source packages are in
        ‘/tmp/RtmpmaGIDZ/downloaded_packages’
Warning message:
In install.packages("R.oo") :
  installation of package ‘R.oo’ had non-zero exit status

It does not happen when I remove library(glue) from my .Rprofile and launch R -e "library(glue); install.packages('R.oo')"

HenrikBengtsson commented 3 years ago

Hi, yes, this is a known problem(*). One workaround is what you've found - avoid loading conflicting packages in ~/.Rprofile. Another workaround is to do:

Sys.setenv(R_PROFILE_USER="NULL")
install.packages("R.oo")

This will trick R to skip ~/.Rprofile while installing R.oo.

(*) The long-term solution to this problem is an overdue updated to R.methodsS3, cf. https://github.com/HenrikBengtsson/R.methodsS3/issues/17.

monagai commented 1 year ago

I've got the following error with R 4.3.1 under Cent OS 7.9.

Error in setGenericS3.default(name, export = exportGeneric, envir = envir,  : 
  (converted from warning) Renamed the preexisting function getMethods to getMethods.default, which was defined in environment R.oo.

Sys.setenv(R_PROFILE_USER="NULL") also worked for this.

I exhausted quite much time to come here.......