afex and phia not found when running 3dMVM


When I try to run 3dMVM, I get an error that some R packages are missing: phia and afex.
I saw that I wasn’t the first with this issue, but I tried solutions that were suggested for other people with the same problem, with no success.
I tried rPkgsInstall -pkgs ‘afex’, and rPkgsInstall -pkgs ‘phia’, and I also I tried installing it from R, but I get an error that “lazy loading failed”.
I found the packages (TAR compressed) in a /tmp/ directory. I copied them manually to my R directory (as well as other packages: car, curl, snow) and extracted the packages there, but still I get an error with 3dMVM:

Error in library("afex") : ‘afex’ is not a valid installed package
Execution halted

I don’t know if it is related or not, but when I try to run 3dMVM from the terminal, before the error message is thrown into the screen I see a fast display of names of all files in the directory, as if all names are echoed into the terminal (I hope it is clear). Not sure if this should happen.


Hi, Galit-

What is the output of: -check_all



Hi, here is the output:

-------------------------------- general ---------------------------------
architecture: 64bit ELF
system: Linux
release: 3.13.0-37-generic
version: #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014
distribution: LinuxMint 17.1 rebecca
number of CPUs: 8
apparent login shell: tcsh
shell RC file: .cshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /home/galit/abin/afni
afni version : Precompiled binary linux_openmp_64: Oct 12 2018
: AFNI_18.3.01
AFNI_version.txt : AFNI_18.3.01, linux_openmp_64, Oct 12 2018
which python : /usr/bin/python
python version : 2.7.6
which R : /usr/bin/R
R version : R version 3.4.4 (2018-03-15) – “Someone to Lean On”
which tcsh : /usr/bin/tcsh

instances of various programs found in PATH:
afni : 1 (/home/galit/abin/afni)
R : 1 (/usr/bin/R)
python : 1 (/usr/bin/python2.7)
python2 : 1 (/usr/bin/python2.7)
python3 : 1 (/usr/bin/python3.4)

testing ability to start various programs…
afni : success
suma : success
3dSkullStrip : success : success
3dAllineate : success
3dRSFC : success
SurfMesh : success
3dClustSim : success

checking for R packages…
rPkgsInstall -pkgs ALL -check : FAILURE

    oo Warning: 
       These packages are not installed on the computer: afex!
    These packages are not installed on the computer: phia!
    These packages are not installed on the computer: brms!

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

------------------------------ python libs -------------------------------
++ module ‘PyQt4’ found at /usr/lib/python2.7/dist-packages/PyQt4
++ module loaded: PyQt4

-------------------------------- env vars --------------------------------
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/galit/abin

R_LIBS = /home/galit/R


------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME
top history: …r]: updated FT/SUMA with current FreeSurfer 6 output
data dir : found AFNI_demos under $HOME
top history: … [pault]: remove rank from FATCAT_DEMO, FAT_MVM_DEMO
data dir : found suma_demo under $HOME
top history: …/SUMA_data/Build_tmp on Wed Aug 20 10:04:23 EDT 2014
data dir : found afni_handouts under $HOME
atlas : found TT_N27+tlrc under /home/galit/abin

------------------------------ OS specific -------------------------------
which apt-get : /usr/bin/apt-get
apt-get version : apt 1.0.1ubuntu2 for amd64 compiled on Oct 28 2014 20:55:14

========================= summary, please fix: =========================

  • missing R packages (see rPkgsInstall)

Hi, Galit-

To check and see which repository for R you are using, what is the output of:

grep -H cran /etc/apt/sources.list


And I believe that Aptitude is the package manager for Linux Mint; does running:

sudo apt-get update
rPkgsInstall -pkgs ALL -update

install your missing packages? (you can see the list of missing ones in your output).


Thanks. Indeed, I am using Mint.

Running the sudo command did not install the packages, according to the output of (I see a warning that afex, phia and brms are not installed).

Running the grep command, I get the following output:

/etc/apt/sources.list:deb rebecca/
/etc/apt/sources.list:deb rebecca/
/etc/apt/sources.list:deb rebecca/
/etc/apt/sources.list:deb rebecca/
/etc/apt/sources.list:deb rebecca/
/etc/apt/sources.list:deb rebecca/

Hi, Galit-

I see. I am not sure, because I don’t know much about the Mint OS, but it appears that the “rebecca” version of it is basically Ubuntu “trusty” (14.04).

So, let’s try this:

  1. open up /etc/apt/sources.list, which will require sudo permission; any text editor will do, but ‘gedit’ tends to be a common one on Linux:

