Home > Back-end >  Error attempting to install R packages: malformed universal file: slice content is not mach-o or a s
Error attempting to install R packages: malformed universal file: slice content is not mach-o or a s

Time:08-09

When trying to install R packages (in both RStudio and command-line R) that involve genetic sequence analysis, i.e. ape, adegenet, spider, I get the following error:

ld: malformed universal file: slice content is not mach-o or a static library file '/usr/local/lib/libgfortran.dylib'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ape.so] Error 1
ERROR: compilation failed for package ‘ape’

I've tried a number of things: Reinstalling Xcode, reinstalling gcc via Homebrew, and none of them solve the problem. I get the above error when installing ape, but intermittently get linkage warnings attempting to install ape and always get them when installing adegenet or spider (e.g. ld: warning: object file (decorana.o) was built for newer macOS version (12.5) than being linked (12.0)). I suspect there may be an issue with conflicting versions of gcc existing on my machine. For example, the command which gcc in terminal returns /usr/bin/gcc although brew-installed gcc components are found in /usr/local/Cellar/gcc/. I'm confused about why this is the case because /usr/local/ is listed in advance of /usr/bin/ in my path. Of course, this may not be the only issue.

I'm using MacOS 12.5, RStudio 2022.07.0, R 4.2.1, and brew is completely up to date (e.g. brew outdated returns nothing).

Any and all help would be much appreciated!


The full output from an attempt to install ape in RStudio is as follows:

> install.packages("ape")
Installing package into ‘/usr/local/lib/R/4.2/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/ape_5.6-2.tar.gz'
Content type 'application/x-gzip' length 1754486 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

* installing *source* package ‘ape’ ...
** package ‘ape’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c BIONJ.c -o BIONJ.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c NNI.c -o NNI.o
clang   -std=gnu  14 -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -g -O2  -c RcppExports.cpp -o RcppExports.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c SPR.c -o SPR.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c additive.c -o additive.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c ape.c -o ape.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c bNNI.c -o bNNI.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c bionjs.c -o bionjs.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c bipartition.c -o bipartition.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c bitsplits.c -o bitsplits.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c delta_plot.c -o delta_plot.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c dist_dna.c -o dist_dna.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c dist_nodes.c -o dist_nodes.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c ewLasso.c -o ewLasso.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c heap.c -o heap.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c mat_expo.c -o mat_expo.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c me.c -o me.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c me_balanced.c -o me_balanced.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c me_ols.c -o me_ols.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c mvr.c -o mvr.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c mvrs.c -o mvrs.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c nj.c -o nj.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c njs.c -o njs.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c pic.c -o pic.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c plot_phylo.c -o plot_phylo.o
clang   -std=gnu  14 -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -g -O2  -c prop_part.cpp -o prop_part.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c rTrait.c -o rTrait.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c read_dna.c -o read_dna.o
clang   -std=gnu  14 -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -g -O2  -c reorder_Rcpp.cpp -o reorder_Rcpp.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c reorder_phylo.c -o reorder_phylo.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c treePop.c -o treePop.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c tree_build.c -o tree_build.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c tree_phylo.c -o tree_phylo.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c triangMtd.c -o triangMtd.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c triangMtds.c -o triangMtds.o
clang -I"/usr/local/Cellar/r/4.2.1/lib/R/include" -DNDEBUG  -I'/usr/local/lib/R/4.2/site-library/Rcpp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include -I/usr/local/include   -fPIC  -Wno-implicit-function-declaration  -c ultrametric.c -o ultrametric.o
clang   -std=gnu  14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/4.2.1/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/xz/lib -L/usr/local/lib -o ape.so BIONJ.o NNI.o RcppExports.o SPR.o additive.o ape.o bNNI.o bionjs.o bipartition.o bitsplits.o delta_plot.o dist_dna.o dist_nodes.o ewLasso.o heap.o mat_expo.o me.o me_balanced.o me_ols.o mvr.o mvrs.o nj.o njs.o pic.o plot_phylo.o prop_part.o rTrait.o read_dna.o reorder_Rcpp.o reorder_phylo.o treePop.o tree_build.o tree_phylo.o triangMtd.o triangMtds.o ultrametric.o -L/usr/local/Cellar/r/4.2.1/lib/R/lib -lRlapack -L/usr/local/opt/openblas/lib -lopenblas -L/usr/local/opt/gcc/lib/gcc/11/gcc/x86_64-apple-darwin21/11 -L/usr/local/opt/gcc/lib/gcc/11/gcc -L/usr/local/opt/gcc/lib/gcc/11 -lgfortran -lemutls_w -lquadmath -lm -L/usr/local/Cellar/r/4.2.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: malformed universal file: slice content is not mach-o or a static library file '/usr/local/lib/libgfortran.dylib'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ape.so] Error 1
ERROR: compilation failed for package ‘ape’
* removing ‘/usr/local/lib/R/4.2/site-library/ape’
Warning in install.packages :
  installation of package ‘ape’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/4n/0ghjrzsd4g393zjlgxy9ympc0000gn/T/Rtmpot4Zet/downloaded_packages’

CodePudding user response:

Well... I deleted /usr/local/lib/libgfortran.dylib as it was just a link and this caused the installer to find libgfortran.dylib in a different directory and the install worked with only the linked file warnings. I'm calling this a win.

  • Related