vito / booklit

a pretty lit content authoring system
https://booklit.page
MIT License
176 stars 55 forks source link

Example does not work #19

Closed ykrevnyi closed 4 years ago

ykrevnyi commented 5 years ago

Getting error: failed to load plugin 'github.com/vito/booklit/booklitdoc': plugin: not implemented

Reproduce with:

git clone git@github.com:vito/booklit.git
cd booklit
booklit \
  -i ./docs/lit/index.lit \
  -o ./docs \
  --html-templates docs/lit/html \
  --plugin github.com/vito/booklit/booklitdoc

go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/yuriikrevnyi/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yuriikrevnyi/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/yuriikrevnyi/code/tmp/booklit/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n1/1fsc4x552wq69f8z3pz1ykqw0000gn/T/go-build369202601=/tmp/go-build -gno-record-gcc-switches -fno-common"
vito commented 5 years ago

Hmm, seems fishy. Go claims to support Darwin for the plugin package. Would you be able to try with the very latest Go?

ykrevnyi commented 5 years ago

Yup, tested with latest go as well.

go version: go version go1.12.5 darwin/amd64

The same error appears: failed to load plugin 'github.com/vito/booklit/booklitdoc': plugin: not implemented

vito commented 5 years ago

🤔 Guess using the plugin package was riskier than I thought. Thanks for letting me know.

What version of OS X are you running? Maybe it has to be the latest? I just tried it on an up-to-date machine and it seemed fine (well, it failed for a different reason - scripts/build-docs worked though).

alexbarbato commented 4 years ago

Hey @vito,

Just hopping into this thread as I'm also experiencing the issue @ykrevnyi is talking about.

Details System: Catalina 10.15.1 Booklit Version: 0.10.0 Go Version: go1.13.5 darwin/amd64

I see the exact same error mentioned above when I run the command stated in the read.me

booklit \
  -i docs/lit/index.lit \
  -o docs \
  --html-templates docs/lit/html \
  --plugin github.com/vito/booklit/booklitdoc \
  --plugin github.com/vito/booklit/chroma/plugin

however when I run the build-docs script locally everything works totally fine

go run cmd/booklit/*.go \
  -i docs/lit/index.lit \
  -o docs \
  --html-templates docs/lit/html \
  --plugin github.com/vito/booklit/booklitdoc \
  --plugin github.com/vito/booklit/chroma/plugin \

I'm still trying to debug why the binary version I installed of booklit does not work, but running the go directly does.

PS: For context, I first experienced this issue trying to make a PR for the concourse docs, but hit the snag above. Apologies if this is just user error!

alexbarbato commented 4 years ago

Even more suprisingly if I run the following locally to generate a new binary

go build \
    --ldflags "-X github.com/vito/booklit.Version=0.10.0" \
    -o booklit_test \
    github.com/vito/booklit/cmd/booklit 

and then use that booklit_test binary locally everything works totally fine.

I'm totally shooting in the dark here, but could it be because concourse is using a linux box to build the binary or something? Also if this helps the binary that is generated for me locally is 14.5MB whereas the binary I downloaded for the release of 0.10.0 from GitHub is 11.4MB. 🤷‍♂

vito commented 4 years ago

@alexbarbato Yeah I think you might be right. Cross-compiling probably doesn't work for the plugin package. Thanks for the sleuthing! I'll try to fix this up for the next release. Until then I suggest that folks just build booklit themselves. I've ended up doing that in my own projects to make the dependency explicit, and just doing something like this:

https://github.com/concourse/docs/blob/58f9b6556a3d5d7ad5d6955405a6cbf6ba1d2b0b/scripts/build#L7-L9

vito commented 4 years ago

I've "fixed" this by rolling back use of the plugin package. I'm going to do a bit more work to make sure the old reexec-based method works properly with Go modules and then ship another release.