Nixpkgs: Support for the desktop protocol is missing in KIO after upgrading to plasma desktop 5.17.5

Created on 10 Feb 2020  Â·  27Comments  Â·  Source: NixOS/nixpkgs

Describe the bug
Support for several protocols are missing in KIO after upgrading to plasma desktop 5.17.5

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade with the latest nixos-unstable channel,
  2. Make sure the desktop is configured with the folder view
  3. After logging in, an error message is displayed at the center of the screen:

image

Expected behavior
A folder view of the desktop icons should be displayed correctly.

Additional context
I think one can reproduce the error with kioclient5:

kioclient5 exec desktop:/

This will give the same error message:

[kj@DCHORUS-LEGION-NIXOS:/]$ env LANG=en_US.UTF-8 kioclient5 exec desktop:/
kf5.kio.core: couldn't create slave: "klauncher said: Unknown protocol 'desktop'.\n"
kf5.kio.widgets: KRun(0x1d2b000) ERROR 173 "Unable to create io-slave. klauncher said: Unknown protocol 'desktop'.\n"

Metadata

[root@DCHORUS-LEGION-NIXOS:~]# nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.25 MiB download, 1.17 MiB unpacked):
  /nix/store/as5612va9alwps1hlggh201iw181md8r-gnumake-4.2.1
  /nix/store/n96k7sq103i2xf9piapszp6pkc0dl2i0-stdenv-linux
copying path '/nix/store/as5612va9alwps1hlggh201iw181md8r-gnumake-4.2.1' from 'https://cache.nixos.org'...
copying path '/nix/store/n96k7sq103i2xf9piapszp6pkc0dl2i0-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.17, NixOS, 20.03pre212208.8130f3c1c2b (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.2`
 - channels(root): `"nixos-20.03pre212208.8130f3c1c2b"`
 - channels(kj): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
bug qkde

Most helpful comment

Using socket-activated D-Bus fixes this issue:

.nix { services.xserver.startDbusSession = false; services.dbus.socketActivated = true; }

I suspect that if the D-Bus session is started too early, the environment is not set up correctly.

All 27 comments

cc @ttuegel

Thanks for reporting this! I don't see any error message on the desktop in a VM, but I will try the kioclient5 reproduction next.

I cannot reproduce this in a clean VM. @y-usuzumi, does this happen after upgrading an existing installation? If so, then I suspect this is a (known) issue with ksycoca not performing cache invalidation correctly.

Hi @ttuegel , yes, I noticed the regression right after I upgraded my system withnix-channel --update followed by nix build --no-link -f '<nixpkgs/nixos>' config.system.build.toplevel followed by nixos-rebuild switch (I have network issues and I found this workaround somewhere on GitHub).

Before the upgrade I was running plasma 5.16.5 where it worked well.

Might be stupid but how can I clear the cache of ksycoca? I tried things like kbuildsycoca5 --noincremental with no luck. I also tried with a new user but had the same issue.

Might be stupid but how can I clear the cache of ksycoca? I tried things like kbuildsycoca5 --noincremental with no luck. I also tried with a new user but had the same issue.

kbuildsycoca5 will rebuild the current cache, but you have to actually remove all the existing caches: rm $HOME/.cache/ksycoca5*. Basically, this is because every KDE program runs in its own environment, so there may be multiple caches.

However, the old caches wouldn't affect a new user, so if you are seeing the same with a new user, it must be something else.

Have the same issue. Just upgraded to 5.17.5, restarted PC and desktop shows the same error as originally reported.
image

Removing cache with rm $HOME/.cache/ksycoca5* didn't help.

I have the same issue in an vm after upgrading, but I will try to reproduce it in an new VM.

Beside 'desktop', some other protocols are not working either. By checking journalctl I found similar error messages in other programs:

