Winit: Eventloop initialization failure - Failed to open input method

Created on 23 Aug 2018  路  10Comments  路  Source: rust-windowing/winit

Got this on Debian Buster.

thread 'main' panicked at 'Failed to open input method: PotentialInputMethods {
    xmodifiers: None,
    fallbacks: [
        PotentialInputMethod {
            name: "@im=local",
            successful: Some(
                false
            )
        },
        PotentialInputMethod {
            name: "@im=",
            successful: Some(
                false
            )
        }
    ],
    _xim_servers: Err(
        GetPropertyError(
            TypeMismatch(
                0
            )
        )
    )
}', /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.17.2/src/platform/linux/x11/mod.rs:85:17

Managed to fix it by commenting line 81 (setlocale) in the file mentioned in the log.

Edit: It seems that setting the LC_CTYPE locale to an empty c string is invalid, using b"C\0" worked.
Using LC_ALL doesn't work either with an empty string, at least on my system.

Update: It seems that the problem has something to do with my etc/default/locale being set to en_IL.UTF-8. I changed it to en_US.UTF-8 and it worked.

good first issue X11 high needs investigation bug

All 10 comments

Same here. changing from LANG=en_IL.UTF-8 to LANG=en_US.UTF-8 fixes this error:

thread 'main' panicked at 'Failed to open input method: PotentialInputMethods {
    xmodifiers: None,
    fallbacks: [
        PotentialInputMethod {
            name: "@im=local",
            successful: Some(
                false
            )
        },
        PotentialInputMethod {
            name: "@im=",
            successful: Some(
                false
            )
        }
    ],
    _xim_servers: Err(
        GetPropertyError(
            TypeMismatch(
                0
            )
        )
    )
}', /build/alacritty-eHHw83/alacritty-0.3.2~1556145865~18.04~4ba1771/vendor/winit/src/platform/linux/x11/mod.rs:92:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Same thing here; encountered within alacritty as above. My default LANG is en_US.utf8@grissess (mostly en_US plus ISO8601 datetime), which resulted in exactly the error above. Using LANG=en_US.utf8 fixes it.

The alacritty issue ref'd above has other people changing locales and getting it working, too. Is there any way to work around this without changing LANG?

I'd love to investigate this, but I cannot reproduce it.

Tried adding en_IL.UTF-8 to my /etc/local.gen, rebuilding my locals with local-gen, then changing my default to en_IL.UTF-8 in /etc/local.conf, then unset LANG, then source /etc/profile.d/locale.sh, to no avail.

Run echo $LANG before you run to make sure that the lang is really the IL one.

Btw you can just export it and it should also do the trick.

Even if you're having trouble reproducing it there, I'll gladly proffer my system for test builds and theories as needed.

(To follow up what elichai said, I just did the cross-LANG test with LANG=en_US.utf8 alacritty verbatim.)

https://i.imgur.com/i61KD4I.png :/

It would be useful to know the values of inner and input_method on successful runs, and on failed runs.
https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/mod.rs#L60

The values of local_modifiers and im would also be of interest: https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L20

So would printing out input_method above these two places: https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L264 https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L274

EDIT:
I'm available 6pm-10pm Tues to Friday UTC-6 on #Glutin:matrix.org, if any of you want to work this issue out together.

Using version 0.19.5
Failed run (using en_IL.utf8):

src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im=local"
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x0
src/platform/linux/x11/ime/input_method.rs:34 im: 0x0
src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im="
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x0
src/platform/linux/x11/ime/input_method.rs:34 im: 0x0
src/platform/linux/x11/ime/mod.rs:60 input_method: Failure
src/platform/linux/x11/ime/mod.rs:60 inner: ImeInner { xconn: 0x55834ba884d0, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(false) }, PotentialInputMethod { name: "@im=", successful: Some(false) }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x55834baa0290, callback: Some(0x55834acbee80) }, is_destroyed: false, is_fallback: false }

Successful run (using en_US.utf8):

src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im=local"
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x557ccb507280
src/platform/linux/x11/ime/input_method.rs:34 im: 0x557ccb5072a0
src/platform/linux/x11/ime/mod.rs:60 input_method: Fallback(InputMethod { im: 0x557ccb5072a0, name: "@im=local" })
src/platform/linux/x11/ime/mod.rs:60 inner: ImeInner { xconn: 0x557ccb4c44d0, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(true) }, PotentialInputMethod { name: "@im=", successful: None }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x557ccb4dc490, callback: Some(0x557cc9a0be80) }, is_destroyed: false, is_fallback: false }

Can you test against winit master?

Same with master (on February 9, 2020)
Failed run (using en_IL.utf8)

src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im=local"
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im="
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x0
src/platform_impl/linux/x11/ime/mod.rs:65 input_method: Failure
src/platform_impl/linux/x11/ime/mod.rs:65 inner: ImeInner { xconn: 0x56288127e090, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(false) }, PotentialInputMethod { name: "@im=", successful: Some(false) }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x5628812963b0, callback: Some(0x56287f945540) }, is_destroyed: false, is_fallback: false }

Successful run (using en_US.utf8)

src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im=local"
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x55cfb734f5f0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x55cfb734f610
src/platform_impl/linux/x11/ime/mod.rs:65 input_method: Fallback(InputMethod { im: 0x55cfb734f610, name: "@im=local" })
src/platform_impl/linux/x11/ime/mod.rs:65 inner: ImeInner { xconn: 0x55cfb730c090, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(true) }, PotentialInputMethod { name: "@im=", successful: None }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x55cfb73242f0, callback: Some(0x55cfb6e6c540) }, is_destroyed: false, is_fallback: false }

As far as I understand, it seems the initialization is failing (at least on my system) because my current locale (C.utf8) is accepted by setLocale:
https://github.com/rust-windowing/winit/blob/96df85896134895b4538a6a24a9f96d8b3343343/src/platform_impl/linux/x11/mod.rs#L108)
but is refused by X11 (XSetLocaleModifiers returns NULL):
https://github.com/rust-windowing/winit/blob/96df85896134895b4538a6a24a9f96d8b3343343/src/platform_impl/linux/x11/ime/input_method.rs#L25

If I set my locale with LANG=C.UTF-8, the problem disappears for a reason unknown to me.

I have made a PR (#1445) which does not fix the root problem (setLocale / X11 discrepancy) but which prevents winit initialization from failing with an "invalid" locale (more details in the PR).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k0nserv picture k0nserv  路  3Comments

coderhwz picture coderhwz  路  3Comments

dhardy picture dhardy  路  3Comments

felixrabe picture felixrabe  路  4Comments

mistodon picture mistodon  路  4Comments