Skip to content
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

Checksum mismatch against registry #29

Closed
tlux opened this issue Mar 20, 2020 · 1 comment
Closed

Checksum mismatch against registry #29

tlux opened this issue Mar 20, 2020 · 1 comment

Comments

@tlux
Copy link
Contributor

@tlux tlux commented Mar 20, 2020

Hello everyone,

Thank you for this great app. mini_repo has worked perfectly for several months now. But from one day to another I wasn’t able to mix deps.get anymore - without changing anything in my mini_repo setup. mix deps.get raises the following error:

** (RuntimeError) Checksum mismatch against registry (outer)
    (hex) lib/hex/scm.ex:187: Hex.SCM.update/1
    (mix) lib/mix/dep/fetcher.ex:61: Mix.Dep.Fetcher.do_fetch/3
    (mix) lib/mix/dep/converger.ex:190: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:123: Mix.Dep.Converger.all/7
    (mix) lib/mix/dep/converger.ex:108: Mix.Dep.Converger.all/4
    (mix) lib/mix/dep/converger.ex:51: Mix.Dep.Converger.converge/4
    (mix) lib/mix/dep/fetcher.ex:16: Mix.Dep.Fetcher.all/3
    (mix) lib/mix/tasks/deps.get.ex:31: Mix.Tasks.Deps.Get.run/1

However, before the issue appeared for the first time, I accidentally published the same version of the same package twice with different contents (thus changing the checksums for the package version). Possibly this has something to do with it? Anyway, the bug is NOT limited to that particular package anymore. In fact, I can't install any of my self-hosted packages at the moment.

I noticed that the mini_repo registry in the MiniRepo.Repository struct contains the same version for that particular package multiple times with different checksums, which seems odd to me. Maybe it would help to somehow rebuild the entiry registry.

This is my first attempt on rebuilding the registry, which did not help.

repo_name = :main
repo_config = Application.fetch_env!(:mini_repo, :repositories)[repo_name]
{_, [root: store_path]} = repo_config[:store]

registry =
  [store_path, "repos", to_string(repo_name), "tarballs", "*.tar"]
  |> Path.join()
  |> Path.wildcard()
  |> Enum.sort()
  |> Enum.reduce(%{}, fn tarball_path, registry ->
    {:ok, {package_name, version_info}} =
      tarball_path
      |> File.read!()
      |> MiniRepo.Utils.unpack_tarball()

    Map.update(registry, package_name, [version_info], &[version_info | &1])
  end)

MiniRepo.Repository
|> struct!([name: to_string(repo_name)] ++ repo_config)
|> Map.put(:registry, registry)
|> MiniRepo.RegistryBackup.save()

Edit: I also took a look into your wm-outer-checksum branch, which actually did the trick. Is there any chance of brushing things up and merging it into the master?

@wojtekmach

This comment has been minimized.

Copy link
Owner

@wojtekmach wojtekmach commented Mar 23, 2020

I also took a look into your wm-outer-checksum branch, which actually did the trick

Great. I just committed it on master so you should be good to go, but please let me know otherwise!

@wojtekmach wojtekmach closed this Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.