sudo gedit /etc/apt/sources.list

  1. comment out those 6 lines in that file; that is, put a hash “#” at the start, so that they look like (NB: the AFNI MB is turning the actual link into a hyperlink abbreviation-- find the line with the link to “” in that file):

# deb rebecca/

  1. then, below those put the following line into the file (NB: don’t use the Message Board hyperlink abbreviation of the real path-- put the actual web address after ‘deb’):

deb trusty/

Save and close the file.

  1. I don’t know if it would be necessary to remove your current R and reinstall it-- let’s just try updating what you have now. Copy+paste the following into a terminal (each might prompt you for your password, or it might remember it from using sudo to open the text file):
    a) :

sudo apt-get update


sudo apt-get install -y r-base-dev r-cran-rmpi
sudo apt-get -f install

  1. try install the AFNI-specific packages

rPkgsInstall -pkgs ALL -update

… and check your system check again.


Thanks, unfortunately it still didn’t work.

  1. In the sources list I changed things as you said (with the actual url and not the hyperlink). Here is the output:

grep -H cran /etc/apt/sources.list

/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:#deb rebecca/
/etc/apt/sources.list:deb trusty/

Should the commented lines be in the output?

  1. Updated R, I see this:

rPkgsInstall -pkgs ALL -update

This package has been installed on the computer: afex
This package has been installed on the computer: phia
This package has been installed on the computer: brm

However, in the system check they still don’t exist. -check_all

    oo Warning: 
       These packages are not installed on the computer: afex!
    These packages are not installed on the computer: phia!
    These packages are not installed on the computer: brms!

Perhaps the following output from the updating command might help - this appeared right before the announcement of successful installation (I get this kind of error for many packages there other than afex):

  • installing source package ‘afex’ …
    ** package ‘afex’ successfully unpacked and MD5 sums checked
    ** R
    ** data
    ** inst
    ** preparing package for lazy loading
    Warning: S3 methods ‘print.curl_handle’, ‘print.curl_multi’, ‘print.form_data’, ‘print.form_file’ were declared in NAMESPACE but not found
    Error in library.dynam(lib, package, package.lib) :
    shared object ‘’ not found
    ERROR: lazy loading failed for package ‘afex’
  • removing ‘/home/galit/R/afex’
  • restoring previous ‘/home/galit/R/afex’

And in addition this message also appears:

The downloaded source packages are in

Many thanks again for all the help!

Try installing ‘curl’ first:

rPkgsInstall -pkgs ‘curl’

Then run

rPkgsInstall -pkgs ALL

Thanks Gang. I did as you said, but when I install ‘curl’ I get the following error:

------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:

  • deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
  • rpm: libcurl-devel (Fedora, CentOS, RHEL)
  • csw: libcurl_dev (Solaris)
    If libcurl is already installed, check that ‘pkg-config’ is in your
    PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
    is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars=‘INCLUDE_DIR=… LIB_DIR=…’

ERROR: configuration failed for package ‘curl’

  • removing ‘/home/galit/R/curl’
  • restoring previous ‘/home/galit/R/curl’
    ERROR: dependency ‘xml2’ is not available for package ‘spelling’
  • removing ‘/home/galit/R/spelling’

The downloaded source packages are in

libcurl is installed (so it says when I try to install it). But I am not sure how to follow the rest of the instructions. Here is what I tried to do (and I might have done it all wrong):

  1. I checked if ‘pkg-config’ is in my PATH:

pkg-config --variable pc_path pkg-config


I suppose it means that it is there?

  1. I set PKG_CONFIG_PATH to search for packages where the downloaded R packages are:

setenv PKG_CONFIG_PATH /tmp/RtmpUqDXzp/downloaded_packages

It still didn’t work, so I suppose I did something wrong here. Your help is highly appreciated!

I’m clueless at this point. Maybe try one more thing:

sudo apt-get install libcurl4 libcurl4-openssl-dev -y

Thanks Gang, and everyone! Problem solved - apparently I was missing the xml package, and for that package to compile, I had to run the following code (found it here):

sudo apt install libxml2-dev

After running that, I was able to install phia and afex with no problem.

Thanks again for all the help!

Hi, Galit-

That is great news. I guess that might be a slight difference between Mint and Ubuntu installs. On my Ubuntu 14.04 desktop, I checked what xml2 packages were installed (probably all as dependencies of other installed packages), and this is what I get:

dpkg --get-selections | grep xml2
libxml2:amd64					install
libxml2-utils					install
python-libxml2					install

No libxml2-dev, but still something of those. I’m not sure if the Mint installations hadn’t had any xml2 packages installed, or just not the right library for that system.

Anyways, congrats on solving it-- and thanks for posting the solution here.