Gitea: routers/api/v1/api.go:5: running "swagger": exec: "swagger": executable file not found in $PATH

Created on 4 May 2017  Â·  14Comments  Â·  Source: go-gitea/gitea

When I run TAGS=bindata make generate build, it reports the error. @sapk

kinbug kinbuild

Most helpful comment

Nevermind me, I reinstalled sed with Homebrew with brew install --with-default-names gnu-sed and it worked now.

All 14 comments

When I run make swagger-ui, it reports:

➜  gitea git:(lunny/autocert) ✗ make swagger-ui
rm -Rf public/assets/swagger-ui
git clone --depth=10 -b v3.0.7 --single-branch https://github.com/swagger-api/swagger-ui.git /tmp/swagger-ui
Cloning into '/tmp/swagger-ui'...
remote: Counting objects: 321, done.
remote: Compressing objects: 100% (237/237), done.
remote: Total 321 (delta 93), reused 207 (delta 69), pack-reused 0
Receiving objects: 100% (321/321), 755.53 KiB | 231.00 KiB/s, done.
Resolving deltas: 100% (93/93), done.
Note: checking out 'b289d5992a00748213d0344c0eacf42a3b7f60c2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

mv /tmp/swagger-ui/dist public/assets/swagger-ui
rm -Rf /tmp/swagger-ui
sed -i "s;http://petstore.swagger.io/v2/swagger.json;../../swagger.v1.json;g" public/assets/swagger-ui/index.html
sed: 1: "public/assets/swagger-u ...": extra characters at the end of p command
make: *** [swagger-ui] Error 1

It's two separate problems :

  • make generate execute go generate and api.go now have a generate command based on swagger.
    But make (https://github.com/go-gitea/gitea/blob/master/Makefile#L57) should get swagger before executing go generate. I will have a look into it.
  • make swagger-ui is for updating the swagger-ui interface to display swagger.json (generated by go generate). It seems that the sed command failed.

In order to reproduce what is your env mostly for sed?
For fixing swagger dep you could add $GOPATH/bin like in drone env or add swagger to your PATH after getting it.

@lunny any news ?

In fact, I think I didn't install swagger correctly?

For make generate yes and for sed (make swagger-ui that update the dep) I think that it could come from a different version depending of OS maybe I could improve interoperability.

I've run into a sed problem as well, when running env TAGS=sqlite make generate build (I'm using Fish shell) it gives this output:

me@Jupiter ~/C/g/s/c/gitea> env TAGS=sqlite make generate build
go generate code.gitea.io/gitea code.gitea.io/gitea/cmd code.gitea.io/gitea/models code.gitea.io/gitea/models/migrations code.gitea.io/gitea/modules/auth code.gitea.io/gitea/modules/auth/ldap code.gitea.io/gitea/modules/auth/oauth2 code.gitea.io/gitea/modules/auth/openid code.gitea.io/gitea/modules/auth/pam code.gitea.io/gitea/modules/avatar code.gitea.io/gitea/modules/base code.gitea.io/gitea/modules/context code.gitea.io/gitea/modules/cron code.gitea.io/gitea/modules/highlight code.gitea.io/gitea/modules/httplib code.gitea.io/gitea/modules/indexer code.gitea.io/gitea/modules/lfs code.gitea.io/gitea/modules/log code.gitea.io/gitea/modules/mailer code.gitea.io/gitea/modules/markdown code.gitea.io/gitea/modules/markup code.gitea.io/gitea/modules/minwinsvc code.gitea.io/gitea/modules/notification code.gitea.io/gitea/modules/options code.gitea.io/gitea/modules/private code.gitea.io/gitea/modules/process code.gitea.io/gitea/modules/public code.gitea.io/gitea/modules/setting code.gitea.io/gitea/modules/ssh code.gitea.io/gitea/modules/sync code.gitea.io/gitea/modules/templates code.gitea.io/gitea/modules/user code.gitea.io/gitea/modules/util code.gitea.io/gitea/modules/validation code.gitea.io/gitea/routers code.gitea.io/gitea/routers/admin code.gitea.io/gitea/routers/api/v1 code.gitea.io/gitea/routers/api/v1/admin code.gitea.io/gitea/routers/api/v1/convert code.gitea.io/gitea/routers/api/v1/misc code.gitea.io/gitea/routers/api/v1/org code.gitea.io/gitea/routers/api/v1/repo code.gitea.io/gitea/routers/api/v1/user code.gitea.io/gitea/routers/api/v1/utils code.gitea.io/gitea/routers/dev code.gitea.io/gitea/routers/org code.gitea.io/gitea/routers/private code.gitea.io/gitea/routers/repo code.gitea.io/gitea/routers/routes code.gitea.io/gitea/routers/user
bindata.go
bindata.go
bindata.go
sed: 1: "../../../public/swagger ...": invalid command code .
routers/api/v1/api.go:6: running "sed": exit status 1
make: *** [generate] Error 1

I'm on the latest version of OS X, and I'm not sure what to do from here.

Nevermind me, I reinstalled sed with Homebrew with brew install --with-default-names gnu-sed and it worked now.

So is this still an issue? Or can we close this?

It's still a problem when using default sed on macOS Sierra.

Actually #1791 should also fix this by removing the go generate tag and using a separate make command.

fixed by #1791 @lunny right?

Yes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fastidious picture Fastidious  Â·  3Comments

thehowl picture thehowl  Â·  3Comments

flozz picture flozz  Â·  3Comments

adpande picture adpande  Â·  3Comments

thehowl picture thehowl  Â·  3Comments