Install afex error - Mac Monterey 12 (12.0.1)

I cannot get the afex R package to install. Among some other issues with installation that I am stuck at.

I tried the following:
(1) setting LD_LIBRARY_PATH = /usr/local/lib in my .zshrc, hopefully that is the right path
(2) brew install gcc
(3) Installing afex package in R with install.packages(‘afex’)
– this was giving errors like “ld: library not found for -lgfortran”
(4) So I tried installing https://github.com/rmacoslib/r-macos-rtools/releases/tag/v3.2.2
but then installing afex still gave a similar error “ld: library not found for -lm”

I get a TON of warnings when trying to install afex, but perhaps the most relevant errors are:


Warning: Unused dummy argument ‘sp’ at (1) [-Wunused-dummy-argument]
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o quantreg.so akj.o boot.o bound.o boundc.o brute.o chlfct.o cholesky.o combos.o crqf.o crqfnb.o dsel05.o etime.o extract.o frand.o grexp.o idmin.o iswap.o kuantile.o kuantiles.o linpack.o mcmb.o penalty.o pfnb.o powell.o profnb.o pwxy.o qfnb.o qselect.o quantreg_init.o rls.o rq0.o rq1.o rqbr.o rqfn.o rqfnb.o rqfnc.o rqs.o sakj.o sparskit2.o srqfn.o srqfnc.o srtpai.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: library not found for -lm
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [quantreg.so] Error 1
ERROR: compilation failed for package ‘quantreg’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/quantreg’
ERROR: dependency ‘quantreg’ is not available for package ‘car’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/car’
ERROR: dependency ‘car’ is not available for package ‘afex’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/afex’

I am out of ideas

Here is my output of afni_system_check.py -check_all


-------------------------------- general ---------------------------------
architecture:         64bit 
system:               Darwin
release:              21.1.0
version:              Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64
distribution:         10.16
number of CPUs:       16
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/keithdodd/abin/afni
afni version         : Precompiled binary macos_10.12_local: Mar  2 2022 
                     : AFNI_22.0.15 'Hadrian'
AFNI_version.txt     : AFNI_22.0.15, macos_10.12_local, Mar 02 2022
which python         : /Users/keithdodd/opt/anaconda3/bin/python
python version       : 3.9.7
which R              : /Library/Frameworks/R.framework/Resources/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
which tcsh           : /bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/Users/keithdodd/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
    python  : 2 
      /Users/keithdodd/opt/anaconda3/bin/python3.9
      /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/pythonwrapper.app/Contents/MacOS/pythonwrapper
    python2 : 1   (/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/pythonwrapper.app/Contents/MacOS/pythonwrapper)
    python3 : 3 
      /Users/keithdodd/opt/anaconda3/bin/python3.9
      /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9
      /usr/bin/python3


testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    uber_subject.py      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        
        oo Warning: 
           These packages are not installed on the computer: afex!
        

R RHOME : /Library/Frameworks/R.framework/Resources

checking for $HOME files...
    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

++ module loaded: matplotlib.pyplot
   module file : /Users/keithdodd/opt/anaconda3/lib/python3.9/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.5.0

-- python binaries under /usr/local/bin:
    /usr/local/bin/python3 (sym link to /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9)
    /usr/local/bin/python3.9 (sym link to /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9)

-------------------------------- env vars --------------------------------
PATH = /Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources:/Library/Frameworks/R.framework/Resources:/Users/keithdodd/opt/anaconda3/bin:/Users/keithdodd/opt/anaconda3/condabin:/usr/local/fsl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/keithdodd/Library/Python/3.8/bin:/Users/keithdodd/.local/bin:/Users/keithdodd/abin:/Users/keithdodd/abin:/Users/keithdodd/abin:/Users/keithdodd/abin:/Users/keithdodd/abin:/Users/keithdodd/abin:/Users/keithdodd/abin

PYTHONPATH = 
R_LIBS = 
LD_LIBRARY_PATH = /usr/local/lib

DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) = 

------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : found TT_N27+tlrc  under /Users/keithdodd/abin

------------------------------ OS specific -------------------------------
XQuartz version      : 2.8.1

which brew           : /usr/local/bin/brew
brew version         : Homebrew 3.4.0

-- for PyQt4 under brew, consider running:
   brew install cartr/qt4/pyqt
** consider linking /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/libgomp.1.dylib under /usr/local/lib
++ found valid link /usr/local/lib/libglib-2.0.dylib
   to ../Cellar/glib/2.70.4/lib/libglib-2.0.dylib
++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
   -- found 'libXt' dylib files:
      /opt/X11/lib/flat_namespace/libXt.6.dylib
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell 'zsh'...
++ found evar DYLD_LIBRARY_PATH = :/opt/X11/lib/flat_namespace
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in shell 'tcsh'...
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)

