AFNI Opening Issue - "AFNI is detached from terminal"

I have recently downloaded AFNI on my desktop (Windows 10) using the ‘Quick Setup’ instructions here (after having downloaded Linux and XQuartz):
However, I am unable to open AFNI through the Ubuntu terminal. I get the following error message when I type “afni”:

Precompiled binary linux_ubuntu_16_64: Feb 18 2022 (Version AFNI_22.0.11 'Hadrian')

** Version check disabled: AFNI_VERSION_CHECK forbids
Thanks go to P Kundu for great efforts

Initializing: X11Error: Can't open display: :0.0
++ AFNI is detached from terminal.

This is the message I get following the command “ -check_all”:

-------------------------------- general ---------------------------------
architecture:         64bit ELF
system:               Linux
version:              #1 SMP Fri Apr 2 22:23:49 UTC 2021
distribution:         ubuntu 20.04 focal
number of CPUs:       6
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /home/marcus/abin/afni
afni version         : Precompiled binary linux_ubuntu_16_64: Feb 18 2022
                     : AFNI_22.0.11 'Hadrian'
AFNI_version.txt     : AFNI_22.0.11, linux_ubuntu_16_64, Feb 18 2022
which python         : /usr/bin/python
python version       : 3.8.2
which R              : /usr/bin/R
R version            : R version 4.1.2 (2021-11-01) -- "Bird Hippie"
which tcsh           : /usr/bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/home/marcus/abin/afni)
    R       : 1   (/usr/bin/R)
    python  : 1   (/usr/bin/python3.8)
    python2 : 0
    python3 : 1   (/usr/bin/python3.8)

** have python3 but not python2

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success      : 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!
        These packages are not installed on the computer: phia!
        These packages are not installed on the computer: lmerTest!

R RHOME : /usr/lib/R

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 : /usr/lib/python3/dist-packages/matplotlib/
   matplotlib version : 3.1.2

-------------------------------- env vars --------------------------------
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2020.424.0_x64__79rhkp1fndgsc:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/d/Program Files/MATLAB/R2020b/bin:/mnt/c/Program Files/PsychoPy3:/mnt/c/Program Files/PsychoPy3/DLLs:/mnt/c/Program Files/dotnet/:/mnt/c/Users/Marcus/AppData/Local/Programs/Python/Python39/Scripts/:/mnt/c/Users/Marcus/AppData/Local/Programs/Python/Python39/:/mnt/c/Users/Marcus/AppData/Local/Microsoft/WindowsApps:/snap/bin:/home/marcus/abin

R_LIBS = /home/marcus/R


------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME (257007M Avail)
           top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : found AFNI_demos   under $HOME
           top history: ...ct 2020 [taylorp]: updated scripts under FATCAT_DEMO
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 /home/marcus/abin

------------------------------ OS specific -------------------------------
which apt-get        : /usr/bin/apt-get
apt-get version      : apt 2.0.2 (amd64)

have Ubuntu system: ubuntu 20.04 focal
have Ubuntu afni  : Precompiled binary linux_ubuntu_16_64: Feb 18 2022

=========================  summary, please fix:  =========================
*  just be aware: login shell 'bash', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)

Any ideas on how to fix this? I have seen similar questions posted before, but they all appear to have slightly different issues.
Thank you very much for your time!

The “detached from terminal” is normal behavior, but it appears you have not set the DISPLAY variable, and you may not have installed an Xserver too. The installation for WSL under Windows requires a bit more than native Ubuntu:

WSL version 1 is easier to configure than WSL2. You will also need to select an Xserver (VcXsrv is the one described in the instructions).

Hi Daniel,

Thank you for your response, and apologies for my slow one. I beleive I have installed Xserver - I run it before opening Ubuntu.

How do I set the DISPLAY variable?


You would typically set that variable in your .bashrc file so that it is set everytime you restart a WSL instance. That is a configuration file for the bash shell. WSL versions 1 and 2 work differently, so you would set that variable for the one you are using. Most users have had better success with version 1 of WSL. Besides that WSL instruction page, there are a few message board posts like this one that give some specifics for WSL1 and WSL2.,164375,164375

Problem solved, using the process given in the link you sent. I opened the Windows PowerShell and typed the commands:

wsl --set-version Ubuntu 1
wsl --set-default-version 1

After restarting my computer, I was able to load up AFNI.

Thank you for your help!