Re: Failed to load R_io.so

I will revive this thread since I ran into the same (or into a very similiar problem).

My aim: I wanted to use 3dLME for a second-level analysis. AFNIs 3dLME explanation (https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dLME.html) explains that it is required to upgrade R via the following terminal code: “rPkgsInstall -pkgs ALL”.

The problem: Using the command above, the terminal gives me the following error message below:

oo Warning:
Failed to load R_io.so with this error message:

Error in dyn.load(ll) :
cannot load shared object ‘/Users/Philipp/abin/R_io.so’:
dlopen(/Users/Philipp/abin/R_io.so, 6): Library not loaded: /sw/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libR.dylib
Referenced from: /Users/Philipp/abin/R_io.so
Reason: image not found
Ruft auf: source … withVisible → eval → eval → set_R_io → dyn.load
Ausführung angehalten

Two things:

  1. The file “load R_io.so” really exists in its correct place (/Users/Philipp/abin/).
  2. Then I did a quick “afni_system_check.py -check_all” AFNI check. This lead to one problem: “please set DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace”

My computer:

  • 2013 Macbook, OS Big Sur 11.6.1
  • R Version: R 4.1.1 GUI 1.77 High Sierra build (7985). If you wonder why I use the High Sierra R version on Big Sur: the “R 4.1.1 binary for macOS 11 (Big Sur) and higher, Apple silicon arm64 build” does not work on my intel Macbook (it does not even allow me the installation).
  • AFNI and XQuartz are up to date. I even reinstalled AFNI because I thought that may helps me to solve this problem. Interestingly I ran into the same problem while reinstalling AFNI. More precisely, the part where R should be installed (https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_mac.html) and the command “sudo rPkgsInstall -pkgs ALL” has to be copied into the terminal. Here, the terminal also complains about the “R_io.so” file so that it cannot update the R specific packages for AFNI.

My first question would be how I can set the DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace?
And my second question is what I can do to solve the problem with the “R_io.so” file for installing the R updates required to run several AFNI programs such as 3dLME.

Thanks,
Philipp

An update:

I realized that the error message “please set DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace” for “afni_system_check.py -check_all” only occurs because I am running Zsh as a shell instead of either bash or tcsh. Is there a way to adjust AFNIs following script from this source (https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_mac.html#setup-mac-env-variables) to Zsh? I am refering to the following script:

[quote="script: touch ~/.cshrcscript: touch ~/.cshrc
echo ‘if ( $?DYLD_LIBRARY_PATH ) then’ >> ~/.cshrc
echo ’ setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace’ >> ~/.cshrc
echo ‘else’ >> ~/.cshrc
echo ’ setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace’ >> ~/.cshrc
echo ‘endif’ >> ~/.cshrc

touch ~/.bashrc
echo ‘export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace’ >> ~/.bashrc
echo ‘if ( $?DYLD_LIBRARY_PATH ) then’ >> ~/.cshrc
echo ’ setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace’ >> ~/.cshrc
echo ‘else’ >> ~/.cshrc
echo ’ setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace’ >> ~/.cshrc
echo ‘endif’ >> ~/.cshrc

touch ~/.bashrc
echo ‘export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace’ >> ~/.bashrc"]

[/quote]

I guess that adjusting and applying this script once to Zsh would solve my first problem?

Hi Philipp,

The flat_namespace bit is secondary, and might just be because apple tries to make working with such variable more and more difficult.
In any case, just add that same .bashrc line to your ~/.zshrc file (if it isn’t already there).

export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace

But R_io.so is compiled against R version 3.6.x. So on a mac at least, it does not currently work with 4.x.
If you really want to use the R packages on that mac, it might be necessary to compile AFNI locally, which might take some work (the homebrew dependencies seem to be a bit of a moving target right now). Is that something that you would like to consider? Otherwise, is installing 3.6 an option?

  • rick

Hi Rick,

I uninstalled and reinstalled AFNI a couple of times now. The current status of the problem is as follows.

The command line “export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace” is added in my “.zshrc” file.

The message output by afni_system_check.py -check_all “please set DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace” only appears when using the Zsh shell. If I switch to tcsh, this message does no longer occur when doing the system check.

I also uninstalled the newest R version and switched back to 3.6.3. When I now run “rPkgsInstall -pkgs ALL” the error “load R_io.so” does no longer occur. Instead, the terminal starts to download the updates. Many “warnings” occur while the files are downloaded, but I believe thats due to the fact that I am not using the up-to-date version of R (it is a really long list of warnings, if its helpfull to post it there, let me know). These warnings occur both when running “rPkgsInstall -pkgs ALL” under the tcsh and zsh shell.

The download and installation of “rPkgsInstall -pkgs ALL” then ends with the following message output:

++ Note: @ 11:13:31
This package has been installed on the computer: afex

Warnmeldungen (warning messages):
1: In install.packages(pkgs_miss, dep = TRUE, repos = site) :
installation of package ‘quantreg’ had non-zero exit status
2: In install.packages(pkgs_miss, dep = TRUE, repos = site) :
installation of package ‘glmmTMB’ had non-zero exit status
3: In install.packages(pkgs_miss, dep = TRUE, repos = site) :
installation of package ‘car’ had non-zero exit status
4: In install.packages(pkgs_miss, dep = TRUE, repos = site) :
installation of package ‘afex’ had non-zero exit status

Now what is interesting is the following fact:
This is the output of AFNIs system check while running the Zsh shell (my favorite shell).

========================= 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
  • please set DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace

And this is the output when running the tcsh shell.
========================= 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

These summaries appear after I ran “rPkgsInstall -pkgs ALL”. There was another topic here where someone had a similiar problem and you wrote that the message “please set DYLD_LIBRARY_PATH to include /opt/X11/lib/flat_namespace” under zsh might just be a bug while running zsh, but that in fact everything is ok. Even if that would be the case, we would still face the problem with the missing R packages (or could that be a bug too?).

Let’s sum it up:

  • The problem with the “R_io.so” file seems solved.
  • The message to incldue the DYLD_LIBRARY path might be a bug related to the usage of zsh.
  • What would be your idea to solve the problem with the missing R packages? Are there some other files required for AFNI that might be missing on my computer?

rick reynolds Wrote:

Hi Philipp,

If you really want to use the R packages on that
mac, it might be necessary to compile AFNI
locally, which might take some work (the homebrew
dependencies seem to be a bit of a moving target
right now). Is that something that you would like
to consider? Otherwise, is installing 3.6 an
option?

  • rick

I am not sure if my knowledge would allow me to do those changes in AFNI and on my computer. But is that option off the table since I already switched to R 3.6.3 anyway? Please let me know if you have another idea on the “missing R packages (see rPkgsInstall)” output by AFNIs system check, or if you think that this problem is directly related to what you just explained and asked me above, so that I have to compile AFNI locally, whatever this means in detail.

Thanks,
Philipp

Philipp,

installation of package ‘afex’ had non-zero exit status

It seems that the main failure is about the installation of the R package “afex”, which would only impact on the AFNI program 3dMVM. So, you can proceed to use all other AFNI programs except 3dMVM.

As for the issue with ‘afex’, you may try the following command inside R:

install.packages(‘quantreg’)

and track down the problem.