sql-migrate icon indicating copy to clipboard operation
sql-migrate copied to clipboard

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

Open nikhil1011 opened this issue 3 years ago • 4 comments
trafficstars

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/[email protected].

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

nikhil1011 avatar Mar 21 '22 00:03 nikhil1011

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

nikhil1011 avatar Mar 21 '22 04:03 nikhil1011

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

krushanu avatar Apr 28 '22 14:04 krushanu

@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

nikhil1011 avatar Apr 28 '22 17:04 nikhil1011

@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.

krushanu avatar Apr 29 '22 07:04 krushanu

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

outime avatar Aug 26 '22 12:08 outime

@outime Merged the PR #215

rubenv avatar Aug 26 '22 12:08 rubenv

Should be OK now. Sorry for taking this long.

rubenv avatar Aug 26 '22 12:08 rubenv