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

Error when http_archive has wrong sha256 now reports prefix not found in the zip #5045

Closed
alexeagle opened this issue Apr 18, 2018 · 13 comments
Assignees
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong P1 I'll work on this now. (Assignee required)

Comments

@alexeagle
Copy link
Contributor

Maybe a caching bug?

I changed my WORKSPACE to update the version in my http_archive

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "e9bc013417272b17f302dc169ad597f05561bb277451f010043f4da493417607",
    strip_prefix = "rules_nodejs-0.7.0",
    url = "https://github.com/bazelbuild/rules_nodejs/archive/0.7.0.zip",
)

now I get

ERROR: error loading package '': Encountered error while reading extension file 'defs.bzl': no such package '@build_bazel_rules_nodejs//': Prefix rules_nodejs-0.7.0 was given, but not found in the zip

I tried releasing a new tag just to get around this, but it still fails.

Sorry, at ng-conf, don't have time to make a minimal repro right now. Possible this is not reproducible, will try to follow up later.

@laszlocsomor
Copy link
Contributor

Please provide some repro, the repo you were working in, and the Bazel version.

@alexeagle
Copy link
Contributor Author

I will try to repro (have seen this twice now) - one hint (maybe) is that the sha256 was also wrong. Next time I see this happen I'll try removing the sha256 attribute and see if that makes any difference.

@alexeagle
Copy link
Contributor Author

Okay, now I understand it a bit better.

http_archive(
    name = "build_bazel_rules_nodejs",
    url = "https://github.com/bazelbuild/rules_nodejs/archive/0.7.0.zip",
    strip_prefix = "rules_nodejs-0.7.0",
    sha256 = "7406bea7954e1c906f075115dfa176551a881119f6820b126ea1eacb09f34a1a",
)

-> ERROR: error loading package '': Encountered error while reading extension file 'defs.bzl': no such package '@build_bazel_rules_nodejs//': Prefix rules_nodejs-0.7.0 was given, but not found in the zip

I expected the error message to tell me the sha256 is wrong, and what the actual one is, so I can update myself. That's what used to happen.

If I put the correct sha256sum, then it works.

@alexeagle
Copy link
Contributor Author

and it's reproducible on linux too, so it's not platform-specific, sorry for the false lead there

@alexeagle alexeagle changed the title Windows: prefix not found in zip Error when http_archive has wrong sha256 now reports prefix not found in the zip Apr 30, 2018
@laszlocsomor laszlocsomor assigned dslomov and aehlig and unassigned laszlocsomor May 2, 2018
@aehlig
Copy link
Contributor

aehlig commented May 28, 2018 via email

@alexeagle
Copy link
Contributor Author

Sure, I'm getting used to downloading the file and running sha256sum myself, this is low severity.

@qzmfranklin
Copy link

I am getting this same issue after upgrading to bazel 0.16

I remembered that in a previous version (possibly 0.12), it will report mismatched sha256. I liked that behavior better.

@ittaiz
Copy link
Member

ittaiz commented Oct 9, 2018 via email

@aehlig
Copy link
Contributor

aehlig commented Nov 7, 2018

I think the more accurate error message is indeed better.

Sure, but as explained in #6089, I don't see a way of improving the error message without degrading the non-error case by unwanted fetches.

@aehlig aehlig added more data needed and removed P2 We'll consider working on this in future. (Assignee optional) labels Nov 7, 2018
@ittaiz
Copy link
Member

ittaiz commented Nov 7, 2018 via email

@jrajahalme
Copy link

jrajahalme commented Nov 14, 2018

Just hit this by changing the archive I'm depending on to a newer one, but failing to update the SHA256, so in the hindsight it is obvious that the newer archive was not found from the old zip file.

@aehlig Would it be too much to ask to have some more context in the error message, e.g., "Existing zip with SHA256 ... was used but the contents does not match with the expected, maybe use a different SHA256?"

@irengrig irengrig added the bad error messaging Issues where users get stuck because they don't understand what they did wrong label Feb 1, 2019
@dslomov
Copy link
Contributor

dslomov commented Feb 6, 2019

Let's attempt to redownload the file and check the checksum if the prefix is not found

@dslomov dslomov added P1 I'll work on this now. (Assignee required) bazel 1.0 and removed more data needed labels Feb 6, 2019
@dslomov dslomov removed their assignment Feb 6, 2019
@aehlig
Copy link
Contributor

aehlig commented Feb 26, 2019

The current state (after aff8319) is that in that case (URL and prefix changed, but hash not updated), bazel will

  • report that the prefix wasn't found and show the available prefixes,
  • report which files where taken from cache based on which provided hashes, and
  • will fail the build.

After offline discussion with @dslomov, we decided to leave it at this state for the moment, and not attempt to proactively redownload the file.

@aehlig aehlig closed this as completed Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong P1 I'll work on this now. (Assignee required)
Projects
None yet
Development

No branches or pull requests

9 participants