Ubuntu – 15.10: ‘startx $(which unity)’ fails when booting to console

bootunityxorg

I followed this answer and ran the following commands on my 15.10 with Unity Desktop to boot to text mode:

sudo systemctl enable multi-user.target --force
sudo systemctl set-default multi-user.target

The first command gave me the following output though, but I proceeded anyway:

The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).

I also modified the GRUB_CMDLINE_LINUX_DEFAULT="text" line in in /etc/default/grub and ran sudo update-grub afterwards.


The system then booted successfully into text mode and I could use the TTY1 login mask. But after that, I wanted to start the desktop using startx $(which unity), which failed with the error message below (white text on red background btw.):

X.Org X Server 1.17.2
Release Date: 2015-06-16
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.13.0-68-generic x86_64 Ubuntu
Current Operating System: Linux ecs-harigel-webserver 4.2.0-27-generic #32-Ubuntu SMP Fri Jan 22 04:49:08 UTC 2016 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.2.0-27-generic root=UUID=17983985-9c67-4e5b-a6fd-0c501c5abc41 ro text
Build Date: 12 November 2015  05:33:29PM
xorg-server 2:1.17.2-1ubuntu9.1 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.32.6
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Wed Feb  3 10:28:57 2016
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning:          Type "ONE_LEVEL" has 1 levels, but <RALT> has 2 symbols
>                   Ignoring extra symbols
Errors from xkbcomp are not fatal to the X server
Traceback (most recent call last):
  File "/usr/bin/unity", line 21, in <module>
    import glib
ImportError: No module named glib
xinit: connection to X server lost

waiting for X server to shut down (II) Server terminated successfully (0). Closing log file.

The commands startx /usr/bin/gnome-session --session=ubuntu and plain startx bring me to a broken desktop consisting of only the wallpaper and an X-shaped cursor which only moves on the diagonal line from the top left corner downwards to the right..

If it helps, here's the output of env:

XDG_VTNR=1
LC_PAPER=de_DE.UTF-8
XDG_SESSION_ID=c1
LC_ADDRESS=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
SHELL=/bin/bash
TERM=linux
HUSHLOGIN=FALSE
LC_NUMERIC=de_DE.UTF-8
USER=bytecommander
LC_TELEPHONE=de_DE.UTF-8
MAIL=/var/mail/bytecommander
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
QT_QPA_PLATFORMTHEME=appmenu-qt5
LC_IDENTIFICATION=de_DE.UTF-8
PWD=/home/bytecommander
LANG=en_US.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
SHLVL=1
XDG_SEAT=seat0
HOME=/home/bytecommander
LOGNAME=bytecommander
XDG_RUNTIME_DIR=/run/user/1000
LC_TIME=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
_=/usr/bin/env

which python reports /usr/bin/python, which is version 2.7.10.

Looking at python's sys.path value, it's the same booting to text mode and booting to desktop, but compared to another 15.10 installation, the value /usr/lib/python2.7/dist-packages/gtk-2.0 is missing here. I can't import glib in python neither when booted to text mode nor in desktop mode. On the other 15.10 machine, that works.

The package python-dbus is installed in version 1.2.0-2build3 on both systems (the one which makes problems and the one I compare it to).

Why did this happen and how can I fix it to be able to start the GUI when booted into text mode?

Best Answer

Seems like the package python-gtk2 was missing. I installed it:

sudo apt-get install python-gtk2

That explains the difference in Python's sys.path (/usr/lib/python2.7/dist-packages/gtk-2.0 was missing). But on the other machine where the entry was present, according to aptitude why, the package was only installed as dependency of compizconfig-settings-manager, an obviously optional package. I think this package should be converted into a dependency of Unity instead!

But the Unity Desktop I get is still not usable. It has a screen resolution of 800x600 and all indicators are missing, the panel is completely empty. Also I can't change the settings (e.g. the display resolution), which results in an error like this:

screenshot: Failed to apply configuration

I'm opening a new question on this:
Unity Desktop incomplete when launching manually using 'startx $(which unity)'