Could not locate library m17n.so for addon m17n

[demo@nixos:~]$ fcitx5
I2022-08-14 19:05:59.631392 instance.cpp:1407] Override Enabled Addons: {}
I2022-08-14 19:05:59.631476 instance.cpp:1408] Override Disabled Addons: {}
I2022-08-14 19:05:59.637514 addonmanager.cpp:191] Loaded addon xcb
I2022-08-14 19:05:59.637787 addonmanager.cpp:191] Loaded addon imselector
I2022-08-14 19:05:59.639905 addonmanager.cpp:191] Loaded addon quickphrase
E2022-08-14 19:05:59.639926 addonloader.cpp:32] Could not locate library m17n.so for addon m17n.
I2022-08-14 19:05:59.639941 addonmanager.cpp:188] Could not load addon m17n
I2022-08-14 19:05:59.644601 addonmanager.cpp:191] Loaded addon keyboard
E2022-08-14 19:05:59.644651 addonloader.cpp:32] Could not locate library libluaaddonloader.so for addon luaaddonloader.
I2022-08-14 19:05:59.644682 addonmanager.cpp:188] Could not load addon luaaddonloader
E2022-08-14 19:05:59.645585 addonloader.cpp:61] Failed to create addon: dbus Unable to request dbus name. Is there another fcitx already running?
I2022-08-14 19:05:59.645620 addonmanager.cpp:188] Could not load addon dbus
I2022-08-14 19:05:59.645735 addonmanager.cpp:297] Unloading addon keyboard
I2022-08-14 19:05:59.645941 addonmanager.cpp:297] Unloading addon quickphrase
I2022-08-14 19:05:59.646085 addonmanager.cpp:297] Unloading addon imselector
I2022-08-14 19:05:59.646118 addonmanager.cpp:297] Unloading addon xcb
I2022-08-14 19:05:59.646155 inputcontextmanager.cpp:318] All display connections are gone, exit now.


[demo@nixos:~]$ nano /etc/nixos/configuration.nix 

[demo@nixos:~]$ nix-env -iA nixos.fcitx5-m17n
warning: name collision in input Nix expressions, skipping '/home/demo/.nix-defexpr/channels_root/nixos'
suggestion: remove 'nixos' from either the root channels or the user channels
replacing old 'fcitx5-m17n-5.0.8'
installing 'fcitx5-m17n-5.0.8'

i18n.defaultLocale = "zh_CN.UTF-8";
i18n.inputMethod.enabled = "fcitx5"; 
i18n.inputMethod.fcitx5.enableRimeData = true; 
i18n.inputMethod.fcitx5.addons = with pkgs; [
#     fcitx5-rime
     fcitx5-chinese-addons
]; 
}

pinyin input method is unavailable.
Could anyone tell me how to fix it?

Setting:

Will install a version of fcitx with those addons pre-installed.

Running:

Will put that plugin in a random path and not use it.

I’d start by removing that package again:

nix-env --uninstall nixos.fcitx5-m17n

Next up, let’s look at that missing library. Looking at your addon, it does not look like it depends on m17n at all: https://github.com/NixOS/nixpkgs/blob/5c211b47aeadcc178c5320afd4e74c7eed5c389f/pkgs/tools/inputmethods/fcitx5/fcitx5-chinese-addons.nix#L59

It’s also not included in the default addons: https://github.com/NixOS/nixpkgs/blob/5c211b47aeadcc178c5320afd4e74c7eed5c389f/pkgs/tools/inputmethods/fcitx5/with-addons.nix#L6

So where does that come from? Is the config you’re showing really your whole config? Did you forget to nixos-rebuild switch?

It’d also be nice to see what you have installed with nix-env, to see if that might be causing conflicts. Please share the output of nix-env -q.

I actually don’t recommend using nix-env, unless you really know what you’re doing. It can cause issues like this one, though in this case I think it’s unlikely to be the culprit. We’ll see!

I also installed fcitx5-qt fcitx5-lua fcitx5-gtk fcitx5-configtool fcitx5 fcitx5-configtool fcitx5-chinese-addons with nix-env command.
Do I need to remove them together?
Actually, I ran nixos-rebuild switch one time. I don’t know what the issue, So I installed all relative packages.
This is my first time to experience Nixos & nixpkg.
I’m not familiar witch command can replace nix-env, Could you help me?

