AFNI Installation failure on Windows

I installed WSL and Ubuntu 20.4 and AFNI using the command scripts.
When I typed afni in my bash shell I got this:

Precompiled binary linux_ubuntu_16_64: Oct 17 2023 (Version AFNI_23.3.02 'Septimius Severus')

** Version check disabled: AFNI_VERSION_CHECK forbids
Thanks go to G Chen for great efforts

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

Thank you.


Did you install VcXsrv, and the shell variables here?
Note that you have to start VcXsrv on your computer before opening a terminal, too. (Hopefully, Windows will make this process easier some day...)


Thank you for the response. Yes I have installed XLaunch, I started it, went through the prompts and clicked 'Finish' and then installed the shell variables. Maybe there is an option I should click on the XLaunch setup?

In the XLaunch setup for VcxSrv, you should set Native opengl off, Disable access control on. The installation instructions are written for wsl version 1, but the default installation nowadays is version 2. Xlaunch should be started each time before starting wsl Ubuntu.

You can force version 1 for all wsl instances or for specific wsl instances like this:

wsl --set-default-version 1

wsl2 may be configured for wslg in which case, that supports X11 graphics without VcxSrv, but it doesn't do a very good job of it the last time I checked, about a year ago. This is how to turn off wslg if it's being used.

Users wanting to use different servers than the one provided by WSLg can change these environment variables. User can also choose to turn off the system distro entirely by adding the following entry in their .wslconfig file (located at c:\users\MyUser.wslconfig - on the Windows side of the file system). This will turn off support for GUI applications in WSL.


Many at NIH use mobaXterm for X11 ssh and terminal features. It also features an integrated wsl controls. That would be instead of VcxSrv.

One of these ways ought to work, so let us know how it works out.

Thank you very much, it works now!
A couple of things that were going on (in case someone has the same issue).
It seems in the past I had installed WSL2 and an older version of Ubuntu (which I removed), so when I typed :

wsl --list --verbose

the (new) 20.04 version was associated with version 2.
I used

wsl --set-version Ubuntu-20.4 1

which associated the Ubuntu with version 1. I also changed the XLaunch setup as you suggested.
Thank you.

1 Like