Thanks!

Is your compiler coming from the brew tree or from conda?
A failing -lm error is peculiar, in that the math library should always be available, which suggest an environmental issue.
The gfortran library should come with gcc under homebrew. A conda version might be questionable.
The system check did warn about possibly making a link for openMP (gomp), but that should be separte from -lm or -lgfortran.

Anyway, can you tell which compiler is being used (i.e. the path to clang that is being applied)?

  • rick

Hi,
Try:


brew install openmpi

If that fails, there is a gfortran installer from R (cran)
See this:
https://mac.r-project.org/tools/

Separate issues but one may help

Hello, I tried both of those things and then tried installing afex again, but still errors everywhere :/. I can send error logs if it helps. Thanks!

Sorry just saw this.

I apologize but I need clarification. I am not sure how to check where my compiler (and am not sure what is meant by “the path to the clang that is being applied”) is coming from. I would assume from brew tree, as I had brew and not conda I believe. Although I have since installed conda last week.

Thanks!

Current output of afni check is:


-------------------------------- general ---------------------------------
architecture:         64bit 
system:               Darwin
release:              21.1.0
version:              Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64
distribution:         10.16
number of CPUs:       16
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/keithdodd/abin/afni
afni version         : Precompiled binary macos_10.12_local: Mar  2 2022 
                     : AFNI_22.0.15 'Hadrian'
AFNI_version.txt     : AFNI_22.0.15, macos_10.12_local, Mar 02 2022
which python         : /Users/keithdodd/opt/anaconda3/bin/python
python version       : 3.9.7
which R              : /Library/Frameworks/R.framework/Resources/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
which tcsh           : /bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/Users/keithdodd/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
    python  : 2 
      /Users/keithdodd/opt/anaconda3/bin/python3.9
      /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/pythonwrapper.app/Contents/MacOS/pythonwrapper
    python2 : 1   (/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/pythonwrapper.app/Contents/MacOS/pythonwrapper)
    python3 : 3 
      /Users/keithdodd/opt/anaconda3/bin/python3.9
      /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9
      /usr/bin/python3


testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    uber_subject.py      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        
        oo Warning: 
           These packages are not installed on the computer: afex!
        

R RHOME : /Library/Frameworks/R.framework/Resources

checking for $HOME files...
    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

++ module loaded: matplotlib.pyplot
   module file : /Users/keithdodd/opt/anaconda3/lib/python3.9/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.5.0

-- python binaries under /usr/local/bin:
    /usr/local/bin/python3 (sym link to /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9)
    /usr/local/bin/python3.9 (sym link to /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/bin/python3.9)

-------------------------------- env vars --------------------------------
PATH = /Library/Frameworks/R.framework/Resources:/Users/keithdodd/opt/anaconda3/bin:/Users/keithdodd/opt/anaconda3/condabin:/usr/local/fsl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/keithdodd/Library/Python/3.8/bin:/Users/keithdodd/.local/bin:/Users/keithdodd/abin

PYTHONPATH = 
R_LIBS = 
LD_LIBRARY_PATH = /usr/local/lib

DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) = 

------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME (1908108M Avail)
           top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : missing AFNI_demos
data dir : found suma_demo    under $HOME
           top history: ...s_New/data/Build_tmp on Mon Mar  4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME
atlas    : found TT_N27+tlrc  under /Users/keithdodd/abin

------------------------------ OS specific -------------------------------
XQuartz version      : 2.8.1

which brew           : /usr/local/bin/brew
brew version         : Homebrew 3.4.3

-- for PyQt4 under brew, consider running:
   brew install cartr/qt4/pyqt
** consider linking /usr/local/Cellar/gcc/11.2.0_3/lib/gcc/11/libgomp.1.dylib under /usr/local/lib
++ found valid link /usr/local/lib/libglib-2.0.dylib
   to ../Cellar/glib/2.70.4/lib/libglib-2.0.dylib
++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
   -- found 'libXt' dylib files:
      /opt/X11/lib/flat_namespace/libXt.6.dylib
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell 'zsh'...
++ found evar DYLD_LIBRARY_PATH = :/opt/X11/lib/flat_namespace
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in shell 'tcsh'...
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)


rick reynolds Wrote:

Is your compiler coming from the brew tree or from
conda?
A failing -lm error is peculiar, in that the math
library should always be available, which suggest
an environmental issue.
The gfortran library should come with gcc under
homebrew. A conda version might be questionable.
The system check did warn about possibly making a
link for openMP (gomp), but that should be separte
from -lm or -lgfortran.

Anyway, can you tell which compiler is being used
(i.e. the path to clang that is being applied)?

  • rick