-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix example of install by go toolchain at README #257
fix example of install by go toolchain at README #257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to specify the version in the path when installing.
$ docker run -it --rm golang:1.12-alpine
/go # apk add -q git
/go # echo $GOPATH
/go
/go # cd /
/ # go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate
/ # migrate
Usage: migrate OPTIONS COMMAND [arg...]
migrate [ -version | -help ]
Options:
-source Location of the migrations (driver://url)
-path Shorthand for -source=file://path
-database Run migrations against this database (driver://url)
-prefetch N Number of migrations to load in advance before executing (default 10)
-lock-timeout N Allow N seconds to acquire database lock (default 15)
-verbose Print verbose logging
-version Print version
-help Print usage
Commands:
create [-ext E] [-dir D] [-seq] [-digits N] [-format] NAME
Create a set of timestamped up/down migrations titled NAME, in directory D with extension E.
Use -seq option to generate sequential up/down migrations with N digits.
Use -format option to specify a Go time format string.
goto V Migrate to version V
up [N] Apply all or N up migrations
down [N] Apply all or N down migrations
drop Drop everything inside database
force V Set version V but don't run migration (ignores dirty state)
version Print current migration version
Source drivers: file
Database drivers: postgresql, stub, postgres
/ #
$
What version of go are you using?
Thank you for your reply and confirmation. ~ > go version
go version go1.12.7 darwin/amd64
~ > go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate
go: finding github.com/golang-migrate/migrate/cmd/migrate latest
go: finding github.com/golang-migrate/migrate/cmd latest
go get github.com/golang-migrate/migrate/cmd/migrate: no matching versions for query "latest" |
Are you running |
No. I'm running outside $GOPATH. |
Try running |
I ran as you said. But the result was the same.
|
Weird, based on your the output, it looks like you're pulling migrate v3 instead of migrate v4. I don't think modules are enabled. Try setting https://github.com/golang/go/wiki/Modules#how-to-use-modules |
Already GO111MODULE=on was. ~ > echo $GO111MODULE
on
~ > go clean -modcache
~ > go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate
go: finding github.com/golang-migrate/migrate/cmd/migrate latest
go: finding github.com/golang-migrate/migrate/cmd latest
go: finding github.com/golang-migrate/migrate v3.5.4+incompatible
go: downloading github.com/golang-migrate/migrate v3.5.4+incompatible
go: extracting github.com/golang-migrate/migrate v3.5.4+incompatible
go get github.com/golang-migrate/migrate/cmd/migrate: no matching versions for query "latest" |
Can confirm same issue in go 1.12.9. Specifying v4 works |
@incazteca @stobita Can you reproduce the issue in a docker container? That way we're isolating environment differences. |
@dhui Not really familiar with Dockerfile writing but I think I found a way to reproduce this, will provide a dockerfile later when I have the time. For now I noticed that the issue happens when a go.mod file is present. I've also noticed that when the command does work it downloads the latest version 3 |
I've encountered with the same problem. Here is the workaround: Can anyone please update the documentation? |
1 similar comment
Confirming this is still an issue with go1.14.2 I suggest that, even if we don't want to merge this PR as is because reasons, it would be useful to add the fix in the PR to the documentation as an alternative. Even if we don't understand why this bug is occurring, at this point it's been an issue for a while, and having to dig through issues and pull requests to try and find a solution to a known instillation issue is a bad user experience. |
@dhui If you're still trying to troubleshoot this issue, I created a dockerfile that represents my environment close enough to also cause this failure. Be warned that the docker image it with the dependencies is kind of big (between 500MB-1GB I think). FROM fedora:32
RUN dnf update -y && dnf install golang git -y
RUN mkdir /golang && mkdir /develop && cd /develop && git clone https://github.com/moul/golang-repo-template.git myrepo
ENV GOPATH=/golang
WORKDIR /develop/myrepo
RUN go build . && ./golang-repo-template
RUN go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate |
Thanks for the reproducible I think I've figured out the issue. It looks like there are issues installing This failure might be an issue specific to To work around this issue, you can either:
I'll update the README to warn about installing from an existing module. |
Note: in Go 1.16, it seems like |
Currently, result of install by go toolchain as follows
So, I fixed Installation->With Go toolchain.