How to install the rgl package in macOS Big Sur - r

I have been trying to install the rgl package in my macOS Big Sur, but I have failed each time.
I have downloaded R from the CRAN website, and have also installed Xquartz. After rebooting the computer, I tried to install the rgl package from the R console. It installs successfully, but whenever I type library("rgl") in the R console, the package does not load, and instead, this is shown :
Error in dyn.load(dynlib <- getDynlib(dir)) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rgl/libs/rgl.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rgl/libs/rgl.so, 6): Symbol not found: _hb_buffer_add_utf8
Referenced from: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rgl/libs/rgl.so
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rgl/libs/rgl.so
Error: package or namespace load failed for ‘rgl’:
.onLoad failed in loadNamespace() for 'rgl', details:
call: rgl.init(initValue, onlyNULL)
error: OpenGL is not available in this build
In addition: Warning messages:
1: 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
2: Trying without OpenGL...
I headed to the link that this error message mentions, and tried uninstalling rgl and Xquartz, and reinstalling them again, but the issue remains.
Moreover, here it is said that I am supposed to delete org.xquartz.startx.plist from /Library/LaunchDaemons, but from the terminal, after navigating to the Library directory, it seems that there is nothing named LaunchDaemons or LaunchAgents.
Any help would be appreciated. I am using macOS Big Sur 11.4, Xquartz 2.8.1 and rgl 0.106.8. Thanks.

Related

R tcl issue on shared HPC cluster environment

I've been having some issues getting R to run properly on the shared cluster at my institution , where i don't have root access. Some things will work but it gets tricky when i need to install packages etc. The current issue i'm trying to trouble shoot is the following error when trying to load the caret package:
Loading required package: lattice
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so':
/cifs/hariri-long/Scripts/Tools/R/packages/rlang/libs/rlang.so: undefined symbol: R_removeVarFromFrame
Error: package ‘ggplot2’ could not be loaded
Execution halted
I found this page suggesting i install rlang as follows:
> install.packages("rlang",type="source")
Installing package into ‘/cifs/hariri-long/Scripts/Tools/R/packages’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Can't find a usable init.tcl in the following directories:
/usr/share/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.13/library ./tcl8.5.13/library
but i get the above tcl error. since i've seen this in other threads:
> capabilities("tcltk")
tcltk
TRUE
it looks like tcl on my system is 8.6, but i don't know how to tell R to look for that version.
$ whereis tcl
tcl: /usr/lib64/tcl8.6 /usr/include/tcl.h /usr/share/tcl8.6
$ which R
/opt/apps/rhel7/R-3.6.0/bin/R
Any ideas? The OS is CentOS 8. Thanks!
I ended up deciding to try using a more recent R version (4.1.1) to solve this issue. I was hesitant to do this at first because I have run into issues with availability / compatibility of packages I need in more recent R versions, but I wasn't getting anywhere troubleshooting this issue otherwise. I figured that since TCL 8.6 is what was installed on the system, a newer version of R might be able to work with it, and seems i was right, since I got past the first error I was having when I switched.
I did get a new error regarding an issue loading the shared library Libtk8.6.so. So I downloaded the .so file from here and unpacked it to my home directory using rpm2cpio (i don't have root access so i can't just use yum install etc). After that i just had to re-install all my packages for the new R version and it worked!

Error: package or namespace load failed for ‘rjags’

