im-config configuration ignored with gdm3

Bug #1720250 reported by Gunnar Hjalmarsson
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gdm3 (Ubuntu)
Invalid
High
Unassigned
im-config (Ubuntu)
Fix Released
High
Gunnar Hjalmarsson

Bug Description

After having logged in via gdm3, the IM related environment variables are always set like this:

$ env | grep -E '_IM|XMOD'
QT_IM_MODULE=ibus
XMODIFIERS=@im=ibus

Changing ~/.xinputrc to e.g. xim makes no difference, so gdm3 prevents all other IM frameworks but IBus from working.

This problem seems to be similar to bug #1594681 (which was fixed).

Changed in im-config (Ubuntu):
importance: Undecided → High
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdm3 (Ubuntu):
status: New → Confirmed
Changed in im-config (Ubuntu):
status: New → Confirmed
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

My wayland session is same result.

Anyway, /usr/lib/systemd/user/im-config.service is installed, but systemctl doesn't show that unit file. Is it OK?

$ systemctl list-unit-files | grep im-config
(nothing)

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@Mitsuya: I don't know systemd well enough to tell. What I did before drawing the conclusion that it's somehow gdm3 related was to install and test with lightdm. With lightdm the im-config variables are preserved also on GNOME shell (with or without Wayland).

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Mitsuya, im-config provides a systemd *user* service. You'll need to use --user to see it like this:

$ systemctl --user list-unit-files | grep im-config

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> im-config provides a systemd *user* service.

Oh, sorry...

$ systemctl --user list-unit-files | grep im-config
im-config.service static
$ systemctl --user status im-config.service
● im-config.service - Launch and configure input method
   Loaded: loaded (/usr/lib/systemd/user/im-config.service; static; vendor preset: enabled)
   Active: inactive (dead)

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> With lightdm the im-config variables are preserved also on GNOME shell (with or without Wayland).

Umm...

With GDM3, Ubuntu.Xorg session correctly set GTK_IM_MODULE and other environments.
In this case, im-config will be launched from /etc/X11/Xsession.d/70im-config_launch.

If GTK_IM_MODULE and others is not be set on Wayland only,
I thought this will be caused by systemd service file.
However lightdm worked with Wayland, more need to be investigated further...

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Fist of all, I don't know details about history of upstart/unity
and user session system. There is no conclusion, just my research.

---

For Unity8/Mir, upstart script of im-config was added LP #1433831
This Ubuntu only script should be removed from im-config package.

Since switching user session from upstart to systemd, above upstart script
is convert to systemd unit on 0.29-1ubuntu14.

However this unit file uses initctl command, then this unit work on both of
systemd and upstart installed system only.

Legacy (Xorg) system will launches /etc/X11/Xsession.d/70im-config_launch
and set STARTUP variable to exec /usr/bin/im-launch.
All environment variables are set, no problem.

Wayland system doesn't exec /etc/X11/Xsession.d, i.e. any mechanism to
set environment variables is needed as like on Unity8/Mir.

(old) systemd unit doesn't work by two reasons.

  1. use initctl command of upstart
  2. bind to graphical-session.target which is not launched on ubuntu

If I understand correctly, graphical-session.target and graphical-session-pre.target
will be launched for unity8 system and others.
At artful, this target are not depended by any target and service.

/usr/lib/gnome-session/run-systemd-session will stop these targets,
but this script will be executed from unity.desktop only.

How about use basic.target instead of graphical-session.target?
I attach sample im-config.service.

sudo cp im-config.service /usr/lib/systemd/user/
systemctl --user daemon-reload
systemctl --user enable im-config.service
(and restart session by logout and login)

This service file will work about environment variables.

$ env | grep -E '_IM|XMOD'
CLUTTER_IM_MODULE=xim
QT4_IM_MODULE=xim
QT_IM_MODULE=ibus
XMODIFIERS=@im=ibus
GTK_IM_MODULE=ibus

However suggestion window will be displayed on top left of display,
not near cursor on gedit and gnome-termial. The reason isn't known.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks, Mitsuya, for valuable input!

