Protonvpn: No Module named Dbus

On nixOS-unstable.

I’m trying to install proton vpn. However whenever I run it throws the error: “No module named dbus”
I’ve installed dbus, but this hasn’t fixed the issue.

  environment.systemPackages = with pkgs; [
    vim
    wget
    gnome.gnome-tweaks
    gnome.gnome-keyring
    libsecret
    protonvpn-gui
    protonvpn-cli
    dbus
  ];

Upon running the protonvpn-cli status it shows this error:

Traceback (most recent call last):
  File "/nix/store/9yplkli2mlg8ncnxs9bkkra9jh2w34f5-protonvpn-cli-3.11.1/bin/.protonvpn-cli-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/9yplkli2mlg8ncnxs9bkkra9jh2w34f5-protonvpn-cli-3.11.1/lib/python3.9/site-packages/protonvpn_cli/main.py", line 21, in main
    ProtonVPNCLI()
  File "/nix/store/9yplkli2mlg8ncnxs9bkkra9jh2w34f5-protonvpn-cli-3.11.1/lib/python3.9/site-packages/protonvpn_cli/cli.py", line 65, in __init__
    res = getattr(self, args.command)()
  File "/nix/store/9yplkli2mlg8ncnxs9bkkra9jh2w34f5-protonvpn-cli-3.11.1/lib/python3.9/site-packages/protonvpn_cli/cli.py", line 174, in status
    return self.cli_wrapper.status()
  File "/nix/store/9yplkli2mlg8ncnxs9bkkra9jh2w34f5-protonvpn-cli-3.11.1/lib/python3.9/site-packages/protonvpn_cli/cli_wrapper.py", line 857, in status
    if not self.protonvpn.get_active_protonvpn_connection():
  File "/nix/store/fj2ihsvcv6naa1w25dnsrxpha91dvi8p-python3.9-protonvpn-nm-lib-3.9.0/lib/python3.9/site-packages/protonvpn_nm_lib/api.py", line 407, in get_active_protonvpn_connection
    return self._env.connection_backend\
  File "/nix/store/fj2ihsvcv6naa1w25dnsrxpha91dvi8p-python3.9-protonvpn-nm-lib-3.9.0/lib/python3.9/site-packages/protonvpn_nm_lib/core/environment.py", line 43, in connection_backend
    from .connection_backend import ConnectionBackend
  File "/nix/store/fj2ihsvcv6naa1w25dnsrxpha91dvi8p-python3.9-protonvpn-nm-lib-3.9.0/lib/python3.9/site-packages/protonvpn_nm_lib/core/connection_backend/__init__.py", line 1, in <module>
    from .nm_client import nm_client # noqa
  File "/nix/store/fj2ihsvcv6naa1w25dnsrxpha91dvi8p-python3.9-protonvpn-nm-lib-3.9.0/lib/python3.9/site-packages/protonvpn_nm_lib/core/connection_backend/nm_client/nm_client.py", line 3, in <module>
    from dbus.mainloop.glib import DBusGMainLoop
ModuleNotFoundError: No module named 'dbus'

Yeah, so this is a python error. What’s missing isn’t dbus, but the python bindings for dbus. Worse yet, those bindings are provided by gobject-introspection, which in turn provides bindings into gobjects, which are more or less C bindings into various bits of GNOME related software - such as dbus.

The package that’s failing to load that module actually includes the correct library for it, so it’s not a case of a missing package: https://github.com/NixOS/nixpkgs/blob/e0169d7a9d324afebf5679551407756c77af8930/pkgs/development/python-modules/protonvpn-nm-lib/default.nix#L33

Well, unless your last update is about two weeks ago (or the unstable channel has not caught up yet): python3Packages.protonvpn-nm-cli: add dependencies · NixOS/nixpkgs@2361dc9 · GitHub

Rather, gobject-introspection will magically decide what modules are available when your system is running. In this case it has decided that dbus isn’t available, presumably because it’s not running sufficiently, or some socket/env var is missing (rather than simply not installed; it’d be extremely weird for it not to be installed, most packages depend on dbus in some way).

So, on to figuring out what’s wrong. What desktop environment are you using? Are you trying to run this CLI application in a systemd unit that doesn’t have access to your user session or something like that? Are you actually using networkmanager, because the official protonvpn thing doesn’t support non-networkmanager setups?

Also, while I’m at it, proton provide wireguard/openvpn config files. Those are significantly nicer to use, you just shove their settings into networking.wireguard.interfaces or services.openvpn.servers respectively, and call it a day (while getting all the nice service integration that systemd gives you, which GUI managers can never hope to match).

Thanks for helping out!
I’m using gnome as my desktop environment, and I’m trying to just launch the app like you would any other. I have both the gui and cli app installed which I did with

environment.systemPackages = with pkgs; [
];

I guess I might have to run it as a systemd service as you were saying.

On a somewhat unrelated note, if my system is managed by flakes, do I need to run nix-channel --update to fetch the latest updates or do I just need to run my nixos-rebuild command with the --upgrade flag (since nixpkgs is defined as a source for the flake). Also, is there a way to see what updates are available? Or even what changed after running an update?

FYI, I’m expecting python3Packages.protonvpn-nm-lib: 3.10.0 -> 3.11.0 by WolfangAukang · Pull Request #176817 · NixOS/nixpkgs · GitHub to be approved and backported, so 22.05 can be updated.

If using flakes, you can run nix flake update to make sure it is updated, then run the nixos-rebuild command as usual.

1 Like

That would be GDbus from GLib – dbus-python are ancient bindings not based on gobject-introspection.

gobject-introspection (in python used by pygobject3) just scans for libraries in paths listed in GI_TYPELIB_PATH environment variable, no sockets or anything like that are involved. But in this case, it is simply a Python module missing.

Neither of the library dependencies are to be picked up from system – they should just be included by the builder – typelibs through wrapGAppsHook, Python modules by Python wrapper.


I would say this is the most likely cause. https://nixpk.gs/pr-tracker.html?pr=172939 has been merged on May 27 and the nixos-unstable channel advanced to a commit containing the fix May 30. So it might be possible OP has not updated since.

1 Like

As @WolfangAukang says, nix flake update will update your lockfile, which pins the exact commit of nixpkgs your system is built from. That makes it very easy to figure out if you’re before or after that commit too, flakes are great :slight_smile:

Yes, well, for one, you can look at the literal commits between your current sha and what’s on master. Just cat flake.lock is good enough for that, but nix flake info is quite a bit nicer to digest.

You can also use nix store diff-closures for a nice list of changed packages (you can use nixos-rebuild build rather than switch to get the closure without, well, switching to it, and then compare it to the running system’s closure).

@jtojnar is totally right, by the way, of course that isn’t the gobject-introspection interface, the parent module isn’t called the right thing for that, and that’s the bit that’s missing :slight_smile: The reference to glib threw me off.

Regarding using the ProtonVPN configs on NixOS, I can confirm that it works.

My NixOS module for ProtonVPN (the code is here) originally used OpenVPN, but I just rewrote it to use Wireguard.

The OpenVPN version pretty much just worked. To use Wireguard you have to first make sure that there’s a route to the VPN endpoint via a gateway. Otherwise, Wireguard won’t be able to establish a handshake to set up the VPN “tunnel.” I bring this up because I was quite stuck on this point, and it’s not mentioned on the NixOS Wireguard wiki. I’ve added a way to set up such a route in my ProtonVPN module. Although it works, I’m considering a more dynamic way to handle the situation.

Nevertheless, I hope the implementation can help in case you’d like to use a NixOS module to set up the VPN.

2 Likes