I have a M1 Macbook Pro running OS Big Sur and just tried to install rjags and JAGS. I downloaded JAGS from https://sourceforge.net/projects/mcmc-jags/ without a problem, and ran install_packages("rjags"), but when I run library(rjags) I get this error:
Loading required package: coda
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so':
dlopen(/Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so, 10): Library not loaded: /opt/R/arm64/lib/libjags.4.dylib
Referenced from: /Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so
Reason: image not found
I understand this means that R cannot "find" the installation of JAGS. I am using renv for this project, but even if I deactivate it and re-run install_packages("rjags") and library(rjags) I get the error (just with different file paths):
Loading required package: coda
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so, 10): Library not loaded: /opt/R/arm64/lib/libjags.4.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so
Reason: image not found
I'm a stats person without much back-end computer expertise so I'd appreciate help resolving this!
See here for a similar post.
So have you installed the correct version of JAGS on your Apple computer?
Essentially, rjags is an R interface and it needs an installed JAGS (a back-end you mentioned) to function.
Follow the instructions here to install JAGS on Apple computers with M1 chips.
Also from the link above (from JAGS development team):
A readme file is provided in the disk image - please do read it.
If you find that rjags fails to load after installation of JAGS,
make sure you have installed the Mavericks or El Capitan binary of
R from CRAN. If you really need the Snow Leopard build of R (or if
you compiled R yourself) you will have to compile JAGS from source.
If you have followed the instructions above (and in the relevant
README file) and are still having problems with installation of
these binaries, please let us know via the JAGS discussion forum.
PS: I would comment if I could, but I am new here and don't have enough points to do so.

RStudio won't allow me to install the package 'imager'

Installed RStudio using Anaconda Navigator even though I already had RStudio and it was working fine before. The package 'imager' didn't load so I removed the application from Navigator and completely uninstall R and RStudio from my Macbook and reinstalled R and the application through Navigator, but that didn't fix things. Other packages install just fine. The following is the error message:
library(imager)
Error: package or namespace load failed for ‘imager’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so':
dlopen(/Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so, 6): Library not loaded: /opt/X11/lib/libX11.6.dylib
Referenced from: /Users/omeedkashef/Library/R/3.4/library/imager/libs/imager.so
Reason: image not found
I had this same problem. I did not have a problem installing imager from CRAN but did get an error message when trying to load the CRAN-installed package. When I tried installing from GitHub I got the more useful error message saying that X11 was not found (same as #andrii above). I solved all issues by installing X11 by downloading from this site: https://www.xquartz.org/
EDIT: I should mention that this is not a problem with RStudio per se, as the header of the question suggests, but rather just a dependency issue of one package (imager) on a not-explicitly R piece of sofware (X11).

Installed rJava, Installed Java 8 update. Still cannot load rJava on MacOS Sierra

Bear in mind that I am computer illiterate and new to R. I have installed the rJava package in R studio version 1.0.143 and installed Java 8 (using MacOS Sierra). When I try to load the rJava package:
library(rJava)
I get the following error
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object
'/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so':
dlopen(/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so, 6):
Library not loaded: #rpath/libjvm.dylib
Referenced from:
/Users/cormac/Library/R/3.4/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning messages:
1: package ‘rJava’ was built under R version 3.4.2
2: running command '/usr/libexec/java_home' had status 1
Could somebody help me to interpret this error message? There is probably a very simple solution, but I am completely lost. Thank you!!
As noted in Unable to load rJava in RStudio, there is a very specific sequence of steps that must be taken to get rJava to work on a Macbook, as documented in rJava Issues #86.
Download and install Java from Oracle
Uninstall any previously installed version of rJava
Add JAVA_HOME to your .bashrc
Close & restart terminal, R and RStudio sessions so they pick up the updated JAVA_HOME
Use install.packages() to install rJava
See the URL link above for additional details on each step.

Error installing packages in R after messing with "pahts"

I was trying to install the rattle package in R and got this error message saying
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
Then I tried to fix the RGtk2 problem using this guide
http://marcoghislanzoni.com/blog/2014/08/29/solved-installing-rattle-r-3-1-mac-os-x-10-9/
I tried this code in the Mac OS terminal (but this is above my understanding) :
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
sudo port selfupdate
sudo port install pkgconfig
export PATH=/opt/pkgconfig/bin:$PATH
sudo port install gtk2 +x11
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
It gave me this answer
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
ad-mac0630:~ caruc35$ sudo port selfupdate
Password:
Sorry, try again.
Password:
And locked down.
I also installed XCode command line tools from Apple and tried some stuff from the guide above. It didnt get the rattle package to work so I erased it.
After messing with this the rattle package does still not work and R seems not to work as it did before. For example i can´t load the xlsx package getting this error message:
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so':
dlopen(/Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘rJava’ could not be loaded
Did I mess up when trying to change PATH? Is there a way to reset everything back to normal?
I have tried reinstalling R but the same problems still occurs.

Resources