Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install swag #209

Closed
johanndiedrick opened this issue Sep 18, 2018 · 26 comments
Closed

Can't install swag #209

johanndiedrick opened this issue Sep 18, 2018 · 26 comments
Labels

Comments

@johanndiedrick
Copy link

johanndiedrick commented Sep 18, 2018

Describe the bug
I'm unable to install swag given the instructions on the README

To Reproduce
Steps to reproduce the behavior:

  1. Execute go get github.com/swaggo/swag/cmd/swag on the command line
  2. See the following error:
go get github.com/swaggo/swag/cmd/swag
# github.com/ghodss/yaml
./yaml.go:102:28: undefined: yaml.UnmarshalStrict
  1. Try to run swag
  2. See the following error:
zsh: command not found: swag

Expected behavior
swag should be installed properly on my machine.

Desktop (please complete the following information):

  • OS: macOS High Sierra
  • Version: go version go1.10.3 darwin/amd64

@pei0804

@easonlin404
Copy link
Member

easonlin404 commented Sep 19, 2018

@jdiedrick Looks like you have older github.com/ghodss/yaml version at local, please add the -u flag when getting swag like:
go get -u github.com/swaggo/swag/cmd/swag

@easonlin404
Copy link
Member

@jasonhancock please reopen it if you have any questions.

@ghost
Copy link

ghost commented Jan 21, 2019

Followed the recommendation and still "zsh: command not found: swag"

@stiffer831
Copy link

stiffer831 commented Feb 13, 2019

I have installed swag as follows: go get -u github.com/swaggo/swag/cmd/swag. But when I run "swag", I got error like: -bash: swag: command not found. how can I resolved this issue? thanks.
Mac OS version: 10.14.3 and golang version: go1.11 darwin/amd64

@jasonhancock
Copy link
Contributor

@stiffer-cl the binary will likely have been installed to $GOPATH/bin/swag. Run if from there or copy the file from there to somplace in your $PATH

@ghost
Copy link

ghost commented Feb 19, 2019 via email

@pnutmath
Copy link

Path variable must be set:
After running go get -v -u github.com/swaggo/swag/cmd/swag
Please check /usr/local/go/bin or $HOME/go/bin where those swag executable is present.

Make sure you have that PATH in /etc/profile or $HOME/.profile

e.g. export PATH=$PATH:$HOME/go/bin

@hariraogotit
Copy link

hariraogotit commented Apr 18, 2020

Hi @pnutmath @jasonhancock I did the following

  1. Ran go get -v -u github.com/swaggo/swag/cmd/swag
  2. I see swag in $HOME/go/bin
  3. I then tried running swag init in my work space where I have my main.go but I got "-bash: swag: command not found".
  4. I then ran swag init in $HOME/go/bin and I got the same error

I am new to Golang. Can you please help?

@jasonhancock
Copy link
Contributor

@hariraogotit from the directory with your main.go, run $HOME/go/bin/swag or add $HOME/go/bin to your $PATH, or copy $HOME/go/bin/swag to a directory in your $PATH

@hariraogotit
Copy link

@hariraogotit from the directory with your main.go, run $HOME/go/bin/swag or add $HOME/go/bin to your $PATH, or copy $HOME/go/bin/swag to a directory in your $PATH

thank you very much that worked

@Omkeshs
Copy link

Omkeshs commented Oct 30, 2020

@jasonhancock, please use export PATH=$(go env GOPATH)/bin:$PATH

@alramdein
Copy link

alramdein commented Jun 26, 2021

What and where is $PATH? Is it from Windows Environment Variable? I'm new to Golang

@Omkeshs
Copy link

Omkeshs commented Jun 26, 2021

  1. Create new folder wherever you like for your code, create there: bin, src and pkg directories.
  2. Then go to Control Panel -> All Control Panel Items -> System -> Advansed System Settings -> tab Advanced -> Environment Variables -> add new system variable by clicking New on System varaibles -> Variable name = GOPATH, Variable value = Your:\directory\that\you\created
    When you're done, RESTART your cmd or Bash(that's important) and you have your GOPATH set. To be sure run go env and you will see your value. Then reopen cmd/restart cmd.

@yusrilmr
Copy link

yusrilmr commented Mar 8, 2022

In my case, I added these two lines to my environment variable(MacOS):

export GOPATH=/Users/[user-folder-name]/go
export PATH=$GOPATH/bin:$PATH

Open a new terminal, then execute the Swaggo command.

@DecodeWorms
Copy link

Currently, am using swag version 1.8.1 But the company am working for require me to use version 1.7.6 and have been trying to do this by google on how to do this BUT i was unable to get answer, can anybody help me on this?

@DecodeWorms
Copy link

Currently, am using swag version 1.8.1 But the company am working for require me to use version 1.7.6 and have been trying to do this by google on how to do this BUT i was unable to get answer, can anybody help me on this?

solved.

@basil-github
Copy link

basil-github commented Jun 16, 2022