...
2月 10 10:16:04 DCHORUS-LEGION-NIXOS org.freedesktop.FileManager1[1119]: kf5.kio.core: couldn't create slave: "klauncher 回应:Unknown protocol 'desktop'.\n"
...
2月 10 11:36:48 DCHORUS-LEGION-NIXOS org.kde.kdeconnect[1119]: kf5.kio.core: couldn't create slave: "klauncher 回应:Unknown protocol 'tags'.\n"
...
2月 10 12:03:04 DCHORUS-LEGION-NIXOS xsession[1112]: kf5.kio.core: couldn't create slave: "klauncher 回应:Unknown protocol 'tags'.\n"
...
2月 10 12:03:04 DCHORUS-LEGION-NIXOS xsession[1112]: kf5.kio.core: couldn't create slave: "klauncher 回应:Unknown protocol 'thumbnail'.\n"
...

Can anyone share a configuration I can use to reproduce this?

Below is my configuration:

configuration.nix:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, lib, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./users.nix
      ./fonts.nix
      ./networking.nix
      ./packages.nix
      ./services.nix
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = false;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  boot.loader.grub.efiSupport = true;
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "nodev";

  # Select internationalisation properties.
  i18n = {
    defaultLocale = "zh_CN.UTF-8";
    inputMethod = {
      enabled = "fcitx";
      fcitx.engines = with pkgs.fcitx-engines; [ anthy ];
    };
  };
  console = {
    keyMap = "us";
    font = "Lat2-Terminus16";
  };

  # Set your time zone.
  time.timeZone = "Asia/Shanghai";

  # Security
  # security.sudo.extraConfig = ''
  #   %usuzumi ALL=(ALL:ALL) NOPASSWD
  # '';

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    # see ./packages.nix
  ];
  environment.pathsToLink = [ "/share/locale" ];
  # nix.binaryCaches = lib.mkForce [ "https://sdf.org" ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  programs.gnupg.agent = { enable = true; enableSSHSupport = true; };

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio = {
    enable = true;
    extraModules = [ pkgs.pulseaudio-modules-bt ];
    package = pkgs.pulseaudioFull;
  };

  # Enable Bluetooth
  hardware.bluetooth = {
    enable = true;
    config = {
      General = {
        Enable = "Source,Sink,Media,Socket";
      };
    };
  };

  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.extraPackages = with pkgs; [ vaapiIntel ];

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "19.09"; # Did you read the comment?
}

fonts.nix

{ config, pkgs, ... }:

{
  imports = [
  ];

  config = {
    fonts = {
      enableDefaultFonts = true;
      fonts = with pkgs; [
        emacs-all-the-icons-fonts
        noto-fonts
        noto-fonts-cjk
        noto-fonts-emoji
    powerline-fonts
    # sarasa-gothic
      ];
      fontconfig = {
        penultimate.enable = false;
        defaultFonts = {
          serif = [ "Noto Serif CJK SC" "Noto Serif" ];
          sansSerif = [ "Noto Sans CJK SC" "Noto Sans" ];
          monospace = [ "Noto Sans Mono CJK SC" "Noto Sans Mono" ];
        };
      };
    };
  };
}

hardware-configuration.nix

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:

{
  imports =
    [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "sd_mod" ];
  boot.initrd.kernelModules = [ "dm-snapshot" ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/532835da-b2fb-485a-bfdc-e60a097591a0";
      fsType = "ext4";
    };

  fileSystems."/boot/efi" =
    { device = "/dev/disk/by-uuid/2C36-0290";
      fsType = "vfat";
    };

  fileSystems."/home" =
    { device = "/dev/disk/by-uuid/74d4b26c-d02b-4729-ac2b-42f7b77558e6";
      fsType = "ext4";
    };

  fileSystems."/lab" =
    { device = "/dev/disk/by-uuid/552ec1de-f94c-4756-b46f-11c97fcbcd60";
      fsType = "ext4";
    };

  swapDevices = [ ];

  nix.maxJobs = lib.mkDefault 8;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}

networking.nix

{ config, ... }:

