rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.18k stars 270 forks source link

sql-migrate CLI tool not being added to path with the installation command provided. `zsh: command not found: sql-migrate` #213

Closed nikhil1011 closed 2 years ago

nikhil1011 commented 2 years ago

Tried using Go 1.18 (the latest release as of March 20, 2022) and Go 1.17.8 (latest older release) on my Macbook Pro running MacOS Monterey Version 12.1 (21C52). The sql-migrate command is not getting added to the PATH variable. I have looked extensively and don't find a solution to adding this to the path without doing it manually. I would like to not do it manually.

Basically I'm getting zsh: command not found: sql-migrate when I try to run sql-migrate command on my terminal running zsh. Even when I switch to bash it doesn't work.

I can see that the package is being installed in $HOME/go/pkg/mod/github.com/rubenv/sql-migrate@v1.1.1.

Is this a known issue or am I missing something? How can I solve this?

nikhil1011 commented 2 years ago

After researching a little bit, I found that the binary file was not being generated anymore by the go get command and that functionality has been transferred over to the go install command. So to resolve this, the following needs to be run:

go install github.com/rubenv/sql-migrate/...@latest

krushanu commented 2 years ago

I am on macbook pro Intel My Go version is go1.18.1 darwin/amd64

I did use for installation go install github.com/rubenv/sql-migrate/...@latest

Still When I am doing sql-migrate --help, I am getting this error sql-migrate: command not found

nikhil1011 commented 2 years ago

@krushanu can you run ls $GOPATH and then make sure a bin folder exists there. Now, check ls $GOPATH/bin, there should be an sql-migrate file in that folder.

I am thinking your GOPATH has not been set correctly. Add it to your .zshrc file. Mine looks like this:

export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
export GOBIN=$GOPATH/bin
krushanu commented 2 years ago

@nikhil1011 Thanks for the guidance. Tried the above but no change in the error. Also tried to put it in the .bash_profile. No change.

outime commented 2 years ago

Advice about go install worked, I'd say the README needs to be updated. @rubenv thoughts?

rubenv commented 2 years ago

@outime Merged the PR #215

rubenv commented 2 years ago

Should be OK now. Sorry for taking this long.