go-swagger
go-swagger copied to clipboard
The `swagger generate spec` command does not run normally.
Problem statement
Hello. I hope you're doing well.
After installing go-swagger through the brew install go-swagger
command and running swagger generate spec -o swagger.yaml --scan-models
in my Go project, the go-swagger cli stopped.
Also, no error message was printed.
To solve this problem, I looked through the go-swagger documentation and found an option called -w
.
As soon as I passed the absolute path of my Go project as the value of the -w
option, I confirmed that the go-swagger cli was working normally.
I couldn't figure out why I had to pass the -w
option to get the go-swagger cli to run normally.
And I was wondering how to run go-swagger cli normally without -w
option.
Be Safe and take care yourself.
Environment
swagger version: v0.27.0
go version: 1.17.1
OS: Apple M1 macOS Big Sur(11.5.2)
Same as me but mine is error, im run it with docker run through aliasing
err: exit status 1: stderr: failed to initialize build cache at /.cache/go-build: mkdir /.cache: permission denied
Same as me but mine is error, im run it with docker run through aliasing
err: exit status 1: stderr: failed to initialize build cache at /.cache/go-build: mkdir /.cache: permission denied
I'm encountering this too. Solved via this comment: https://github.com/go-swagger/go-swagger/issues/2242#issuecomment-766881952
Change your swagger alias to:
alias swagger='docker run --rm -it --user $(id -u):$(id -g) -e GOCACHE=/tmp -e GOPATH=$(go env GOPATH):/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger'
Same for me. Ubuntu 22.04 using an alias for the docker container setup. Comment from @dwjohnston solved it for me.
Maybe this part -e GOCACHE=/tmp
just needs to be added to the documentation to prevent the error for a lot of people. Makes kind of sense if i think about it. Isn't it the case that the swagger generator wants to write to the cache folder in the go path but cannot because the gopath is outside of the container? So just setting another cache dir will help?