As regards the upstart stuff, it was introduced before Unity8, and since I don't know if all the flavors have switched to systemd for user session, I'm disinclined to drop it at this time.

I uploaded a test version of im-config here:

https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

The difference compared to the version in the queue is that I made use of your im-config.service script and changed the related symlink accordingly.

Even if the variables seem to be properly set, I made this observation:

$ systemctl --user list-unit-files | grep im-config
im-config.service disabled

Can't tell if that is of any significance.

Anyway, I'll try to make some experienced developer review this solution. It looks promising to me.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

Gunnar, upstart has been removed from Debian 9 "Stretch" and from Ubuntu 17.10.

You should drop the debian/menu too.
https://lintian.debian.org/tags/command-in-menu-file-and-desktop-file.html

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-02 00:00, Jeremy Bicha wrote:> Gunnar, upstart has been removed from Debian 9 "Stretch" and from
> Ubuntu 17.10.
Ah, had missed that.

> You should drop the debian/menu too.
I just uploaded a new version to the PPA with those changes.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> I uploaded a test version of im-config here:

Thanks!

> Even if the variables seem to be properly set, I made this observation:
>
> $ systemctl --user list-unit-files | grep im-config
> im-config.service disabled

$ systemctl --user status im-config.service
● im-config.service - Launch and configure input method
   Loaded: loaded (/usr/lib/systemd/user/im-config.service; disabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2017-10-02 22:45:14 JST; 26min ago
 Main PID: 1266 (code=exited, status=0/SUCCESS)

10月 02 22:45:14 ubuntu-ax2 systemd[1260]: Starting Launch and configure input method...
10月 02 22:45:14 ubuntu-ax2 systemd[1260]: Started Launch and configure input method.

As my understand, user session unit is enabled by symlink on ~/.config/systemd/user/.
If there is not symlink on the directory, "is-enabled" command will show "disabled".
"/usr/lib/systemd/user" is vendor preset directory, and just show "vendor preset: enabled".

If you exec "systemctl --user preset", it will create symlink on ~/.config/systemd/user.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Unfortunately, gnome-terminal and gedit show select window on top left...
(this behavior same as old im-config on wayland, not problem on xorg).

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Just for your information, I attached zesty's result about systemd.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-02 16:19, Mitsuya Shibata wrote:> As my understand, user session unit is enabled by symlink on
> ~/.config/systemd/user/. If there is not symlink on the directory,
> "is-enabled" command will show "disabled". "/usr/lib/systemd/user"
> is vendor preset directory, and just show "vendor preset: enabled".
>
> If you exec "systemctl --user preset", it will create symlink on
> ~/.config/systemd/user.
I think you misunderstood the nature of my observation. The modified package in the PPA works out of the box via the system level symlink:

/usr/lib/systemd/user/basic.target.wants/im-config.service

So no need to set a symlink in the users' HOME.

Maybe it's not a problem at all. I just noticed a difference.

> Unfortunately, gnome-terminal and gedit show select window on top
> left... (this behavior same as old im-config on wayland, not problem on
> xorg).
Ok. I first thought it was a side effekt of the new im-config.service file, but now I realize it's not. Then it's probably not related to im-config at all, but rather ibus/wayland/whatever.

Revision history for this message
Iain Lane (laney) wrote :

ok, I had a look at the unit

  - basic.target is quite basic, it happens for every user session. If the first session is a SSH login then we'll execute im-config when we probably shouldn't.
  - PartOf=graphical.target will be necessary when we get back to launching the UI under systemd (hopefully in 18.04), please don't drop it
  - Maybe this isn't a problem with basic.target, but it will be when we use graphical-session-pre.target - type=oneshot will mean that this is executed on every login
  - Same, maybe ok with basic.target --- there's no way to clear the variables and they won't be scoped to there being a graphical session (existing bug with the unit?)

Thought - what about putting a script in /etc/profile.d? basically doing what the unit would do, but make sure to case it on $XDG_CURRENT_DESKTOP being nonempty or something, so it doesn't run for shell logins.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

As per Iain's suggestion I have uploaded a new variant to the PPA, where a file in /etc/profile.d replaces the modifications of im-config.service. It works AFAICT, but I'd appreciate your confirmation before I upload to the archive.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> So no need to set a symlink in the users' HOME.
> Maybe it's not a problem at all. I just noticed a difference.

Yes, you are right. My old comment is just reason why "list-unit-files" show "disabled".

> Then it's probably not related to im-config at all, but rather ibus/wayland/whatever.

Filed as another bug #1721023

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Ian and Gunnar,

Thank you for details about systemd target and new package!

The profile.d version works on my environment too with gedit (gtk app) and setup-mozc (qt app).
However suggestion window doesn't show up...

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2017-10-03 15:16, Mitsuya Shibata wrote:
> The profile.d version works on my environment too with gedit (gtk
> app) and setup-mozc (qt app).

Ok..

> However suggestion window doesn't show up..

Confirmed. So then it doesn't work properly after all, right? (It does show up on "Ubuntu on Xorg", though.)

Revision history for this message
Iain Lane (laney) wrote : Re: [Bug 1720250] Re: im-config configuration ignored with gdm3

On Tue, Oct 03, 2017 at 01:16:54PM -0000, Mitsuya Shibata wrote:
> However suggestion window doesn't show up...

Please could you try to find out why this is?

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

As Iain suggested on IRC

https://irclogs.ubuntu.com/2017/10/03/%23ubuntu-devel.html#t15:52

I checked out what the processes looked like for the two attempts at a solution, and attached a couple of files with my observations.

Well, not sure what I should look for, to be honest, but that exercise inspired me to a possible solution: Since gdm3 always starts ibus-daemon anyway, I added a condition to /usr/share/im-config/data/21_ibus.rc so im-config does not start ibus-daemon if gdm3 is the DM. That seems to fix it.

So I have uploaded yet another variant to the PPA.

https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

Revision history for this message
Iain Lane (laney) wrote :

On Wed, Oct 04, 2017 at 12:40:03AM -0000, Gunnar Hjalmarsson wrote:
> As Iain suggested on IRC
>
> https://irclogs.ubuntu.com/2017/10/03/%23ubuntu-devel.html#t15:52
>
> I checked out what the processes looked like for the two attempts at a
> solution, and attached a couple of files with my observations.
>
> Well, not sure what I should look for, to be honest, but that exercise
> inspired me to a possible solution: Since gdm3 always starts ibus-daemon
> anyway, I added a condition to /usr/share/im-config/data/21_ibus.rc so
> im-config does not start ibus-daemon if gdm3 is the DM. That seems to
> fix it.
>
> So I have uploaded yet another variant to the PPA.
>
> https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

Thanks Gunnar, good find.

I wonder what this is telling us - you end up with multiple copies of
iBus running or something? Or the order matters and somehow the
basic.target one starts up early enough and the other one doesn't?

From looking at that 21_ibus.rc script, it doesn't look like it's
crucial that im-config is the thing to actually execute iBus, right? If
that's the case, this is probably good. If it tests out, feel free to
upload.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I'm not able to spot the root cause for the problem with the ibus-mozc suggestion window, but I have tested on Ubuntu, Ubuntu on Xorg and Unity both with GDM and LightDM. The suggestion window failed to show up with the combination Wayland + LightDM, but that's an odd combo anyway, and the other tests were successful.

So I uploaded to the queue.

Changed in gdm3 (Ubuntu):
status: Confirmed → Invalid
Changed in im-config (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
status: Confirmed → Fix Committed
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

My apologies for late and sparse reply...

> So I have uploaded yet another variant to the PPA.

Thank you for your upload. Suggestion window become to visible!

--

I will tackle following issues related to input method until 18.04 release.

- bug #1721023 : suggestion window position
- bug #1719938 : ibus-mozc isn't enabled by default on Japanese locale

Thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package im-config - 0.32-1ubuntu2

---------------
im-config (0.32-1ubuntu2) artful; urgency=medium

  * debian/input-method-config.sh, debian/rules:
    - Script which works around (in 17.10) the fact that
      graphical-session-pre.target services are not always run as
      intended (LP: #1720250).
  * debian/patches/dont-start-ibus-if-gdm3.patch:
    - Prevents two instances of ibus-daemon, which fixes issue with
      suggestion window not showing up when using ibus-mozc
      (LP: #1720250).
  * Dropped the upstart user session job.
  * debian/menu: Dropped.

 -- Gunnar Hjalmarsson <email address hidden> Wed, 04 Oct 2017 17:17:00 +0200

Changed in im-config (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

In my /etc/X11/xinit/xinputrc I have these lines:

# im-config(8) generated on Thu, 09 Aug 2018 08:42:10 +0100
run_im none
# im-config signature: d77e0956ffec112e1184abeaf12847c1 -

And the script /etc/profile.d/input-method-config.sh is causing the following error message in a X11 level dialog box (i.e. the mouse cursor turns into an 'X'):

"Error found when loading /etc/profile:

E: Script for none not found at run_im.
E: Script for none not found at run_im.

As a result, the session will not be configured correctly.
You should fix the problem as soon as feasible."

So, what I did to get rid of the error message was to add a "return" to the top of the above-mentioned /etc/profile.d/input-method-config.sh script. But maybe there is a more proper solution to this problem?

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@Tigran: This bug was closed several years ago, and there is absolutely no point in adding comments to it now.

If you have found a new bug, please report it separately. If you need support, please visit some resource for that, e.g. https://askubuntu.com . My guess is that the latter applies to your case.

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

@Gunnar You are assuming that the bug was fixed completely by the code in /etc/profile.d/input-method-config.sh. Well, in complex entities, such as the operating systems (even in user-space level) there is no such thing as "complete, universal bugfix". There will always be some subtle cases, which the developer did not think of and these may or may not come up later, which may be 7 years later as in this case. I assume that my 20+ years of Linux kernel development experience allow me to make such a statement.

The real problem is that I have 7 other machines (identical clones) running exactly the same Ubuntu 18 system and on none of them this problem manifests itself. There are a few differences between this machine and the rest, namely:

1. I configured LVM2 on it.
2. I use bind-mounts in /etc/fstab heavily (for /usr/local and other parts).
3. I use QEMU on this machine extensively, so VFIO/PCI passthrough etc etc are configured.
4. Maybe a few other bits and pieces.

Oh well, don't worry, I won't bother you further with this. I will try to figure out the cause and will let you know if I find it.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Well, I don't claim that im-config is bug free forever after the fix of this bug. New issues show up.

My point is that trying to revive an old and closed bug report is simply not the right way to call the developers' attention to new issues.

My advice still stands: Use Ask Ubuntu to get help to sort things out. If you conclude that there is a bug, you are welcome to submit a new bug report about your problem.

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

Ok, the reason I left a comment here was very logical: disabling the code in /etc/profile.d/input-method-config.sh script made the problem "go away". And in the header of this script there is a reference to this particular bug number, so that was my first place to go to.

However, I completely agree with you, that the real cause of the problem may be elsewhere and it should be reported against the corresponding subsystem. I will do as you suggest as soon as I have more information (I am not working on this actively, as my "workaround" seems to be ok, but of course I am curious and so "in the back of my mind" I am still considering this issue :)

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@Tigran: It struck me that /etc/profile.d/input-method-config.sh is an ancient file. Yes, it was introduced in 2017 due to this bug as a fix or workaround, but it was dropped long ago. If you are on an Ubuntu version > 20.04, you can safely just remove it.

So how could that happen? My guess is that you at some point of time took a shortcut when upgrading your Ubuntu version. You seem to have switched from some version before 20.04 directly to some version after 20.04. Skipping an LTS like that is not a supported upgrade path, and may result in issues like this one.

So I don't think there is much to report. ;)

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Another theory is that you may have removed the im-config package without purging it. In latter im-config versions we prevent such a measure from leading to issues, but in the version uploaded due to this bug there was no such protection.

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

@Gunnar

1. I am still on Ubuntu 18.04.6. I know it sounds strange, but in the past 5-6 years I was so busy, that I was upgrading only the components I actually actively use in my research work, namely Wolfram Mathematica, python (with all scientific modules) etc. But yes, at some point I will need to switch. I never "upgrade", but always install from scratch and then spend several days tweaking the system to my liking. The reason I didn't upgrade to Ubuntu 20 is that I really disliked the idea of using snap. I am used to having a full control over every single instruction my CPUs are executing and snap somewhat distances the user of the system from what is happening inside, imo.

2. The im-config package could not be removed without removing gnome-control-center, which would be extremely inconvenient. So, no, it is still installed. I would gladly remove it, but because of this dependency I had to keep it.

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

This is the version of im-config I am using:

$ apt show im-config
Package: im-config
Version: 0.34-1ubuntu1.3
Priority: optional
Section: x11
Origin: Ubuntu
Maintainer: Ubuntu Developers <email address hidden>
Original-Maintainer: Osamu Aoki <email address hidden>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 360 kB
Provides: im-switch
Depends: gettext-base
Recommends: x11-common, zenity | kdialog | kde-baseapps-bin (<< 4:16.08.3-2~) | whiptail
Conflicts: im-switch
Task: ubuntu-desktop, kubuntu-desktop, kubuntu-full, xubuntu-desktop, lubuntu-gtk-desktop, lubuntu-desktop, ubuntustudio-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-budgie-desktop
Supported: 5y
Download-Size: 23.3 kB
APT-Manual-Installed: yes
APT-Sources: http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages

So, you are saying that with this version I don't need the file /etc/profile.d/input-method-config.sh and can simply remove it? In that case, yes, there is nothing to report, except the strange fact that this file was not removed when im-config was updated during the normal "sudo apt update" procedure at some point.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2023-03-14 09:09, Tigran Aivazian wrote:
> So, you are saying that with this version I don't need the file
> /etc/profile.d/input-method-config.sh and can simply remove it?

No. I said that you can do that if you are on an Ubuntu version > 20.04. Given the version you actually are on, instead I would suggest that you reinstall im-config:

sudo apt-get install --reinstall im-config

That's because the error message indicates that the installation of im-config is not complete. Maybe you tried to partly uninstall it.

"E: Script for none not found at run_im."

Well, "script for none" should be there:

$ ls -1 /usr/share/im-config/data | grep none
78_none.conf
78_none.rc

and a reinstall ought to restore those files.

Or you can keep your return at the top of the file. That won't hurt if you don't use any input method.

> The im-config package could not be removed without removing
> gnome-control-center

That's true, and the reason is that language-selector-gnome depends on im-config. I should probably relax that to a recommends.

> except the strange fact that this file was not removed when im-config
> was updated during the normal "sudo apt update" procedure at some point

Not strange at all, actually, since you are on bionic.

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

Your analysis is absolutely correct. On my system the whole directory /usr/share/im-config/data was missing. So I did "sudo apt install --reinstall im-config" as you suggested, and, behold, that directory was restored, including the two 78* files you mentioned. Then I removed my "return" at the top of /etc/profile.d/input-method-config.sh and logged out, and then logged in again -- no more error messages.

Thank you very much, Gunnar. You were very helpful and patient :)

Revision history for this message
Tigran Aivazian (aivazian-tigran) wrote :

In order to put this mystery of the "missing directory /usr/share/im-config/data" to complete rest I would like to say that the reason for it turned out to be my error. Normally I clone a system by "rsync --delete -ahvHAX", followed by grub-install with appropriate arguments. But this time I added "--exclude=data/" to rsync options, because I wanted to exclude a huge directory "/data" containing terabytes of books and music, not realising that this would also exclude a few dozens of other directories, namely all those containing "/data/" as part of their full pathname, including the one containing im-config data.

Needless to say, I have wiped out this system and did a fresh install of Ubuntu 22.04 and am very happy with it. After a few optimisations, removing some stuff, disabling Wayland and making a few other minor adjustments, the system is rock stable and almost as fast as Ubuntu 18 (which used to boot in just over one second even on this old slow hardware).

So, thank you, Gunnar, and thanks to all Ubuntu developers for patiently bearing with all my comments :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.