home blog tags about

Fixed broken login into X session

written by Robin Schubert on 2022-11-16 | Tags: wiki

I was having difficulties to login to X sessions on a desktop PC, running void linux with the GNOME desktop environment. Every time I entered my password in the login screen, it would go black as if preparing to show my desktop and then throw me back into the login screen. There was no error message or anything.

I tried to login with another user and voila, no issues. Next I tried to login on a non-graphical tty via alt+ctrl+F2, which also worked without problems, so I figured it had to do with something in my user profile that the X session init scripts didn't like. I switched the login manager from gdm to lightdm but saw the exact same behavior.

However, I was looking for errors under /var/log quite a while, checking log files for Xorg and gdm without luck until I eventually had the idea to also scan my home directory for .x* files and found ~/.xsession-errors which finally pointed me in the right direction:

sh: 1: /home/robin/.myexports: Syntax error: "(" unexpected

In an attempt to clean up my dot files of the home directory, I put all shell variables that I export in .zshrc or .bashrc .profile in one file and arranged it for better maintainability. This is a snipped from my $HOME/.myexports file, that is sourced in my $HOME/.profile (which is also symlinked to .bash_profile and zprofile):

export binpaths=(

MYPATH=$(echo ${binpaths[@]} | tr " " ":")

To have a good overview over all the directories that include executable binaries, I create an array which is then joined into my $PATH environment variable. What I didn't know: sh does not support arrays.

The solution to fix my login problem was to replace the hashbang of /etc/lightdm/Xsession from #!/bin/sh to #!/bin/bash. I don't yet know if this change will survive system updates, but at least it's a solution that I understand, although it hasn't been obvious to me.

Creative Commons License