Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tray.target not found #2064

Open
jlesquembre opened this issue Jun 2, 2021 · 17 comments · Fixed by #2713
Open

Unit tray.target not found #2064

jlesquembre opened this issue Jun 2, 2021 · 17 comments · Fixed by #2713
Assignees
Labels
pinned Prevent marking as stale

Comments

@jlesquembre
Copy link
Contributor

Issue description

On current master, I get the error Unit tray.target not found when I try to start some systemd units (like udiskie or blueman).
I'm using waybar, I think this error is related to #2027

Meta

Maintainer CC

@berbiche @NickHu

Technical details

@berbiche
Copy link
Member

berbiche commented Jun 2, 2021

Unfortunately, the tray.target is only created if xsession management is enabled in HM.

The creation of said systemd target should be moved elsewhere.

In the meantime, you can create the systemd target manually from the xsession.nix? file and add Install.WantedBy = [ "graphical-session-pre.target" ] to the target definition. (untested)

@sumnerevans
Copy link
Member

Unfortunately, the tray.target is only created if xsession management is enabled in HM.

Ah, this explains why I encountered that error on my wayland system. We should definitely fix that.

@sumnerevans sumnerevans pinned this issue Jun 19, 2021
@zeorin
Copy link

zeorin commented Jul 20, 2021

I have this problem on X11. flameshot includes a service that wants the tray.target.

@vyorkin
Copy link

vyorkin commented Jul 20, 2021

Can confirm the problem on X11 with flameshot, subscribed to this issue exactly for this reason

@berbiche berbiche self-assigned this Jul 20, 2021
@zeorin
Copy link

zeorin commented Jul 27, 2021

@vyorkin I should probably mention that I worked around this for the time being with the following in my home.nix:

	systemd.user.targets.tray = {
		Unit = {
			Description = "Home Manager System Tray";
			Requires = [ "graphical-session-pre.target" ];
		};
	};

which I lifted from home-manager's source somewhere.

@stale

This comment was marked as outdated.

@stale stale bot added the status: stale label Oct 25, 2021
@stale stale bot closed this as completed Nov 1, 2021
@sumnerevans sumnerevans added the pinned Prevent marking as stale label Nov 1, 2021
@sumnerevans sumnerevans reopened this Nov 1, 2021
@stale stale bot removed the status: stale label Nov 1, 2021
@DavHau
Copy link
Member

DavHau commented Jan 12, 2022

Still an issue. The home-manager udiskie service doesn't work on my nixos 21.05.
I'm using i3wm on x11 and there is no tray target

@zeorin
Copy link

zeorin commented Feb 24, 2022

I've since enabled xsession management, but I'm assuming that with this change, someone that's not running sway nor xsession management will still have this issue?

@aruZeta
Copy link

aruZeta commented Mar 19, 2022

What I noticed is that I can't start any service in $XDG_CONFIG_HOME/systemd/user, so services like the ones created from services.emacs or services.gpg-agent can't be started. Searching a bit I didn't find any issue directly talking about it. systemd-analyze --user unit-paths shows $XDG_CONFIG_HOME/systemd/user, which makes the fact that it can't find services there even more strange.

pjones added a commit to pjones/tilde that referenced this issue Jul 15, 2022
@teto teto unpinned this issue Sep 3, 2022
loganlinn added a commit to loganlinn/dotfiles that referenced this issue Jan 5, 2023
Fixes "Failed to start syncthingtray.service: Unit tray.target not found."

nix-community/home-manager#2064
@AshleyYakeley
Copy link

I believe this should be reopened? I'm using marco (rather than sway) without xsession management, and I'm coming across this issue.

@ncfavier ncfavier reopened this Feb 28, 2023
@ncfavier
Copy link
Member

I can see two solutions:

  • change Requires directives on tray.target to Wants instead; @NickHu is there a specific reason you used Requires?
  • define the tray target in the systemd module, regardless of whether xsession or sway is enabled

@Mikilio
Copy link
Contributor

