<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>7800</bug_id>
          
          <creation_ts>2015-05-21 11:37:08 +0000</creation_ts>
          <short_desc>systemd.bbclass doesn&apos;t check for services in systemd/user/ directory</short_desc>
          <delta_ts>2026-08-06 08:52:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>configuration</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>6.1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Pau Espin Pedrol">pespin.shar</reporter>
          <assigned_to name="Himani Barde">HimaniRamesh.Barde</assigned_to>
          <cc>HimaniRamesh.Barde</cc>
    
    <cc>liezhi.yang</cc>
    
    <cc>Qi.Chen</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
    
    <cc>sgw</cc>
    
    <cc>stephano</cc>
    
    <cc>tanuk</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>51189</commentid>
    <comment_count>0</comment_count>
      <attachid>2519</attachid>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2015-05-21 11:37:08 +0000</bug_when>
    <thetext>Created attachment 2519
Patch to fix the problem

Some projects such as bluez/obex and pulseaudio install user session services in (/usr)/lib/systemd/user/.

I attach a patch which solves the issue. I tested it in my poky-1.6.1 environment, but the code I added is still not there in latest master-next branch. In fact, the patch provided was generated against latest master-next branch from today.

This patch was necessary to get correct systemd support in pulseaudio_6.0.bb (still missing some stuff in there too in latest master-next, I will provide a bug report + patch soon today).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51233</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-05-22 15:54:05 +0000</bug_when>
    <thetext>For future reference, oe-core accepts patches through the mailing list not bugzilla.

Adding the paths to the search path gets the files packaged correctly, but doesn&apos;t that then result in invalid postinst scripts being written?  ie if I have a recipe that installs a foo user unit, the init script attempts to enable the foo system unit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51323</commentid>
    <comment_count>2</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2015-05-28 13:54:41 +0000</bug_when>
    <thetext>Yes, you may be correct with regarding to the enabling part. I&apos;m working on related stuff during next days (enabling systemd user session with dbus + pulseaudio + weston). 

I still have to check deeply but I guess a solution would be to check in systemd.bbclass if path contains systemd/user and then use systemctl --global enable instead of systemctl --system enable.

I will provide next solution on mailing list and share link to this bug report. Thank you for reviewing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51543</commentid>
    <comment_count>3</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2015-06-08 08:28:13 +0000</bug_when>
    <thetext>I sent some comments to the mailing list like a week ago with the work done so far but I got no response yet: 
https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg42187.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51992</commentid>
    <comment_count>4</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2015-06-29 09:49:21 +0000</bug_when>
    <thetext>I asked for information in systemd IRC channel on expected behavior for systemctl problem, but I got no answer.

I also added a bug report in systemd bugzilla in order to clarify the behaviour. It can be found in here:
https://bugs.freedesktop.org/show_bug.cgi?id=90897

So, for me this ticket is kind of blocked until we we get some answer from someone with more knowledge on systemd or systemctl specifically, or fins another better way to achieve something similar to what I&apos;m trying to achieve.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63133</commentid>
    <comment_count>5</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2016-06-18 17:56:13 +0000</bug_when>
    <thetext>It seems systemctl --global is finally working together with --root at least since version 229.

As v229 is currently being used (from what I could see in git recipes), this improvement could be pushed forward.

I&apos;m not having a lot of time to invest on this lately and I don&apos;t usually work with any OE environment nowadays, therefore if somebody wants to pick up this task he is more than welcome. Otherwise I may work on it at some point but unclear when that&apos;s gonna be.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65758</commentid>
    <comment_count>6</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2016-09-02 03:13:43 +0000</bug_when>
    <thetext>Could you please provide more details for your problem?

I can see that the systemd user deamon (/lib/systemd/systemd --user) is not started in our system. Is it the key problem here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65760</commentid>
    <comment_count>7</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2016-09-02 07:33:14 +0000</bug_when>
    <thetext>No, this ticket is not about &quot;systemd --user&quot; not being started, it is about systemd-user services not being installed automatically by systemd.bbclass and so not started correctly when &quot;systemd --user&quot; starts if they were not manually enabled in their own bb recipe at install time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65859</commentid>
    <comment_count>8</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2016-09-07 09:21:56 +0000</bug_when>
    <thetext>git://git.openembedded.org/openembedded-core-contrib ChenQi/systemd-user-units
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ChenQi/systemd-user-units

Chen Qi (3): 
  systemd-systemctl: add option to manage user services
  systemd.bbclass: add support to manage user services
  pulseaudio: fix to manage user services corretly</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67082</commentid>
    <comment_count>9</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2016-10-10 02:08:49 +0000</bug_when>
    <thetext>As the codes might have some impact, move it to 2.3.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82389</commentid>
    <comment_count>10</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2018-12-04 08:04:56 +0000</bug_when>
    <thetext>The current status of systemd has no such problem as the user instance of systemd daemon could be correctly started.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82394</commentid>
    <comment_count>11</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2018-12-04 16:34:18 +0000</bug_when>
    <thetext>As far as I can tell, in current poky.git ./meta/classes/systemd.bbclass, .service files under ${systemd_user_unitdir} are not being checked and included into $FILES_FOO (foo as in foreach $SYSTEMD_PACKAGES) like the ones done in ${systemd_system_unitdir}.

So I reopen the issue because it&apos;s still not fixed. systemd.bbclass continues to ignore systemd user services files.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82424</commentid>
    <comment_count>12</comment_count>
    <who name="Stephen K Jolley">sjolley.yp.pm</who>
    <bug_when>2018-12-06 16:09:09 +0000</bug_when>
    <thetext>Chen Qi - Please review again, if needed set into NEEDINFO to get configuration that doesn&apos;t work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88498</commentid>
    <comment_count>13</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-10-27 08:00:38 +0000</bug_when>
    <thetext>Move from 3.3-M2 to 3.3 since medium priority bugs are not targeted to a milestone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106194</commentid>
    <comment_count>14</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-07-16 15:17:43 +0000</bug_when>
    <thetext>Himani, can you check if this feature is present and working on oe-core/master.
We think it was fixed in Jan 2025. It would be nice to add a test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106195</commentid>
    <comment_count>15</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2026-07-16 15:17:56 +0000</bug_when>
    <thetext>I think this was addressed by the patches from Artur in around around this patch:
https://git.openembedded.org/openembedded-core/commit/?id=df1cdf1bf4cd7d9f17c6a02538057ccfc2efba64</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106202</commentid>
    <comment_count>16</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-07-16 20:45:06 +0000</bug_when>
    <thetext>Himani, Can you or a co-worker check on this. 
As Richard said, it seems like the problem has been resolved
so we&apos;d like you to confirm first and then maybe write a test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106261</commentid>
    <comment_count>17</comment_count>
    <who name="Himani Barde">HimaniRamesh.Barde</who>
    <bug_when>2026-07-22 11:37:06 +0000</bug_when>
    <thetext>Confirmed fixed on oe-core/master.

Artur Kowalski&apos;s patch series (merged Jan 2025, signed-off by Richard Purdie) fully addresses this. 

Key commits:

- df1cdf1bf4 systemd.bbclass: add ${sysconfdir}/systemd/user to search path
- 9a89d36932 systemd.bbclass: introduce systemd_service_searchpaths()
- 0218542d80 systemd.bbclass: properly handle user units in systemd_create_presets
- ce62b88d8f systemd.bbclass: support user units in postinst and prerm hooks

Code inspection on current master confirms:
- User unit search paths (${systemd_user_unitdir} and ${sysconfdir}/systemd/user) are included
- systemctl --global enable/disable/preset is used for user services
- Separate user-preset files are generated
- postinst and prerm scripts correctly differentiate system vs user units

Regarding a test case: there is currently no dedicated oe-selftest for user unit handling in systemd.bbclass. I can look into writing one if needed — it would involve a minimal recipe that installs a service to ${systemd_user_unitdir} and verifies the postinst uses --global and a user-preset file is generated. Let me know if you&apos;d like me to proceed with that.

This bug can be closed as RESOLVED/FIXED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106271</commentid>
    <comment_count>18</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-07-22 17:42:19 +0000</bug_when>
    <thetext>Thanks Himani. 

Pau all good ? If so please close the bug.

---

Himani, 

I&apos;d like to to create an YP enhancement to investigate
reviving the ptest coverage for systemd.

