Skip to content

Dep - Solving failure: No versions of github.com/golang-migrate/migrate met constraints #123

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

Closed
megalepozy opened this issue Oct 29, 2018 · 4 comments

Comments

@megalepozy
Copy link

megalepozy commented Oct 29, 2018

Describe the Bug
When trying to use dep to fetch migrate I get "Solving failure: No versions of github.com/golang-migrate/migrate met constraints"

Steps to Reproduce
Steps to reproduce the behavior:

  1. Copy the second example of using migrate in a Go project from the README file and create a new folder with main.go containing the example code
  2. Run dep init

Expected Behavior
Expected dep to fetch the dependencies

Migrate Version
Not installed as I'm trying to use it as a lib

Go Version
go version go1.11.1 linux/amd64

Stacktrace
I get the following errors:
$ dep ensure
Solving failure: No versions of github.com/golang-migrate/migrate met constraints:
v4.0.2: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).)
v4.0.1: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).)
v4.0.0: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).)
v3.5.4: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).)
v3.5.3: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).)
v3.5.2: Could not introduce github.com/golang-migrate/[email protected] due to multiple problematic subpackages:
Subpackage github.com/golang-migrate/migrate/v4/source/file is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4 is missing. (Package is required by (root).) Subpackage github.com/golang-migrate/migrate/v4/database/postgres is missing. (Package is required by (root).)
And so on and on...

Just to make things easier, here is the code example which I used:

import (
    "database/sql"
    _ "github.com/lib/pq"
    "github.com/golang-migrate/migrate/v4"
    "github.com/golang-migrate/migrate/v4/database/postgres"
    _ "github.com/golang-migrate/migrate/v4/source/file"
)

func main() {
    db, err := sql.Open("postgres", "postgres://localhost:5432/database?sslmode=enable")
    driver, err := postgres.WithInstance(db, &postgres.Config{})
    m, err := migrate.NewWithDatabaseInstance(
        "file:///migrations",
        "postgres", driver)
    m.Steps(2)
}
@dhui
Copy link
Member

dhui commented Oct 29, 2018

If you're using migrate v4, use Go modules. If you're using migrate v3 you may use dep or another Go dependency manager. See: #103 (comment)

I'd recommend using migrate v4 and Go modules if possible since that's where the community is heading.

@megalepozy
Copy link
Author

First of all thanks a lot for your quick help and this gr8 project! 🥇

I saw that u removed the dep reference at the README, thats good cause it confused me :)

Other then that (and I know that this is not the place but this is not important enough to open a task and bug u there as well), I just worked with m.Up() and after doing a second migration it returned "no change" which was the expected result 4 me but I think that it should not be returned as an err as that should be reserved to.. well.. errors :)
Maybe change the output to string, err ? (at later version in order not to break compatibility of course)

@lopezator
Copy link
Contributor

lopezator commented Oct 30, 2018

Ran into same issue.

We don't want to move our project to modules yet since it isn't completely stable, some of our dependencies fail with modules.

Any workaround to use migrate, v4 and dep?

@dhui
Copy link
Member

dhui commented Oct 30, 2018

@megalepozy That's how Up() is designed to work. If you'd like, you can ignore ErrNoChange errors.

@lopezator Nope. As previously stated, if you wanna use migrate v4, you'll need to use Go modules. If you want to use another package manager, you'll have to use migrate v3. Note, all future development for migrate will be on v4. Security related fixes will be backported to v3 until Go 1.10 is EOL.

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

No branches or pull requests

3 participants