While @ArthurMeinild's answer is technically correct for fixing the errors, also note that those lines aren't needed on WSL any longer and should probably just be removed entirely.
As @Raffa mentioned in a comment, it appears you copied these from a website and pasted them in, losing the line-breaks on the first attempt.
You should determine why you are trying to use those lines in the first place and probably consider other (IMHO, better) options. Note that WSL has seen some massive changes and improvements over the last 18 months. If you are following instructions on a website/blog that pre-date that, they may be outdated already. And, of course, always be suspect of any website/blog post that doesn't include a posting or updated date.
As for these particular lines, what they do, and why they probably aren't needed:
The export DISPLAY
line is only needed if you require a third-party X server, which most likely isn't the case any longer. WSL now includes the ability to run GUI applications directly, using WSLg rather than a third-party X server. Please see this answer for information on how to make sure you have updated to the latest release that supports this.
Even if you were using a third-party X server, there's a much better (IMHO) version of that DISPLAY
line:
export DISPLAY="$(hostname).local:0"
See my Super User answer here along with my Stack Overflow explanation.
Likewise, LIBGL_ALWAYS_INDIRECT
isn't needed with the new WSL implementation.
And WSL now can setup and run Systemd and D-Bus directly (if needed, which it often isn't) in the latest releases. See my Systemd answer here for information on how to set it up, and how to determine if you really need it.
Even if you were, for some reason, needing to start D-Bus directly at start-up, using sudo
to do so in your user rc
file isn't the best option. It means you have to type your password each time you start Ubuntu on WSL, which isn't the case normally.
If you need to start a system service (apart from Systemd) when Ubuntu/WSL starts, create a /etc/wsl.conf
file (as sudo
) and use the [boot]
section as in this answer.
As a result of this, I would highly recommend removing all of those additional lines and using the WSL features that accomplish the same thing directly.
~/.bashrc
- fix that. If you want help to fix the error, please post the relevant lines of your~/.bashrc
so people can have a look at it. – Artur Meinild Mar 04 '23 at 20:20~/.bashrc
). You can use that to revert any changes you made. If you aren't sure what the problem line is in the first place, then please use that method to get access to your~/.bashrc
and edit your question to include it. Then reply to this comment with @NotTheDr01ds in it, and I can reopen it. Thanks! – NotTheDr01ds Mar 04 '23 at 20:53fi
starting withexport ...
down on a new line or add a semicolon afterfi
like sofi; export ....
and use https://www.shellcheck.net/ to check your code ... There might be other syntax/structure errors in it. – Raffa Mar 05 '23 at 13:10export
statements on that one line. – NotTheDr01ds Mar 05 '23 at 15:12export
s are just laid down on the same line .... What an unlucky poor shell dealing with all those ... I guess suggesting to load bash without a profile at all might be rather more legitimate in such case after all :) ... It's hard to read from that screenshot anyway. – Raffa Mar 05 '23 at 15:47#!/bin/bash
Alone in the first line before the rest if the code … That is what’s called a shebang :-) – Raffa Mar 07 '23 at 14:45