Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Failed to execute operation: Invalid argument" mean when running systemctl enable?

Tags:

systemd

I've created a systemd service file (specifically for svnserve; I'm actually using the example from here https://stackoverflow.com/a/40584047/464087), and when I enable it, typing

sudo systemctl enable svnserve

I get the response

Failed to execute operation: Invalid argument

Running

sudo systemctl status svnserve

yields

● svnserve.service - Subversion protocol daemon
   Loaded: loaded (/etc/systemd/system/svnserve.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

not giving me any clue about anything being wrong. I can then start the service without any error, and it seems to be running as expected, and after starting systemctl status I still get no clue about anything being wrong:

● svnserve.service - Subversion protocol daemon
   Loaded: loaded (/etc/systemd/system/svnserve.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-01-09 22:10:14 UTC; 6s ago
  Process: 9677 ExecStart=/usr/bin/svnserve $DAEMON_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 9678 (svnserve)
    Tasks: 1
   Memory: 964.0K
      CPU: 2ms
   CGroup: /system.slice/svnserve.service
           └─9678 /usr/bin/svnserve --daemon --pid-file /run/svnserve/svnserve.pid --root /srv/svn/repos --log-file /var/log/svnserve/svnserve.log

So what does this error message mean? And to which level of things is "invalid argument" supposed to apply? An argument to the svnserve command? Some property in the service file? A command line argument to the servicectl command itself?

FWIW this is on a Ubuntu 16.04 LTS server.

like image 802
EricS Avatar asked Jan 09 '18 22:01

EricS


2 Answers

I had a similar case, in my case problem went away after removing the Alias line from the [Install] section. Thanks to Anton in another thread: https://stackoverflow.com/a/34978908/2711456 - alias' name may not be the same as service name.

like image 132
T . Avatar answered Oct 10 '22 09:10

T .


If you copy/paste the file from a system with one encoding (e.g. Windows) to another (e.g. linux), there may be issues with the file encoding, or characters being interpreted differently. You can convert the file and re-analyze to see if it is being interpreted correctly.

  1. Run the analyzer

$ sudo systemd-analyze verify yourname.service /etc/systemd/system/yourname.service:1: Assignment outside of section. Ignoring.

  1. Fix the encoding of the service file, e.g. using vim (answer from here)

$ vim +"set nobomb | set fenc=utf8 | x" yourname.service

  1. Edit the file and remove any strange characters that are now exposed at e.g. the start of the file. e.g. it might have characters like ^[[200~

  2. Save the file and re-enable the service

$ sudo systemctl enable yourname.service

like image 36
culix Avatar answered Oct 10 '22 08:10

culix