-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
- On case-insensitive file-systems, in particular on Windows, Bazel does not distinguish workspaces whose names only differ by case. Stackage contains packages whose names only differ by case. E.g. `HSet` and `hset` in LTS 12.4. This causes errors of the following form on Windows. ``` ERROR: C:/users/user/_bazel_user/glk6p2o5/external/ai_formation_hazel/hazel.bzl:172:3: Label '@haskell_HSet//:files' is duplicated in the 'files' attribute of rule 'all_hazel_packages' ``` - This changes modifies the way Hazel generates workspace names such that they become case-insensitive. This is done by appending a hash of the package name. Characters of different case will lead to different hash values. - This change also unifies the Hazel name mangling into one extension file, and replaces all instances of manual name mangling by calls to the same name mangling functions.
I think it would be good to add more documentation in the README on how to discover what the hash is for a particular package. (That would help when debugging a package directly with In theory, you should be able to get the list of packages already by running something like
So that |
Use the following query to determine the workspace name to a Hackage package: ``` $ bazel query 'deps(@all_hazel_packages//:haskell_mtl, 1)' @all_hazel_packages//:haskell_mtl @haskell_mtl_108453//:bzl ``` The last line describes the case-insensitive workspace name. Note, that this also works on case-insensitive file systems, because Bazel target names remain case-sensitive on case-insensitive file systems.
@judah Thanks, that's a good idea! I've confirmed that target names are indeed case-sensitive on Windows as well, so this works. I noticed that the For now I've implemented (2) using the I've also added some documentation to the README. |
The implementation here looks good. I've tested it with our fairly large internal repo, which involved updating a few direct repository references to include their hashes. I'm still not quite sure we're doing the right thing, though it certainly solves the acute problem on case-insensitive filesystems. Are there any other rulesets that deal with the same problem? Or is Hackage the only package repository to allow case-equivalent packages 😅 |
Very good question! For reference I had a look at Python, Java/Scala, and Golang, see below for details. Of what I could find it seems that this here is the first instance of this issue surfacing. It seems that most packaging ecosystems either don't allow package names to only differ in case, or have longer package coordinates including organization names that make such collisions unlikely. Looking at rules_python they use lower-cased versions of package names, because apparently
In the JVM world, Maven coordinates are case-sensitive, in the sense that if you specify
So, this seems to be a non-issue for any of the JVM rules. If, perhaps, only incidentally. In rules_go I couldn't find any handling of upper case in package names. I'm no Go expert, but my understanding is that third-party packages are always fully qualified, including some sort of organization/author identifier. This makes such upper/lower case collisions very unlikely. I could only find one instance where an organization renamed itself to an all lower case spelling. In that case rules_go decided not to act. |
Apologies for sitting on this, it breaks our build in a subtle way and I haven't had time to properly evaluate why. |
The mangled hazel_workspace name was inserted wrongly. Whenever another package depended on a custom package it would fail due to the missing external workspace.
@thumphries I noticed that I made a silly mistake in the |
Actually, I suspect we were broken by the change in tweag/rules_haskell#550 Let's just merge this (since it is working for you) and I'll revisit once we catch up to rules_haskell master. Again, sorry for the slow. |
closes #52
tools/mangling.bzl
providinghazel_workspace
,hazel_library
, andhazel_binary
functions in one location.