Can't build with plugins

I’m trying to build caddy from source with two plugins: http.filemanager and http.prometheus

I tried to follow https://github.com/mholt/caddy/wiki/Plugging-in-Plugins-Yourself by modifying the end of the imports in caddymain/run.go to be:

        "github.com/mholt/caddy/caddytls"
        // This is where other plugins get plugged in (imported)
        _ "github.com/hacdias/filemanager"
        _ "github.com/miekg/caddy-prometheus"
)

I performed a go get for each of those plugin github URLs. Then, while still within src/github.com/mholt/caddy/caddy I ran go run build.go to create the caddy binary. Next I ran caddy -plugins and didn’t see either of the two plugins listed. Running the caddy binary works fine without directives for the plugins, using the prometheus directive results in the following message:
no action found for directive ‘prometheus’ with server type ‘http’ (missing a plugin?)
Perhaps that wiki page is out of date?

Dumb question, I know, but was the source file which you edited inside your GOPATH?

I promise it should work, this is how the build server does it. :slight_smile:

No questions as dumb when debugging :smile:

$ echo $GOPATH
/Users/brian/go-workspace
$ ls $PWD/caddymain/run.go
/Users/brian/go-workspace/src/github.com/mholt/caddy/caddy/caddymain/run.go

I’m on a mac, maybe something weird going on with that? Someone on Hacker News recommends creating a plugins.go file; I tried that and it did not work either.

Do something crazy, like delete a huge swath of code in run.go, save it, and run build.go. If it doesn’t throw a compile error, then something is definitely wrong with your environment…

1 Like

I tried deleting stuff and it errored out so I went nuclear and deleted everything in $GOPATH to try a fresh start.
Still couldn’t get the wiki steps to work but I did get it to work when I copy and pasted this:

go get github.com/mholt/caddy
go get github.com/caddyserver/builds

cd "$GOPATH/src/github.com/mholt/caddy/caddy"

cat <<EOF>caddymain/plugins.go
package caddymain

import (
_ "github.com/hacdias/filemanager"
_ "github.com/miekg/caddy-prometheus"       
  )
EOF

go get -u -v -f ... || echo "Updated dependencies"
go run build.go

EXCEPT that only http.prometheus worked, http.filemanager does not. That is, I can see prometheus with caddy -plugins and using the directive works, the metrics page works, but filemanager does not show up anywhere and gives me the message “no action found for directive ‘filemanager’ with server type ‘http’ (missing a plugin?)”.
Not sure what that says about the wiki’s method of building caddy, but either way I think there is a issue with the filemanager plugin. I think I’ll raise an issue with them tomorrow.

1 Like

hi,

you are using the wrong import. as you can read in the filemanager repo you shoud import

github.com/hacdias/filemanager/caddy/filemanager

If your build still fails, you can clone my repo at github.com/ulrichSchreiner/caddy-http and add this import to the plugins.go file. you will get a container with a caddy binary and a filemanager plugin.

take github.com/ulrichSchreiner/caddy-builder as a guide how to build.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.