WSL mrview, could not connect to any X display

Dear Authors:
I installed the MRtrix under WSL2 fellowed the instructions. But the mrview seems not work. And I also tried the command export DISPLAY=my own ip :0, but also failed.

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-liu'
qt.qpa.screen: QXcbConnection: Could not connect to display 0:0
Could not connect to any X display.

Thanks
liu

Dear Liu,

I cannot help you with that directly, but one option is to run the version of MRtrix that comes already installed in NeuroDesk (GitHub - NeuroDesk/neurodesk: A flexible, scalable, and easy to use data analysis environment for reproducible neuroimaging). The easiest way is to follow the Quickstart instructions, and when you have the VNM running, choose “VNM Neuroimaging” → “Diffusion imaging” → “mrtrix3” → “mrviewGUI 3.0.2” from the start menu. If it doesn’t work the first time, click on mrviewGUI 3.0.2 once more, and it should work.
If you have any issues, you can start a new discussion in the “Discussions” tab in the link above.

Good luck,
Oren

Hello,

Unfortunately, as outlined in this wiki post, the graphical applications in MRtrix won’t work easily within WSL/WSL2. There isn’t much we can do about this currently, although this may change once Microsoft adds Wayland support to WSL2. It’s in the works, but not yet released – I’m hoping it won’t be long, at which point we’ll likely switch from to WSL2 as our recommended installation option on Windows (currently, we only support installation under MSYS2, since that’s the only way to get mrview to work reliably).

Dear Liu,

This is what has worked for me:

if you are using WSL2, add these lines to you ~/.bashrc

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=0

If you use WSL, then replace export DISPLAY=:0 instead.

Install VcXsrv and change your firewall settings to allow all incoming connections to vcxsrv (create new rule and add vcxsrv.exe to allowed applications). Launch an X session (Mutiple windows, display number: -1 → start no client → unselect native opengl, select disable access control → finish).

Restart your WSL/WSL2 session and you should have mrview working.

As an alternative to using VcXsrv, you can install MobaXterm and if you launch your WSL2/WSL session from there, it should work out of the box (after configuring firewall access to the MobaXterm executable).

Hope it helps,
Nick

4 Likes

Hi Nick,
Thanks to your help, my mrview is finally working!
You are great!
Liu

Glad that it worked!

Cheers,
Nick