Packages downloaded but not in library - Mac

I'm completely new to R and coding so feeling utterly overwhelmed here - any help at all would be truly appreciated.

I've been trying to install the package dartR on my mac, and it appears to download to a separate file on the computer but will not launch in studio or R. I've tried installing associated packages in case that was the problem, but as far as I can tell nothing will work. On my work computer, a Windows, everything run smooth as can be so I'm wondering if it is a mac issue?

I don't have a great understanding of what I'm doing so I'm struggling to troubleshoot, or even explain on here what the issue is so I've included a quick copy-paste of some of the code.

 install.packages("dartR")
installing the source package ‘dartR’

trying URL 'https://cran.rstudio.com/src/contrib/dartR_1.1.11.tar.gz'
Content type 'application/x-gzip' length 3927292 bytes (3.7 MB)
==================================================
downloaded 3.7 MB

* installing *source* package ‘dartR’ ...
** package ‘dartR’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘adegenet’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘deldir’
Error: package ‘adegenet’ could not be loaded
Execution halted
ERROR: lazy loading failed for package ‘dartR’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
Warning in install.packages :
  installation of package ‘dartR’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T/RtmpaWDoVt/downloaded_packages’
> install.packages("adegenet")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/adegenet_2.1.1.tgz'
Content type 'application/x-gzip' length 2904493 bytes (2.8 MB)
==================================================
downloaded 2.8 MB


The downloaded binary packages are in
	/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T//RtmpaWDoVt/downloaded_packages
> library(adegenet)
Error: package or namespace load failed for ‘adegenet’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘deldir’
> 

This is the first time I've installed R and tried to run anything on this computer.
Any advice or suggestions would mean a lot, thank you!!

On Mac, you should expect that installs from source will fail a high percentage of time, and the unzipped/untarred package is left in the /tmp directory in the case you want to try to correct the source code. Usually, you should just use install.packages(dartR) if you get

non-zero exit status

after your first attempt..

I did that on my Mac but ran into another problem. A dartR dependency qvalue isn't on CRAN, but on BioConductor, a parallel universe of R for the life sciences, which you should know about if you'll be doing more work in this field. See the instructions at the gibhub site for how to install.

Hi Technocrat, sorry for the late reply here. Thank you for providing all that information to me, I've run through the instructions on GitHub and tried all the methods listed but unfortunately I'm still running into issues and unable to ultimately install dartR:

> install.packages("dartR")
installing the source package ‘dartR’

trying URL 'https://cran.rstudio.com/src/contrib/dartR_1.1.11.tar.gz'
Content type 'application/x-gzip' length 3927292 bytes (3.7 MB)
==================================================
downloaded 3.7 MB

* installing *source* package ‘dartR’ ...
** package ‘dartR’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so
  Reason: image not found
Error: .onLoad failed in loadNamespace() for 'rgl', details:
  call: NULL
  error: 	Loading rgl's DLL failed. 
	On MacOS, rgl depends on XQuartz, which you can download from xquartz.org.
Execution halted
ERROR: lazy loading failed for package ‘dartR’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
Warning in install.packages :
  installation of package ‘dartR’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T/Rtmpi6WuLd/downloaded_packages’
> install.packages("devtools")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("devtools")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/devtools_2.1.0.tgz'
Content type 'application/x-gzip' length 322875 bytes (315 KB)
==================================================
downloaded 315 KB


The downloaded binary packages are in
	/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T//RtmpJ0M7du/downloaded_packages
> library(devtools)
Loading required package: usethis
> install.packages("BiocManager")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/BiocManager_1.30.4.tgz'
Content type 'application/x-gzip' length 288867 bytes (282 KB)
==================================================
downloaded 282 KB


The downloaded binary packages are in
	/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T//RtmpJ0M7du/downloaded_packages
> BiocManager::install(c("SNPRelate", "qvalue"))
Bioconductor version 3.9 (BiocManager 1.30.4), R 3.6.1 (2019-07-05)
Installing package(s) 'SNPRelate', 'qvalue'
trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/macosx/el-capitan/contrib/3.6/SNPRelate_1.18.1.tgz'
Content type 'application/x-gzip' length 3842701 bytes (3.7 MB)
==================================================
downloaded 3.7 MB

trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/macosx/el-capitan/contrib/3.6/qvalue_2.16.0.tgz'
Content type 'application/x-gzip' length 2795880 bytes (2.7 MB)
==================================================
downloaded 2.7 MB


The downloaded binary packages are in
	/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T//RtmpJ0M7du/downloaded_packages
> install_github("green-striped-gecko/dartR")
Downloading GitHub repo green-striped-gecko/dartR@master
✔  checking for file ‘/private/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T/RtmpJ0M7du/remotes86a94afeeb30/green-striped-gecko-dartR-3f9eebd/DESCRIPTION’ ...
─  preparing ‘dartR’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘dartR_1.3.4.tar.gz’
   
* installing *source* package ‘dartR’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgl/libs/rgl.so
  Reason: image not found
Error: .onLoad failed in loadNamespace() for 'rgl', details:
  call: NULL
  error: 	Loading rgl's DLL failed. 
	On MacOS, rgl depends on XQuartz, which you can download from xquartz.org.
Execution halted
ERROR: lazy loading failed for package ‘dartR’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/dartR’
Error: Failed to install 'dartR' from GitHub:
  (converted from warning) installation of package ‘/var/folders/xv/mq6gtkdd3dx55cs7nd3q3w080000gn/T//RtmpJ0M7du/file86a97f41aa4f/dartR_1.3.4.tar.gz’ had non-zero exit status

Thankyou again for you help, much appreciated!

It seems like you don't have xquartz installed in your system, lets start by installing that and see if that helps

https://www.xquartz.org/

1 Like

@SeRina @andresrcs is right. Usually when we think of package dependencies, it's other R packages. When you are compiling from source

─  building ‘dartR_1.3.4.tar.gz’
   
* installing *source* package ‘dartR’ ...

there can also be external dependencies for compiled libraries buried deep in the OS file system.

The link will probably fix that. It's recommended to reinstall each time you have an OS or R version upgrade.

Sometimes, it will not be obvious how to find a missing library. The brew is a utility program that does a good job of hunting them down and installing them. In cases where that fails, because it's an obscure library and googling doesn't providing guidance, post here. Chances are another user has been through the same quest.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.