I removed all packages installed before with nix-env.
and ran:

sudo nixos-rebuild switch

It works now.
Thanks for your help!
NixOS is very interesting.

1 Like

I think this is a very common problem, indeed, and is exactly why I think hints about nix-env should be replaced with a good explanation of configuration.nix for new users!

Let me explain how you would install a package on NixOS:


Activate the option

Some packages need to be enabled through an option. This is because a lot of the time they weren’t written for NixOS, and you’ll soon learn that NixOS is very different - so packages often need some additional configuration.

Luckily others often have already done that for you, so this is where you should start:

  1. Check NixOS Search to see if someone already made a module for your package.
  2. If you find some kind of .enable option, add it to your configuration.nix and set it to true. The module probably does a lot of work to make it work on NixOS!
  3. Run sudo nixos-rebuild switch to rebuild your system. The package should now be available.
  • Some packages may require a reboot to work, most do not.

Here’s an example from my configuration, for installing docker, for example: https://github.com/TLATER/nixos-hosts/blob/a6e5e04109f3b54c3c949902fa2840e67738e29a/configurations/ct-lt-02052/default.nix#L61

Don’t get confused about the file not being called configuration.nix; you would write it exactly the same. I just split my config files for nicer management.

Also, for example, programs.steam.enable is very hard to make work without the option, but it also has a normal package which is why you should always check for an option first.

Install the package directly

Most of the time, you won’t find an option. Most packages work fine without additional configuration. For those, this is the approach:

  1. Use NixOS Search to find your package
  2. Add the package to the environment.systemPackages list in your configuration.nix
  3. Run sudo nixos-rebuild switch. The package should now be available.

This is what the list in my configuration looks like, for example: https://github.com/TLATER/nixos-hosts/blob/a6e5e04109f3b54c3c949902fa2840e67738e29a/configurations/default.nix#L59

It’s quite short, probably because I mainly use home-manager for software I actually use :slight_smile:


nix-env and nix profile are alternatives. They install a package only for your user that will not be updated with the rest of your system, and completely ignore most of your configuration. This can cause a lot of problems.

Once you start understanding user profiles, how channels work, how modules work, etc., you can make your own decision on whether to use these. But I’d recommend beginners stick to nixos-rebuild exclusively. It will keep you from running into problems like the one that started this thread (and make it a lot easier for people here to reproduce your issues, since they could just copy your config and have the exact same system - can’t do that when you use nix-env).

If you want more detail, there’s some other notes about it here, but it doesn’t explain all the concepts involved, so it may just be confusing to a newcomer: https://stop-using-nix-env.privatevoid.net/

Thank you for providing such a good tutorial.

General use method:

with NixOS configuration or Home Manager

  1. Search and use a exists module to install your packages
  2. Search and install a single package

Gain temporary access

  • nix shell

Alternative for nix-env

for the case of imperative package management

  • nix profile

weakness for nix-env
https://stop-using-nix-env.privatevoid.net/

1 Like

Is there any guide manual for using home-manager?

See the github repository: GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@rycee]

It is a relatively advanced use of nix. If you can stick to it through some frustration and learning from others’ examples, it’s an excellent tool, though. As in general with anything NixOS. It took me a good year to get properly comfortable with everything in the ecosystem, a lot of it spent staring at repositories on GitHub.

Don’t try to learn from my examples, I’ve mixed in far too many unusual things by now :wink:

It seems that nix profile is lack of many packages than nix-env

It has the exact same packages; the syntax is just different. You would use nix profile install nixpkgs#<packagename>.

nix profile is one of the many experimental nix 3.0 commands that revolve around flakes. If you insist on using it, I’d suggest learning about flakes first: Nix Flakes, Part 1: An introduction and tutorial.

But again, these are still experimental, and not yet documented cleanly outside of blog posts and the wiki - they will be hard to understand without understanding the nix ecosystem a bit better.

Also note that nix profile does not solve the problems of shadowing already installed packages, or failing to update with the rest of your system. You will still run into a lot of the problems caused by nix-env. nix-shell is better for almost all use cases of those two commands.