{
    imports = [ ];
    config = {
      networking = {
        hostName = "DCHORUS-LEGION-NIXOS"; # Define your hostname.
    # wireless.enable = true;  # Enables wireless support via wpa_supplicant.
    networkmanager.enable = true;
        # The global useDHCP flag is deprecated, therefore explicitly set to false here.    
        # Per-interface useDHCP will be mandatory in the future, so this generated config    
        # replicates the default behaviour.    
        useDHCP = false;    
        interfaces.enp3s0.useDHCP = true;    
        interfaces.wlp4s0.useDHCP = true;    
        firewall.enable = false;
    firewall.autoLoadConntrackHelpers = true;
        # Configure network proxy if necessary    
        # proxy.default = "http://user:password@proxy:port/";    
        # proxy.default = "socks5://localhost:1080/";
        # proxy.noProxy = "127.0.0.1,localhost,internal.domain";
        # Open ports in the firewall.
        # firewall.allowedTCPPorts = [ ... ];
        # firewall.allowedUDPPorts = [ ... ];
        # Or disable the firewall altogether.    
        # firewall.enable = false;
      };
    };
}

packages.nix

{ config, pkgs, ... }:

{
  imports = [
  ];

  environment.systemPackages = with pkgs;
  [
    # KDE applications
    ark
    dolphin
    filelight
    gwenview
    kate
    kcalc
    kcachegrind
    kcontacts
    kgpg
    khelpcenter
    kig
    kompare
    kwalletmanager
    okteta
    okular
    plasma-integration
    spectacle

    audacity
    chromium
    dconf
    emacs
    git
    go-shadowsocks2
    inetutils
    linuxPackages.bbswitch
    netease-cloud-music
    kdeconnect
    konversation
    neovim
    nix-prefetch-git
    privoxy
    proxychains
    screenkey
    simplescreenrecorder
    tdesktop
    teamviewer
    tilix
    tree
    vivaldi
    vlc
    wqy_microhei
    wqy_zenhei

    (python3.withPackages(ps: with ps; [
      virtualenvwrapper
    ]))
  ];
  nixpkgs.config = {
    allowUnfree = true;
    packageOverrides = pkgs: {
      vivaldi = pkgs.vivaldi.override { proprietaryCodecs = true; };
    };
  };
}

services.nix

{ ... }:
{
  # Enable the OpenSSH daemon.
  services.openssh.enable = true;

  # Enable CUPS to print documents.
  services.printing.enable = true;
  services.teamviewer.enable = true;

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.layout = "us";
  # services.xserver.xkbOptions = "eurosign:e";

  # Enable touchpad support.
  services.xserver.libinput.enable = true;

  # Enable the KDE Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;
}

users.nix

{ config, ... }:

