-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Windows, macOS: package names and input-file-target names are case-ignoring #8799
Comments
Implement getCorrectCasing: a function that normalizes a path and returns the case-correct version of it. See bazelbuild#8799
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
*** Reason for rollback *** We must implement path case fixing on top of Skyframe (by requesting DirectoryListingValue), rather than as a JNI method. That way clients get invalidated when a path is renamed such that only the casing changes. *** Original change description *** Windows: implement getCorrectCasing Implement getCorrectCasing: a function that normalizes a path and returns the case-correct version of it. See #8799 Closes #9435. PiperOrigin-RevId: 277688249
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The --incompatible_validate_package_path_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I9d55cd76b2499172cb55252032163d936b83690e
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
The new --[no]experimental_check_label_casing flag enables a new validation step in package loading: when enabled, Bazel requires that package paths be case-correct. When the user runs "bazel build //Foo/Bar:Baz", Bazel looks up the package "Foo/Bar" by stat'ing "Foo/Bar/BUILD". If the file exists, then the package exists. Every Label that Bazel creates in this package is derived from the "Foo/Bar" string. On Linux the filesystem is case-sensitive, so the path casing must be correct for stat() to succeed, so it's impossible to load the package "//Foo/Bar" as "//FOO/baR". On Windows and macOS the filesystem ignores the difference between lower and upper case letters, so stat("foo/bAr/BUILD") and stat("FOO/bar/build") would both suceed, so "bazel build //foo/bAr:Baz" and "bazel build //FOO/bar:Baz" both work. This leads to bugs such as bazelbuild#6401, bazelbuild#8009, and bazelbuild#8799. Change-Id: I5ad86a0ede6f85aa9cac8e8e56072630738db55c
This class stores a RootedPath and the String value of its relative part. This class allows distinguishing RootedPaths on case-insensitive filesystems, if the RootedPaths refer to the same file but use different casing. The class only compares the casing of the relative parts, not of the root parts. Reason is, this class will be used to validate the casing of package paths, which are always relative to the package root. See bazelbuild#8799 Change-Id: Ie742f95a7feb3935c93cbba6db9278b63cfcc63a
This class stores a RootedPath and the String value of its relative part. This class allows distinguishing RootedPaths on case-insensitive filesystems, if the RootedPaths refer to the same file but use different casing. The class only compares the casing of the relative parts, not of the root parts. Reason is, this class will be used to validate the casing of package paths, which are always relative to the package root whose casing we needn't worry about. See bazelbuild#8799 Change-Id: Ie742f95a7feb3935c93cbba6db9278b63cfcc63a
This class stores a RootedPath and the String value of its relative part. This class allows distinguishing RootedPaths on case-insensitive filesystems, if the RootedPaths refer to the same file but use different casing. The class only compares the casing of the relative parts, not of the root parts. Reason is, this class will be used to validate the casing of package paths, which are always relative to the package root whose casing we needn't worry about. See bazelbuild#8799 Change-Id: Ie742f95a7feb3935c93cbba6db9278b63cfcc63a
This class stores a RootedPath and the String value of its relative part. This class allows distinguishing RootedPaths on case-insensitive filesystems, if two RootedPaths refer to the same file but use different casing. The motivation is to support validating package path casing. (See issue #8799.) My plan is to add a new SkyFunction called PathCasingLookupFunction, which validates that a certain RootedPath is correctly cased. The SkyKey can't just take a RootedPath, because on Windows the path semantics dictate that RootedPath objects are compared without regard to casing. Thus we must also store the particular casing in the SkyKey, and so we need the RootedPathWithCasing class. The class only compares the casing of the relative parts, not of the root parts. Reason is, this class will be used to validate the casing of package paths, which are always relative to the package root whose casing we needn't worry about. See #8799 Closes #10357. Change-Id: Ie742f95a7feb3935c93cbba6db9278b63cfcc63a PiperOrigin-RevId: 283705461
The new PathCasingLookupFunction is a SkyFunction that can validate the casing of a path. On case-insensitive filesystems if "foo/BUILD" exists then "FOO/BUILD" also exists (because they mean the same file), but this should not imply that the "//foo" and "//FOO" packages both exist. The new SkyFunction can validate whether "FOO/BUILD" is the correct casing. The casing is correct if the file's name in its parent directory's listing is exactly the same (case-sensitively) as the expected name. In a later PR we can change the PackageLookupFunction to deny loading if the path is not correctly cased. Change-Id: Ibb2a5f4f6c6041bdfc537b33d0c6fc55e568b998 Motivation: bazelbuild#8799
The new PathCasingLookupFunction is a SkyFunction that can validate the casing of a path. On case-insensitive filesystems if "foo/BUILD" exists then "FOO/BUILD" also exists (because they mean the same file), but this should not imply that the "//foo" and "//FOO" packages both exist. The new SkyFunction can validate whether "FOO/BUILD" is the correct casing. The casing is correct if the file's name in its parent directory's listing is exactly the same (case-sensitively) as the expected name. In a later PR we can change the PackageLookupFunction to deny loading if the path is not correctly cased. Change-Id: Ibb2a5f4f6c6041bdfc537b33d0c6fc55e568b998 Motivation: bazelbuild#8799
If the "bazel.check_label_casing" JVM property is "1", then PackageIdentifier objects will store not only the RepositoryName and PathFragment, but also the toString() values of those. These augmented PackageIdentifiers (actually: CaseCheckingPackageIdentifiers) allow telling apart PackageIdentifiers whose RepositoryName and PathFragment values are equal but are cased differently. This scenario is common on case-insensitive filesystems, where the paths "foo/x" and "FoO/X" are equal but differently cased. Motivation is to allow case-checking the package names in PackageLookupFunction. The SkyKey of PackageLookupFunction contains a PackageIdentifier, which holds a reference to the RepositoryName and PathFragment (package fragment). On case-insensitive filesystems, both of these objects check equality without regard to case, and so do PackageIdentifiers as a consequence. But PackageIdentifier objects are interned for better memory usage, which means that on a case-insensitive filesystem it's impossible to create two PackageIdentifiers whose RepositoryName and PathFragment are equal but differently cased. And that means it's also impossible to check in the PackageLookupFunction whether the requested package path (and thus the PackageIdentifier) has correct casing. With this PR, PackageIdentifier.create() will return CaseCheckingPackageIdentifier when case checking is enabled, so PackageLookupFunction will know exactly what casing the user requested, and can therefore validate that casing and deny loading the package if the casing is wrong. And that is what would fix bazelbuild#8799 Change-Id: I46106f83c0a5b16fa347dd8a07e3c5342248c605
The new PathCasingLookupFunction is a SkyFunction that can validate the casing of a path. On case-insensitive filesystems if "foo/BUILD" exists then "FOO/BUILD" also exists (because they mean the same file), but this should not imply that the "//foo" and "//FOO" packages both exist. The new SkyFunction can validate whether "FOO/BUILD" is the correct casing. The casing is correct if the file's name in its parent directory's listing is exactly the same (case-sensitively) as the expected name. In a later PR we can change the PackageLookupFunction to deny loading if the path is not correctly cased. Change-Id: Ibb2a5f4f6c6041bdfc537b33d0c6fc55e568b998 Motivation: bazelbuild#8799
If the "bazel.check_label_casing" JVM property is "1", then PackageIdentifier objects will store not only the RepositoryName and PathFragment, but also the toString() values of those. These augmented PackageIdentifiers (actually: CaseCheckingPackageIdentifiers) allow telling apart PackageIdentifiers whose RepositoryName and PathFragment values are equal but are cased differently. This scenario is common on case-insensitive filesystems, where the paths "foo/x" and "FoO/X" are equal but differently cased. Motivation is to allow case-checking the package names in PackageLookupFunction. The SkyKey of PackageLookupFunction contains a PackageIdentifier, which holds a reference to the RepositoryName and PathFragment (package fragment). On case-insensitive filesystems, both of these objects check equality without regard to case, and so do PackageIdentifiers as a consequence. But PackageIdentifier objects are interned for better memory usage, which means that on a case-insensitive filesystem it's impossible to create two PackageIdentifiers whose RepositoryName and PathFragment are equal but differently cased. And that means it's also impossible to check in the PackageLookupFunction whether the requested package path (and thus the PackageIdentifier) has correct casing. With this PR, PackageIdentifier.create() will return CaseCheckingPackageIdentifier when case checking is enabled, so PackageLookupFunction will know exactly what casing the user requested, and can therefore validate that casing and deny loading the package if the casing is wrong. And that is what would fix bazelbuild#8799 Change-Id: I46106f83c0a5b16fa347dd8a07e3c5342248c605
The new PathCasingLookupFunction is a SkyFunction that can validate the casing of a path. On case-insensitive filesystems if "foo/BUILD" exists then "FOO/BUILD" also exists (because they mean the same file), but this should not imply that the "//foo" and "//FOO" packages both exist. The new SkyFunction can validate whether "FOO/BUILD" is the correct casing. The casing is correct if the file's name in its parent directory's listing is exactly the same (case-sensitively) as the expected name. In a later PR we can change the PackageLookupFunction to deny loading if the path is not correctly cased. Motivation: #8799 Change-Id: Ibb2a5f4f6c6041bdfc537b33d0c6fc55e568b998 Closes #10362. Change-Id: Ie25b9b202a1aef3b2594064b4842fc0f2fb2776b PiperOrigin-RevId: 283939452
If the "bazel.check_label_casing" JVM property is "1", then PackageIdentifier objects will store not only the RepositoryName and PathFragment, but also the toString() values of those. These augmented PackageIdentifiers (actually: CaseCheckingPackageIdentifiers) allow telling apart PackageIdentifiers whose RepositoryName and PathFragment values are equal but are cased differently. This scenario is common on case-insensitive filesystems, where the paths "foo/x" and "FoO/X" are equal but differently cased. Motivation is to allow case-checking the package names in PackageLookupFunction. The SkyKey of PackageLookupFunction contains a PackageIdentifier, which holds a reference to the RepositoryName and PathFragment (package fragment). On case-insensitive filesystems, both of these objects check equality without regard to case, and so do PackageIdentifiers as a consequence. But PackageIdentifier objects are interned for better memory usage, which means that on a case-insensitive filesystem it's impossible to create two PackageIdentifiers whose RepositoryName and PathFragment are equal but differently cased. And that means it's also impossible to check in the PackageLookupFunction whether the requested package path (and thus the PackageIdentifier) has correct casing. With this PR, PackageIdentifier.create() will return CaseCheckingPackageIdentifier when case checking is enabled, so PackageLookupFunction will know exactly what casing the user requested, and can therefore validate that casing and deny loading the package if the casing is wrong. And that is what would fix bazelbuild#8799 Change-Id: I46106f83c0a5b16fa347dd8a07e3c5342248c605
If the "bazel.check_label_casing" JVM property is "1", then PackageIdentifier objects will store not only the RepositoryName and PathFragment, but also the toString() values of those. These augmented PackageIdentifiers (actually: CaseCheckingPackageIdentifiers) allow telling apart PackageIdentifiers whose RepositoryName and PathFragment values are equal but are cased differently. This scenario is common on case-insensitive filesystems, where the paths "foo/x" and "FoO/X" are equal but differently cased. Motivation is to allow case-checking the package names in PackageLookupFunction. The SkyKey of PackageLookupFunction contains a PackageIdentifier, which holds a reference to the RepositoryName and PathFragment (package fragment). On case-insensitive filesystems, both of these objects check equality without regard to case, and so do PackageIdentifiers as a consequence. But PackageIdentifier objects are interned for better memory usage, which means that on a case-insensitive filesystem it's impossible to create two PackageIdentifiers whose RepositoryName and PathFragment are equal but differently cased. And that means it's also impossible to check in the PackageLookupFunction whether the requested package path (and thus the PackageIdentifier) has correct casing. With this PR, PackageIdentifier.create() will return CaseCheckingPackageIdentifier when case checking is enabled, so PackageLookupFunction will know exactly what casing the user requested, and can therefore validate that casing and deny loading the package if the casing is wrong. And that is what would fix bazelbuild#8799 Change-Id: I46106f83c0a5b16fa347dd8a07e3c5342248c605
It appears not to have been wired up at all so it's all dead code. It was created as response to #8799 about 2.5 years ago but it appears that that bug was never fixed. RELNOTES: None. PiperOrigin-RevId: 439766199
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2.5 years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Description of the problem / feature request:
Bazel does not enforce correct casing in package names, nor in target names (if they refer to input files).
Bazel only enforces correct casing in target names that are rules or output files. (Because these are defined as strings in the BUILD file.)
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Repro on Windows -- in cmd.exe:
Repro on macOS -- in Bash:
What operating system are you running Bazel on?
Windows 10
macOS 10.15.1
What's the output of
bazel info release
?release 1.2.1
Have you found anything relevant by searching the web?
Same culprit as #7627.
The text was updated successfully, but these errors were encountered: