rfjakob / earlyoom

earlyoom - Early OOM Daemon for Linux
MIT License
2.96k stars 157 forks source link

Installation fails due to systemd unit file not being copied to correct location #327

Closed cyrillkuettel closed 1 week ago

cyrillkuettel commented 1 month ago

This is a very minor thing, but I thought I'd write it out here in case this helps anybody. When installing earlyoom using make install, the systemd unit file is not copied to the correct location, causing the service to fail to enable and start.

Steps to Reproduce

  1. Clone the repository:
    git clone https://github.com/rfjakob/earlyoom.git
  2. Build the project:
    cd earlyoom && make
  3. Install using sudo:
    sudo make install

Expected Behavior

The installation should complete successfully.

Actual Behavior

The installation fails to enable the service due to the unit file not being found. The error message is:

$ sudo make install
# [...]
# as per README.md chcon warnings can be ingored
chcon -t systemd_unit_file_t /usr/local/etc/systemd/system/earlyoom.service
chcon: can't apply partial context to unlabeled file '/usr/local/etc/systemd/system/earlyoom.service'
make: [Makefile:43: install] Error 1 (ignored)
systemctl enable earlyoom
Failed to enable unit: Unit file earlyoom.service does not exist.
make: [Makefile:44: install] Error 1 (ignored)

Solution

To get the service working, I had to manually copy the systemd unit file to the correct location:

sudo cp /usr/local/etc/systemd/system/earlyoom.service /etc/systemd/system/

After this manual step, running sudo make install no longer throws the error Unit file earlyoom.service does not exist.

System Information

rfjakob commented 2 weeks ago

Caused by https://github.com/rfjakob/earlyoom/commit/f7d6f1cc925962fbdcf57b1c2aeeabbf11e2d542 , please take a look @AndersonTorres

AndersonTorres commented 2 weeks ago

TIL systemd hardcodes its files.

https://github.com/systemd/systemd/issues/19414

https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html