Install from repo error

1. Caddy version (caddy version):

Latest from repo

$ caddy version
v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=

2. How I run Caddy:

Trying to install from repo and getting some error at end of installation (see below for relevant info).

a. System environment:

Ubuntu 18.04

b. Command:

$ echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
$ sudo apt update
$ sudo apt install caddy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  caddy
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 13.1 MB of archives.
After this operation, 36.9 MB of additional disk space will be used.
Get:1 https://apt.fury.io/caddy  caddy 2.1.1 [13.1 MB]
Fetched 13.1 MB in 3s (4,900 kB/s)
Selecting previously unselected package caddy.
(Reading database ... 267898 files and directories currently installed.)
Preparing to unpack .../archives/caddy_2.1.1_amd64.deb ...
Unpacking caddy (2.1.1) ...
Setting up caddy (2.1.1) ...
Failed to preset unit: File caddy.service: Invalid argument
/usr/bin/deb-systemd-helper: error: systemctl preset failed on caddy.service: No such file or directory
Failed to get unit file state for caddy.service: Invalid argument
caddy.service is a disabled or a static unit, not starting it.

d. My complete Caddyfile or JSON config:

None at this time (just trying to install)

3. The problem I’m having:

4. Error messages and/or full log output:

Specifically it is this:

Failed to preset unit: File caddy.service: Invalid argument
/usr/bin/deb-systemd-helper: error: systemctl preset failed on caddy.service: No such file or directory
Failed to get unit file state for caddy.service: Invalid argument
caddy.service is a disabled or a static unit, not starting it.

5. What I already tried:

Looked at caddy.service file, which appears to be HTML:

/etc/systemd/system$ cat caddy.service 






<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://github.githubassets.com">
  <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">



  <link crossorigin="anonymous" media="all" integrity="sha512-FG+rXqMOivrAjdEQE7tO4BwM1poGmg70hJFTlNSxjX87grtrZ6UnPR8NkzwUHlQEGviu9XuRYeO8zH9YwvZhdg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-146fab5ea30e8afac08dd11013bb4ee0.css" />
  <link crossorigin="anonymous" media="all" integrity="sha512-iXrV/b4ypc1nr10b3Giikqff+qAx5osQ0yJRxHRDd8mKFefdMtEZ0Sxs1QysJxuJBayOKThjsuMjynwBJQq0aw==" rel="stylesheet" href="https://github.githubassets.com/assets/site-897ad5fdbe32a5cd67af5d1bdc68a292.css" />
    <link crossorigin="anonymous" media="all" integrity="sha512-23DJ0jGXuHq4HnEnOv5yjJ3aD9zHvk4UkkK4Vs7e52NlpTBA9/zI9GMjyZ7MrJmYgiHJ0ZHNKVSFxEC3Pud9UA==" rel="stylesheet" href="https://github.githubassets.com/assets/github-db70c9d23197b87ab81e71273afe728c.css" />
    
    
    
    


  <meta name="viewport" content="width=device-width">
  
  <title>dist/caddy.service at master · caddyserver/dist · GitHub</title>
    <meta name="description" content="Resources for packaging and distributing Caddy. Contribute to caddyserver/dist development by creating an account on GitHub.">
    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">
  <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">
  <meta property="fb:app_id" content="1401488693436528">

    <meta name="twitter:image:src" content="https://avatars1.githubusercontent.com/u/12955528?s=400&amp;v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="caddyserver/dist" /><meta name="twitter:description" content="Resources for packaging and distributing Caddy. Contribute to caddyserver/dist development by creating an account on GitHub." />
    <meta property="og:image" content="https://avatars1.githubusercontent.com/u/12955528?s=400&amp;v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="caddyserver/dist" /><meta property="og:url" content="https://github.com/caddyserver/dist" /><meta property="og:description" content="Resources for packaging and distributing Caddy. Contribute to caddyserver/dist development by creating an account on GitHub." />

  <link rel="assets" href="https://github.githubassets.com/">
  
  

  <meta name="request-id" content="B88E:7E90:2B3910:3F23F6:5E847E1E" data-pjax-transient="true"/><meta name="html-safe-nonce" content="8c4733c97e496d1edc5914197d4e9c1065b4e17e" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6Imh0dHBzOi8vY2FkZHlzZXJ2ZXIuY29tL2RvY3MvaW5zdGFsbCIsInJlcXVlc3RfaWQiOiJCODhFOjdFOTA6MkIzOTEwOjNGMjNGNjo1RTg0N0UxRSIsInZpc2l0b3JfaWQiOiI4MjIxMjM4NzI2Njk3NDc0MDY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="961ab9d78b9e8f0c90f5c20bd6b31fd98c74d737674ce65d7bfb0c721a5963f9" data-pjax-transient="true"/>

...

6. Links to relevant resources:

I uninstall and re-installed and everything seems to be ok now:

$ sudo apt install caddy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  caddy
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 13.1 MB of archives.
After this operation, 36.9 MB of additional disk space will be used.
Get:1 https://apt.fury.io/caddy  caddy 2.1.1 [13.1 MB]
Fetched 13.1 MB in 3s (3,976 kB/s)
Selecting previously unselected package caddy.
(Reading database ... 267900 files and directories currently installed.)
Preparing to unpack .../archives/caddy_2.1.1_amd64.deb ...
Unpacking caddy (2.1.1) ...
Setting up caddy (2.1.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/caddy.service → /lib/systemd/system/caddy.service.

Huh, that’s very strange. I have no idea how that could’ve happened. I took a look at the .deb that’s hosted on gemfury and the contents look right. The .deb install hooks don’t do any requests to github either, so I don’t understand…

Your caddy.service file looks like this now, right?

Okay I have a hunch (shoutout to @elcore for pointing me in the right direction here).

Is it possible that you tried to install the Caddy service manually before? Maybe you used curl to grab the service file from github, but you actually downloaded the github HTML instead of the raw service file?

This is what I think might’ve happened:

  • Some time ago, you did some curl or wget command to pull down the service file directly from github, not realizing it was the full HTML page from github rather than the raw contents

  • You set up the gemfury repo and installed the caddy package

  • The .deb install process (the standard system behaviour) noticed there was already a caddy.service on disk, so it didn’t overwrite the file and just left it as-is.

  • The post-install hook of the .deb (which we wrote, which comes with the .deb) then tries to enable the service, but it fails because it’s an HTML document

  • You then uninstall the package, which involves a cleanup step which should remove the caddy.service file because it’s no longer needed

  • You then install once again, which finally does write the correct caddy.service file to disk.

Does that sound about right?

1 Like

Yes, I think you are exactly right. Good sleuthing!
I investigated Caddy some time ago and now revisiting to do our actual implementation.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.