{
  imports = [];

  # Groups
  users.groups.usuzumi = {
    gid = 1003;
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.kj = {
    group = "usuzumi";
    isNormalUser = true;
    description = "Yukio Usuzumi";
    extraGroups = [ "wheel" "usuzumi" "video" "audio" "networkmanager" ]; # Enable ‘sudo’ for the user.
  };
}

Also getting the same problem, ktorrent and yakuake are also reporting the same issue where they cannot find the desktop component (i.e. yakuake cannot find konsole).

Also ktorrent is unable to find the plasma theme

@ttuegel Clearing the ksycoca5 cache had zero effect, here is my configuration https://gist.github.com/mdedetrich/e28c49be1356d0894b86c8b0987b397b

Also the firefox plasma integration seems to be failing, it has the error "Failed to connect to the native host" even though the plasma-browser-integration package was installed.

Also the firefox plasma integration seems to be failing, it has the error "Failed to connect to the native host" even though the plasma-browser-integration package was installed.

Firefox plasma integration works fine for me despite I have the same problem with 'desktop' protocol.

I can reproduce this issue on first-time install of plasma5. Firefox plasma integration works fine while the desktop protocol error is still there.

EDIT : I have issue with krunner also, it seems its does not want to launch correctly at start (keybinding is not opening it). If I launch krunner in the terminal, it works but hang on first keystrokes to shows the following output :

kf5.kio.core: couldn't create slave: "klauncher said: Unknown protocol 'tags'.\n"
kf5.kio.core: "Unable to create io-slave. klauncher said: Unknown protocol 'tags'.\n"

I have the feeling that this is not only the desktop protocol that is impacted

I am (finally) able to reproduce this issue with the following configuration in a QEMU VM:

```.nix
{ ... }:

{
imports = [ ./nixos/tests/common/user-account.nix ];
services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true;
services.xserver.displayManager.defaultSession = "plasma5";
services.xserver.desktopManager.plasma5.enable = true;
services.xserver.displayManager.sddm.autoLogin = {
enable = true;
user = "alice";
};
hardware.pulseaudio.enable = true;
virtualisation.memorySize = 1024;
}
```

I have checked that /run/current-system/sw/share/kservices5/desktop.protocol exists; missing this file is the most obvious way this could go wrong.

Using socket-activated D-Bus fixes this issue:

.nix { services.xserver.startDbusSession = false; services.dbus.socketActivated = true; }

I suspect that if the D-Bus session is started too early, the environment is not set up correctly.

Maybe related: Upstream changes to startplasma cause kdeinit5 to run in an empty environment.

Switching the handling of D-Bus from X11-activated to socket-activated fixed the issue for me as well - didn't touch the ksycoca cache so far.

Thank you @ttuegel , it works! Saved my life!

I can also confirm that it works, @ttuegel is the change from going to X11 to socket activated d-bus likely to be merged into nixos-stable or is this an upstream issue that needs to be resolved and hence the current fix is just a workaround?

This fixes plasma for me, (including latte-dock not auto-starting). For some reason, plasma-browser-integration still is not working for me despite the extension being installed.

I can confirm it fixes the issue also for me.

I can also confirm that it works, @ttuegel is the change from going to X11 to socket activated d-bus likely to be merged into nixos-stable or is this an upstream issue that needs to be resolved and hence the current fix is just a workaround?

Such a change in nixos 20.03 would be out of the question IMHO.
It's a regression that it doesn't work properly in the first place.

is the change from going to X11 to socket activated d-bus likely to be merged into nixos-stable or is this an upstream issue that needs to be resolved and hence the current fix is just a workaround?

It's neither: it is a workaround and it's not an upstream issue.

The issue is that _something_ in the "improved" startplasma unsets the environment for some processes during startup. Then those processes can't find D-Bus. I think with socket activation, the affected processes will start their own message bus. If you look at the log (journalctl -t xsession), the Plasma session isn't properly started, but is just limping along.

I agree with @worldofpeace that this shouldn't be merged into NixOS 20.03, or into any other branch. If a proper solution is not forthcoming, then the Plasma 5.17 update should be reverted.

Okay thanks, I have commented this as a workaround in my configuration.nix. Hopefully we can solve the underlying issue.

I have narrowed this down somewhat. Some background:

  • start_kdeinit is a setuid binary that starts the Plasma session server; because it is setuid, its environment is reset at startup.
  • start_kdeinit_wrapper reads the environment, runs start_kdeinit, and passes the environment through a pipe.
  • start_kdeinit reads the environment from the pipe and sets the environment before calling kdeinit5.

I have verified that start_kdeinit truncates the environment, and I think that causes the problems we are seeing. I don't know why yet, but I have a suspect: start_kdeinit has some sanity checks for the environment that it reads (for security) and one of those checks is on the length of each individual environment entry. I suspect that the new plasma-workspace dependencies in Plasma 5.17 cause the limit to be exceeded.

I don't know why yet, but I have a suspect: start_kdeinit has some sanity checks for the environment that it reads (for security) and one of those checks is on the length of each individual environment entry. I suspect that the new plasma-workspace dependencies in Plasma 5.17 cause the limit to be exceeded.

I have confirmed that this is, indeed, the case. I believe I can have a patch ready in a day.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spacekitteh picture spacekitteh  Â·  3Comments

yawnt picture yawnt  Â·  3Comments

langston-barrett picture langston-barrett  Â·  3Comments

sid-kap picture sid-kap  Â·  3Comments

chris-martin picture chris-martin  Â·  3Comments