Mix Lock mismatch for dependency on private git repo

I want to use an Elixir app hosted on a private git as a dependency on another project,

I added it to mix.exs as

[{:my_app, git: "http://mygit.com/My_App.git"}]

mix deps.get fetches it successfully, but when I try to compile I get the following error

Unchecked dependencies for environment dev:

  • my_app (http://mygit.com/My_App.git)
    lock mismatch: the dependency is out of date (run “mix deps.get” to fetch locked version)
    ** (Mix) Can’t continue due to errors on dependencies

Manually cloning the git repo and pointing to the local folder as

[{:my_app, path: "/path/to/My_App"}]

works fine.

I would try unlocking it

mix deps.unlock my_app
mix deps.get

Also, if you have packets with the same dependencies, but different versions, the add an override to it in your main project.

 [{:my_app, git: "http://mygit.com/My_App.git", override: true}]

I tried unlocking and adding override, but I still get the same error.

Running mix deps or looking at the mix.lock file it says the package is locked at the latest commit hash, which is correct.

When I get deps issues I cannot figure out, I remove the _build and deps folders from my project and run mix do deps.get, deps.compile, compile again.

I tried deleting _build, deps & mix.lock and still had the same problem. I guess the problem had something to do with my
private git repo, because the problem went away when I hosted the package on github.

Strange. I’ve hosted packages on a private git repo in the past without issue. All our corporate stuff is on Bitbucket. Never seen this.

Can you get to the address youre providing in mix.exs through website incognito mode, or curl, but without actually loging in anywhere? If not, mix won’t be able neither. If you have private repo on github, you can download it providing credentials lieke this: {:mylib, git: "https://login:password@github.com/user/repo.git"} At least it work’s that way in Ruby, don’t have any private repo though to test it now :thinking:

yeah it did need a username/password and I had them set as environment variables and didn’t think authentication was an issue since mix deps.get was able to fetch the package, but entering the actual credentials in the mix file fixed the lock mismatch problem