user15866126
user15866126

Reputation: 89

Error: package or namespace load failed for ‘matlib’

I am getting this error everytime I run library(matlib): Error: package or namespace load failed for ‘matlib’: .onLoad failed in loadNamespace() for 'rgl', details: call: rgl.init(initValue, onlyNULL) error: OpenGL is not available in this build

library(matlib)
Registered S3 methods overwritten by 'rgl':
  method               from
  knit_print.rglId         
  knit_print.rglOpen3d     
  sew.rglRecordedplot      
Error in dyn.load(dynlib <- getDynlib(dir)) : 
  unable to load shared object '/Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so':
  dlopen(/Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
  Referenced from: /Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so
  Reason: image not found
Warning:    Loading rgl's DLL failed. 
    This build of rgl depends on XQuartz, which failed to load.
 See the discussion in https://stackoverflow.com/a/66127391/2554330
Warning: Trying without OpenGL...
Error: package or namespace load failed for ‘matlib’:
 .onLoad failed in loadNamespace() for 'rgl', details:
  call: rgl.init(initValue, onlyNULL)
  error: OpenGL is not available in this build

Upvotes: 1

Views: 2327

Answers (1)

user15866126
user15866126

Reputation: 89

Running this before library(matlib) worked for me:

Sys.setenv(RGL_USE_NULL=TRUE)

Upvotes: 3

Related Questions