@jasonhancock
$HOME/go/bin/swag init
Worked for me

@MohammadMobasher
Copy link

use this command please:
go install github.com/swaggo/swag/cmd/swag@latest

@fakecore
Copy link

use this command please: go install github.com/swaggo/swag/cmd/swag@latest

works for me. thx ❤️

@Hemanth-jagaari
Copy link

use this command please: go install github.com/swaggo/swag/cmd/swag@latest

yes it works

@zubikp
Copy link

zubikp commented Feb 19, 2023

use this command please: go install github.com/swaggo/swag/cmd/swag@latest

works for me. thx ❤️

@leyzer9
Copy link

leyzer9 commented Mar 1, 2023

use this command please: go install github.com/swaggo/swag/cmd/swag@latest

Worked for me , thanks.

@orubin
Copy link

orubin commented May 8, 2023

go install github.com/swaggo/swag/cmd/swag@latest

Works thanks!!

@vbgithub1983
Copy link

Bingo this is working -
go install github.com/swaggo/swag/cmd/swag@latest

@minias
Copy link

minias commented Aug 11, 2023

I searched for the same issue and came in.

I started tracking down the cause myself.

The conclusion is that the build failed because the go.mod, go.sum file did not have the right to update.

The fundamental solution is to change the permissions of some files in Makefile to 755, or adjust the permissions as follows.

git update-index --chmod=+x go.mod go.sum

My environment is as follows.

MacBook Pro 14 / Apple M2 Pro / 16GB
macOS 13.4.1
zsh 5.9 (x86_64-apple-darwin22.0)

Go Preferences are as follows.

GOVERSION="go1.20.3"
GOPATH="/Users/minias/go"
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOMOD="/Users/minias/go/pkg/mod/github.com/swaggo/swag@v1.16.1/go.mod"

The solution is as follows.

cd /Users/minias/go/pkg/mod/github.com/swaggo/swag@v1.16.1
chmod 755 go.mod
chmod 755 go.sum
make build && make install

/usr/local/go/bin/go get github.com/swaggo/cli
/usr/local/go/bin/go get sigs.k8s.io/yaml
/usr/local/go/bin/go get github.com/KyleBanks/depth
/usr/local/go/bin/go get github.com/go-openapi/jsonreference
/usr/local/go/bin/go get github.com/go-openapi/spec
/usr/local/go/bin/go get github.com/stretchr/testify/assert
/usr/local/go/bin/go get golang.org/x/tools/go/loader
/usr/local/go/bin/go build -o swag ./cmd/swag
/usr/local/go/bin/go get github.com/swaggo/cli
/usr/local/go/bin/go get sigs.k8s.io/yaml
/usr/local/go/bin/go get github.com/KyleBanks/depth
/usr/local/go/bin/go get github.com/go-openapi/jsonreference
/usr/local/go/bin/go get github.com/go-openapi/spec
/usr/local/go/bin/go get github.com/stretchr/testify/assert
/usr/local/go/bin/go get golang.org/x/tools/go/loader
/usr/local/go/bin/go install ./cmd/swag

ls -al ~/go/bin/swag
-rwxr-xr-x@ 1 minias  staff    14M  8 11 11:22 /Users/minias/go/bin/swag

@muhamadsechansyadat
Copy link

muhamadsechansyadat commented May 2, 2024

sechansydt@sechansydt:~/coding/go/src/test_swag$ go install github.com/swaggo/swag/cmd/swag@latest
go: downloading github.com/swaggo/swag v1.16.3
go: downloading github.com/urfave/cli/v2 v2.3.0
go: downloading github.com/go-openapi/spec v0.20.4
go: downloading golang.org/x/text v0.13.0
go: downloading sigs.k8s.io/yaml v1.3.0
go: downloading github.com/KyleBanks/depth v1.2.1
go: downloading golang.org/x/tools v0.7.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/go-openapi/jsonreference v0.19.6
go: downloading github.com/go-openapi/jsonpointer v0.19.5
go: downloading github.com/go-openapi/swag v0.19.15
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
go: downloading github.com/mailru/easyjson v0.7.6
go: downloading golang.org/x/sys v0.13.0
go: downloading golang.org/x/net v0.17.0
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/josharian/intern v1.0.0
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0

crypto/subtle
asm: asmins: missing op 00036 () PCALIGN $16
asm: asmins: missing op 00065 () PCALIGN $16
asm: assembly failed

internal/bytealg
asm: asmins: missing op 00047 () PCALIGN $16
asm: asmins: missing op 00272 () PCALIGN $32
asm: assembly failed

internal/chacha8rand
/usr/local/go/src/internal/chacha8rand/chacha8_amd64.s:55: ABI selector only permitted when compiling runtime, reference was to """.block"
asm: assembly of /usr/local/go/src/internal/chacha8rand/chacha8_amd64.s failed

sechansydt@sechansydt:~/coding/go/src/test_swag$

How to fix it? i always tried and always get error like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests