Xcaddy/plugin help needed

Hello. I am trying to figure out how to use xcaddy. I am specifically interested in trying the json-schema but unfortunately I am a bit overwhelmed and confused by GitHub and how installs work from there.

So far what I have done is:
Installed Visual Studio Code
Installed Go (go version go1.14.3 windows/amd64)
DL/Installed(?) xcaddy to C:\Users\jfire\Go\src\github.com\caddyserver\xcaddy
DL/Installed(?) the json-schema to C:\Users\jfire\Go\caddy-json-schema

When I try to run xcaddy I get the following:

2020/06/01 08:44:48 [INFO] Temporary folder: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0844.912429335
2020/06/01 08:44:48 [INFO] Writing main module: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0844.912429335\main.go
2020/06/01 08:44:48 [INFO] Initializing Go module
2020/06/01 08:44:48 [INFO] exec (timeout=10s): C:\Go\bin\go.exe mod init caddy
go: creating new go.mod: module caddy
2020/06/01 08:44:48 [INFO] Replace github.com/abiosoft/caddy-json-schema => C:\Users\jfire\Go\caddy-json-schema
2020/06/01 08:44:48 [INFO] exec (timeout=10s): C:\Go\bin\go.exe mod edit -replace github.com/abiosoft/caddy-json-schema=C:\Users\jfire\Go\caddy-json-schema
2020/06/01 08:44:48 [INFO] Pinning versions
2020/06/01 08:44:48 [INFO] exec (timeout=0s): C:\Go\bin\go.exe get -d -v github.com/caddyserver/caddy/v2
go: github.com/caddyserver/caddy/v2 upgrade => v2.0.0
2020/06/01 08:44:49 [INFO] Build environment ready
2020/06/01 08:44:49 [INFO] Building Caddy
2020/06/01 08:44:49 [INFO] exec (timeout=0s): C:\Go\bin\go.exe build -o C:\Users\jfire\Go\caddy-json-schema\caddy -ldflags -w -s -trimpath
go: found github.com/abiosoft/caddy-json-schema in github.com/abiosoft/caddy-json-schema v0.0.0-00010101000000-000000000000
2020/06/01 08:44:54 [INFO] Build complete: ./caddy
2020/06/01 08:44:54 [INFO] Cleaning up temporary folder: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0844.912429335
2020/06/01 08:44:54 [INFO] Running [./caddy]

**2020/06/01 08:44:54 [ERROR] exec: "./caddy": file does not exist**

So I downloaded the caddy server 2.0 and threw the .exe into the same folder. Now when I run xcaddy json-schema I get:

2020/06/01 08:47:04 [INFO] Temporary folder: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0847.315475727
2020/06/01 08:47:04 [INFO] Writing main module: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0847.315475727\main.go
2020/06/01 08:47:04 [INFO] Initializing Go module
2020/06/01 08:47:04 [INFO] exec (timeout=10s): C:\Go\bin\go.exe mod init caddy
go: creating new go.mod: module caddy
2020/06/01 08:47:04 [INFO] Replace github.com/abiosoft/caddy-json-schema => C:\Users\jfire\Go\caddy-json-schema
2020/06/01 08:47:04 [INFO] exec (timeout=10s): C:\Go\bin\go.exe mod edit -replace github.com/abiosoft/caddy-json-schema=C:\Users\jfire\Go\caddy-json-schema
2020/06/01 08:47:04 [INFO] Pinning versions
2020/06/01 08:47:04 [INFO] exec (timeout=0s): C:\Go\bin\go.exe get -d -v github.com/caddyserver/caddy/v2
go: github.com/caddyserver/caddy/v2 upgrade => v2.0.0
2020/06/01 08:47:05 [INFO] Build environment ready
2020/06/01 08:47:05 [INFO] Building Caddy
2020/06/01 08:47:05 [INFO] exec (timeout=0s): C:\Go\bin\go.exe build -o C:\Users\jfire\Go\caddy-json-schema\caddy -ldflags -w -s -trimpath
go: found github.com/abiosoft/caddy-json-schema in github.com/abiosoft/caddy-json-schema v0.0.0-00010101000000-000000000000
2020/06/01 08:47:07 [INFO] Build complete: ./caddy
2020/06/01 08:47:07 [INFO] Cleaning up temporary folder: C:\Users\jfire\AppData\Local\Temp\buildenv_2020-06-01-0847.315475727
2020/06/01 08:47:07 [INFO] Running [./caddy json-schema]

**[ERROR] 'json-schema' is not a recognized subcommand; see 'caddy help'**
**2020/06/01 08:47:07 [ERROR] exit status 1**

I’m really confused about where these files are supposed to ‘Go’ (pun intended). I’ve never used GitHub before aside from following some tutorials and just copying and pasting into command line. I think ‘Go’ with it’s path configuration is part of my problem too.

How can I get this to work and get a vscode? What am I missing?

Did you try following the instructions on the readme? GitHub - abiosoft/caddy-json-schema: JSON schema generator for Caddy v2

What is the command you are running?

I tried but when I pasted it into windows cmd it ran the first line without the --with so then I did git clone https://github.com/abiosoft/caddy-json-schema.git

I assumed that would be the same. Then I thought maybe I had to actually have Caddy installed on the windows system first so I did ‘curl -OL “https://github.com/caddyserver/caddy/releases/latest/download/caddy_2.0.0_windows_amd64.zip”’ and extracted the files.

I run Caddy on a headless RPi for my NAS and wanted to us Visual Studio Code on Windows for building a json.

Now I have all the files but just don’t know if they’re in the right place to make this work.

I don’t know how Windows works but you might need to remove the line break then, and try again.

Ok so I just deleted every file/folder related to Caddy/json-schema/xcaddy. I then ran go get -u github.com/caddyserver/xcaddy/cmd/xcaddy to get xcaddy. It installed inside my PATH in the Go folder.

Now I am trying to run that command

C:\Users\jfire\Go>xcaddy build v2.0.0 \ --with github.com/abiosoft/caddy-json-schema \
2020/06/01 11:27:06 [ERROR] missing flag; caddy version already set at v2.0.0

I get an error that caddy is already set at 2.0.

Any idea if that means I just need to download the plugin? How would I run it once I have it downloaded?

Those backslashes are to escape the newlines, so you’ll need to remove them too. (Sorry I don’t use Windows, I guess we expect people to know how to translate the bash commands into Windows shell syntax.)

Well that takes care of that issue…I don’t know much about command line in general and just started with Linux in April. Not I got what I believe are the desired results

C:\Users\jfire\Go\src\github.com\caddyserver\xcaddy> caddy json-schema --vscode
json-schema .vscode\caddy_schema.json written.
json-schema .vscode\settings.json written.

Now on to figuring out how to get it loaded in to VScode. Thank you!

1 Like

Great! Just put that .vscode folder in your project/workspace root.

I’ll give it a shot when I finish my chores…

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