Mikilio commented Aug 28, 2023

Just some thought to add:

I've been trying to wrap my head around what this target is for and how it's supposed to be used for. By the description it seems like the target being active indicates that there is a system tray active. This caused a lot of confusion for me because all 3rd party bars providing a system tray out there actually start after graphical-session.target creating dependency cycles on most desktops. Then again apps that use a system tray will request the tray from the dbus, which most likely will start the bar for the tray which makes their systemd service only a backup in case dbus hasn't started them yet. As far as I understand the only requirement for tray.target to be met seems to be dbus.service and possibly (xdg-desktop-portal.service ?). Am I right so far?

@Nebucatnetzer
Copy link

Nebucatnetzer commented Dec 6, 2023

Wasn't able to start network manager applet because of the missing tray.target with qtile WM.

Nebucatnetzer added a commit to Nebucatnetzer/nixos that referenced this issue Dec 6, 2023
@arduano
Copy link

arduano commented Dec 7, 2023

Interestingly, using @zeorin's fix for flameshot, it doesn't appear in the tray even though it runs fine in the background. It appears in the tray when I run systemctl --user restart flameshot.

JesusMtnez added a commit to JesusMtnez/dotfiles that referenced this issue Dec 13, 2023
Nebucatnetzer added a commit to Nebucatnetzer/nixos that referenced this issue Dec 13, 2023
@Kreyren
Copy link

Kreyren commented Jul 8, 2024

Doesn't seem to work on NixOS 24.05 with GNOME using wayland either.

Cross-Referencing: NiXium-org/NiXium#115

@ciferkey
Copy link

Confirming I'm seeing this on unstable now with udiskie. System info:

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.0, NixOS, 24.11 (Vicuna), 24.11.20240719.1d9c2c9`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - nixpkgs: `/etc/nix/path/nixpkgs`

Any other details I can provide that would help debug this?

@worthalex
Copy link

worthalex commented Jul 30, 2024

i too am encountering this issue on unstable after an update

activating the configuration...
setting up /etc...
reloading user units for alex...
restarting sysinit-reactivation.target
the following new units were started: systemd-hostnamed.socket
warning: the following units failed: home-manager-alex.service

× home-manager-alex.service - Home Manager environment for alex
     Loaded: loaded (/etc/systemd/system/home-manager-alex.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-07-31 10:19:55 NZST; 70ms ago
   Duration: 4min 4.193s
 Invocation: 877dc7faf55849d3981a0504b9655bdb
    Process: 136236 ExecStart=/nix/store/877sla6xf6kngfzaabmqm4r5al918h9f-hm-setup-env /nix/store/5rkb4h56ggpqddf0v3v8r6zm7s5jqgql-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 136236 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
   Mem peak: 35.9M
        CPU: 853ms

Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136236]: Activating reloadSystemd
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]: Starting units: udiskie.service
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]: Error: Error switching
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]: Caused by:
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]:     0: Failed to perform post-reload tasks
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]:     1: Failed to start unit udiskie.service
Jul 31 10:19:55 sage-ice-cream hm-activate-alex[136642]:     2: org.freedesktop.systemd1.NoSuchUnit: Unit tray.target not found.
Jul 31 10:19:55 sage-ice-cream systemd[1]: home-manager-alex.service: Main process exited, code=exited, status=1/FAILURE
Jul 31 10:19:55 sage-ice-cream systemd[1]: home-manager-alex.service: Failed with result 'exit-code'.
Jul 31 10:19:55 sage-ice-cream systemd[1]: Failed to start Home Manager environment for alex.
warning: error(s) occurred while switching to the new configuration

@vyorkin I should probably mention that I worked around this for the time being with the following in my home.nix:

	systemd.user.targets.tray = {
		Unit = {
			Description = "Home Manager System Tray";
			Requires = [ "graphical-session-pre.target" ];
		};
	};

which I lifted from home-manager's source somewhere.

This fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Prevent marking as stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.