A quick search of the systemd git repo suggests that there are tests
for user units:
---
systemd.git on main
❯ rg &quot;user unit&quot; test/
test/units/TEST-55-OOMD.sh
162:    # Make sure we also work correctly on user units.

test/units/TEST-91-LIVEUPDATE.sh
23:# Ensure user units can also manage sessions

test/units/TEST-26-SYSTEMCTL.sh
611:# Test 1: Create a new global user unit with --force and --runtime

test/units/TEST-50-DISSECT.mountfsd.sh
127:# If the kernel support is present unprivileged user units should be able to use verity images too
---

We had ptest coverage for systemd back in 2018, 
until we updated to building systemd using meson:

https://git.openembedded.org/openembedded-core/commit/?id=906230a73b3ccfa4afd2a19a6b0aa18cd1d5fa08
...
    This new version has dropped ptest support, as there&apos;s no easy
    way to do this in the framework of meson.
---

Of course meson may have improved since then! 

I don&apos;t see a relevant systemd+ptest bug already:
https://bugzilla.yoctoproject.org/buglist.cgi?quicksearch=systemd&amp;list_id=663779

so please create one and mention it here.

Then pass the bug in NEEDINFO state to Pau to close.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106437</commentid>
    <comment_count>19</comment_count>
    <who name="Himani Barde">HimaniRamesh.Barde</who>
    <bug_when>2026-08-06 05:57:50 +0000</bug_when>
    <thetext>Created Bug 16386 - https://bugzilla.yoctoproject.org/show_bug.cgi?id=16386 to track investigation of reviving ptest coverage for systemd, including user unit tests.

Setting to NEEDINFO for Pau to close.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106438</commentid>
    <comment_count>20</comment_count>
    <who name="Pau Espin Pedrol">pespin.shar</who>
    <bug_when>2026-08-06 08:45:32 +0000</bug_when>
    <thetext>Hi, as you may have noticed this bug report was opened quite a long time ago (almost 10 years!), and I haven&apos;t been doing related work since also quite a lot of time, so it&apos;s hard for me to validate or test current state right now.

Hence, letting you decide on whether the issue has been properly fixed and whether the bug report can finally be closed :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106440</commentid>
    <comment_count>21</comment_count>
    <who name="Himani Barde">HimaniRamesh.Barde</who>
    <bug_when>2026-08-06 08:52:30 +0000</bug_when>
    <thetext>Thanks Pau. Closing this as RESOLVED/FIXED.

The fix has been confirmed on oe-core/master via Artur Kowalski&apos;s patch series (merged Jan 2025). The issue is fully addressed.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>2519</attachid>
            <date>2015-05-21 11:37:08 +0000</date>
            <delta_ts>2015-05-21 11:37:08 +0000</delta_ts>
            <desc>Patch to fix the problem</desc>
            <filename>0001-systemd.bbclass-Add-user-directory-to-searchpaths.patch</filename>
            <type>text/plain</type>
            <size>1349</size>
            <attacher name="Pau Espin Pedrol">pespin.shar</attacher>
            
              <data encoding="base64">RnJvbSBlNzMxNzBhOTcxZDJhYmE5NzNlNjQ2ZDgzOTUyMTc2Yjg3MWMxYWEyIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBQYXUgRXNwaW4gUGVkcm9sIDxwYXUuZXNwaW5AYXdldXJvcGUu
YmU+CkRhdGU6IFRodSwgMjEgTWF5IDIwMTUgMTM6MTk6MTIgKzAyMDAKU3ViamVjdDogW1BBVENI
XSBzeXN0ZW1kLmJiY2xhc3M6IEFkZCB1c2VyIGRpcmVjdG9yeSB0byBzZWFyY2hwYXRocwoKU29t
ZSBwcm9qZWN0cyBzdWNoIGFzIGJsdWV6L29iZXggYW5kIHB1bHNlYXVkaW8gaW5zdGFsbCB1c2Vy
IHNlc3Npb24gc2VydmljZXMgaW4gKC91c3IpL2xpYi9zeXN0ZW1kL3VzZXIvLgoKU2lnbmVkLW9m
Zi1ieTogUGF1IEVzcGluIFBlZHJ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