-
Notifications
You must be signed in to change notification settings - Fork 404
Ignore symlinks into Bazel output rather than relying on name #1384
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
Ignore symlinks into Bazel output rather than relying on name #1384
Conversation
5c32b79
to
795adbc
Compare
795adbc
to
95070a7
Compare
95070a7
to
3dd09e6
Compare
Tagging @jayconrod, since it looks like he last reviewed changes to this file. Hope that's ok. |
walk/walk.go
Outdated
// <output-base>/execroot/<workspace-name>/bazel-out | ||
// See https://docs.bazel.build/versions/master/output_directories.html | ||
// for documentation on Bazel directory layout. | ||
bazelOut, err := filepath.EvalSymlinks(filepath.Join(c.RepoRoot, "bazel-out")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a new dependency on the value of --symlink_prefix
and also means that symlinks into the output base are still followed if the convenience symlinks aren't created (which is more likely with the new algorithm used in Bazel 6).
@cpsauer @linzhp Do you think we could instead decline to follow any symlinks that point out of the project directory? That is a condition that needs no external information to be evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's a fair requirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I think the main use case for following symlinks was stitching together multiple repos into something that looks like a coherent workspace. It is probably necessary to follow symlinks outside the repo and outside the workspace root to avoid a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed review; I think my GitHub notification settings are messed up.
Some history: symbolic links create problems for anything walking a directory tree, and it's generally best to treat them like regular files and not follow them. Unlike, filepath.Walk
Gazelle does not take that advice. I think the reasons were:
- Kubernetes does some shenanigans with their
vendor
andstaging
directories. It looks like this is still the case. - The person who originally contributed this functionality had separate repos for public and private code. They had been separate
GOPATH
directories. They wanted Gazelle to work, stitching the two repos together with symbolic links.- Up to the current maintainers whether you want to maintain this use case or break it. I wish I had said No to that PR since it made everything more complicated for the benefit of one organization.
So the main question is whether it's possible for Gazelle to tell if a symbolic link points inside Bazel's output base without running Bazel. Given --symlink_prefix
and changes in new versions of Bazel, it probably can't be done perfectly without running bazel info output_base
.
But maybe ignoring symbolic links that point inside a small number of output directories would be good enough? On macOS, bazel info output_base
is always in /private/var/tmp/_bazel_$USER
. On Linux, it's in $HOME/.cache/bazel/_bazel_$USER
.
walk/walk.go
Outdated
// <output-base>/execroot/<workspace-name>/bazel-out | ||
// See https://docs.bazel.build/versions/master/output_directories.html | ||
// for documentation on Bazel directory layout. | ||
bazelOut, err := filepath.EvalSymlinks(filepath.Join(c.RepoRoot, "bazel-out")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I think the main use case for following symlinks was stitching together multiple repos into something that looks like a coherent workspace. It is probably necessary to follow symlinks outside the repo and outside the workspace root to avoid a regression.
I am OK with breaking it. Stitching two repos together using symlinks sounds more like a hack to me than legit scenario.
I think they should instead make them two Go modules and have the private module importing the public module. |
Hey, guys! Thanks for getting back to me. Just to clarify: Is the decision to get rid of all symlink traversal? [I should also note that, after more thought, I'm realizing that even Again, just here trying to help as a non-current user, so please forgive my ignorance--it's unclear how this would interact with, e.g. external repos that symlink things in. If the decision is to not traverse symlinks at all, and it's obvious to you guys what code to strip, feel free to just close this and go for it--might be faster and save a RTT and it's not that related to the original diff. Might want to preserve the comment change in repo.go, though. |
(Friendly bump.) |
Sorry for the delay. I am OK with a breaking change to disallow following symlinks all together, or a minor version of not following symlinks outside project directory like @fmeum suggested. |
Per decision in bazel-contrib#1384 (comment)
Per decision in bazel-contrib#1384 (comment)
1073985
to
7fd0fb7
Compare
Per decision in bazel-contrib#1384 (comment)
7fd0fb7
to
e2140cc
Compare
Per decision in bazel-contrib#1384 (comment)
e2140cc
to
df20d2e
Compare
np. Thanks for replying to clarify, guys! How's this for skipping symlinks altogether? I think this'd also solve #168 in this form, so I've marked it as such. |
Sweet! Thanks. Glad it looks good to you |
Before I bounce, friendly reminder about the (separate but likely) problem with
|
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | minor | `v0.29.0` -> `v0.30.0` | --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.30.0`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.30.0) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.29.0...v0.30.0) #### What's Changed - fix: add missing Starlark dependency and introduce `bzl_test` by [@​cgrindel](https://togithub.com/cgrindel) in [https://github.com/bazelbuild/bazel-gazelle/pull/1413](https://togithub.com/bazelbuild/bazel-gazelle/pull/1413) - Upgrade rules_go and known imports by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1426](https://togithub.com/bazelbuild/bazel-gazelle/pull/1426) - Regenerate known imports from downgraded go_googleapis by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1429](https://togithub.com/bazelbuild/bazel-gazelle/pull/1429) - testdata with buildable Go pkg deep below by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1433](https://togithub.com/bazelbuild/bazel-gazelle/pull/1433) - language/go: add //go:embed all:<pattern> support by [@​mbicz](https://togithub.com/mbicz) in [https://github.com/bazelbuild/bazel-gazelle/pull/1432](https://togithub.com/bazelbuild/bazel-gazelle/pull/1432) - Fix `go mod download` output expectation for errors by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/bazel-gazelle/pull/1442](https://togithub.com/bazelbuild/bazel-gazelle/pull/1442) - Apply map_kind to existing rules as well as new ones by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/bazel-gazelle/pull/1425](https://togithub.com/bazelbuild/bazel-gazelle/pull/1425) - Ignore symlinks into Bazel output rather than relying on name by [@​cpsauer](https://togithub.com/cpsauer) in [https://github.com/bazelbuild/bazel-gazelle/pull/1384](https://togithub.com/bazelbuild/bazel-gazelle/pull/1384) - Use `short_path` for `go` in the wrapper by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1446](https://togithub.com/bazelbuild/bazel-gazelle/pull/1446) - feature: gazelle wrapper allows to pass environment variables by [@​manuelnaranjo](https://togithub.com/manuelnaranjo) in [https://github.com/bazelbuild/bazel-gazelle/pull/1438](https://togithub.com/bazelbuild/bazel-gazelle/pull/1438) - Update directive documentation by [@​moisesvega](https://togithub.com/moisesvega) in [https://github.com/bazelbuild/bazel-gazelle/pull/1454](https://togithub.com/bazelbuild/bazel-gazelle/pull/1454) - Update gazelle directive documenmtation. by [@​moisesvega](https://togithub.com/moisesvega) in [https://github.com/bazelbuild/bazel-gazelle/pull/1455](https://togithub.com/bazelbuild/bazel-gazelle/pull/1455) - Default Visibility extension overwrite on descent (fixes [#​1467](https://togithub.com/bazelbuild/bazel-gazelle/issues/1467)) by [@​dnathe4th](https://togithub.com/dnathe4th) in [https://github.com/bazelbuild/bazel-gazelle/pull/1472](https://togithub.com/bazelbuild/bazel-gazelle/pull/1472) - Allow keep to be explained by [@​stevebarrau](https://togithub.com/stevebarrau) in [https://github.com/bazelbuild/bazel-gazelle/pull/1447](https://togithub.com/bazelbuild/bazel-gazelle/pull/1447) - Respect repo_name in MODULE.bazel for load generation by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1463](https://togithub.com/bazelbuild/bazel-gazelle/pull/1463) - Add `.ijwb` to `.gitignore` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1478](https://togithub.com/bazelbuild/bazel-gazelle/pull/1478) - Use spaces instead of tabs in go_repositor_tools_srcs.bzl by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1479](https://togithub.com/bazelbuild/bazel-gazelle/pull/1479) - Run buildifier by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1480](https://togithub.com/bazelbuild/bazel-gazelle/pull/1480) - bzlmod: Test BCR test module on all platforms by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1481](https://togithub.com/bazelbuild/bazel-gazelle/pull/1481) - bzlmod: Allow overriding default Go module configuration by [@​seh](https://togithub.com/seh) in [https://github.com/bazelbuild/bazel-gazelle/pull/1456](https://togithub.com/bazelbuild/bazel-gazelle/pull/1456) - fix(bzlmod): apply go.sum sums after version resolution by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1477](https://togithub.com/bazelbuild/bazel-gazelle/pull/1477) - fix(bzlmod/go_deps): don't read go.sum for empty go.mod files by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1484](https://togithub.com/bazelbuild/bazel-gazelle/pull/1484) - feat(bzlmod): support go.mod replace directives by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1450](https://togithub.com/bazelbuild/bazel-gazelle/pull/1450) - README update mentioning gazelle-haskell-modules by [@​kczulko](https://togithub.com/kczulko) in [https://github.com/bazelbuild/bazel-gazelle/pull/1439](https://togithub.com/bazelbuild/bazel-gazelle/pull/1439) - Exclude `.ijwb` from repository tools srcs by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1490](https://togithub.com/bazelbuild/bazel-gazelle/pull/1490) - bzlmod: Fix interaction between replace and implicit upgrade check by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1492](https://togithub.com/bazelbuild/bazel-gazelle/pull/1492) #### New Contributors - [@​darist](https://togithub.com/darist) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1410](https://togithub.com/bazelbuild/bazel-gazelle/pull/1410) - [@​mbicz](https://togithub.com/mbicz) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1432](https://togithub.com/bazelbuild/bazel-gazelle/pull/1432) - [@​cpsauer](https://togithub.com/cpsauer) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1384](https://togithub.com/bazelbuild/bazel-gazelle/pull/1384) - [@​manuelnaranjo](https://togithub.com/manuelnaranjo) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1438](https://togithub.com/bazelbuild/bazel-gazelle/pull/1438) - [@​moisesvega](https://togithub.com/moisesvega) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1454](https://togithub.com/bazelbuild/bazel-gazelle/pull/1454) - [@​stevebarrau](https://togithub.com/stevebarrau) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1447](https://togithub.com/bazelbuild/bazel-gazelle/pull/1447) - [@​seh](https://togithub.com/seh) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1456](https://togithub.com/bazelbuild/bazel-gazelle/pull/1456) - [@​kczulko](https://togithub.com/kczulko) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1439](https://togithub.com/bazelbuild/bazel-gazelle/pull/1439) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.29.0...v0.30.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/cgrindel/bazel-starlib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4yMy4zIiwidXBkYXRlZEluVmVyIjoiMzUuMjMuMyJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | minor | `v0.29.0` -> `v0.30.0` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.30.0`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.30.0) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.29.0...v0.30.0) #### What's Changed - fix: add missing Starlark dependency and introduce `bzl_test` by [@​cgrindel](https://togithub.com/cgrindel) in [https://github.com/bazelbuild/bazel-gazelle/pull/1413](https://togithub.com/bazelbuild/bazel-gazelle/pull/1413) - Upgrade rules_go and known imports by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1426](https://togithub.com/bazelbuild/bazel-gazelle/pull/1426) - Regenerate known imports from downgraded go_googleapis by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1429](https://togithub.com/bazelbuild/bazel-gazelle/pull/1429) - testdata with buildable Go pkg deep below by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1433](https://togithub.com/bazelbuild/bazel-gazelle/pull/1433) - language/go: add //go:embed all:<pattern> support by [@​mbicz](https://togithub.com/mbicz) in [https://github.com/bazelbuild/bazel-gazelle/pull/1432](https://togithub.com/bazelbuild/bazel-gazelle/pull/1432) - Fix `go mod download` output expectation for errors by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/bazel-gazelle/pull/1442](https://togithub.com/bazelbuild/bazel-gazelle/pull/1442) - Apply map_kind to existing rules as well as new ones by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/bazel-gazelle/pull/1425](https://togithub.com/bazelbuild/bazel-gazelle/pull/1425) - Ignore symlinks into Bazel output rather than relying on name by [@​cpsauer](https://togithub.com/cpsauer) in [https://github.com/bazelbuild/bazel-gazelle/pull/1384](https://togithub.com/bazelbuild/bazel-gazelle/pull/1384) - Use `short_path` for `go` in the wrapper by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1446](https://togithub.com/bazelbuild/bazel-gazelle/pull/1446) - feature: gazelle wrapper allows to pass environment variables by [@​manuelnaranjo](https://togithub.com/manuelnaranjo) in [https://github.com/bazelbuild/bazel-gazelle/pull/1438](https://togithub.com/bazelbuild/bazel-gazelle/pull/1438) - Update directive documentation by [@​moisesvega](https://togithub.com/moisesvega) in [https://github.com/bazelbuild/bazel-gazelle/pull/1454](https://togithub.com/bazelbuild/bazel-gazelle/pull/1454) - Update gazelle directive documenmtation. by [@​moisesvega](https://togithub.com/moisesvega) in [https://github.com/bazelbuild/bazel-gazelle/pull/1455](https://togithub.com/bazelbuild/bazel-gazelle/pull/1455) - Default Visibility extension overwrite on descent (fixes [#​1467](https://togithub.com/bazelbuild/bazel-gazelle/issues/1467)) by [@​dnathe4th](https://togithub.com/dnathe4th) in [https://github.com/bazelbuild/bazel-gazelle/pull/1472](https://togithub.com/bazelbuild/bazel-gazelle/pull/1472) - Allow keep to be explained by [@​stevebarrau](https://togithub.com/stevebarrau) in [https://github.com/bazelbuild/bazel-gazelle/pull/1447](https://togithub.com/bazelbuild/bazel-gazelle/pull/1447) - Respect repo_name in MODULE.bazel for load generation by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1463](https://togithub.com/bazelbuild/bazel-gazelle/pull/1463) - Add `.ijwb` to `.gitignore` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1478](https://togithub.com/bazelbuild/bazel-gazelle/pull/1478) - Use spaces instead of tabs in go_repositor_tools_srcs.bzl by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1479](https://togithub.com/bazelbuild/bazel-gazelle/pull/1479) - Run buildifier by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1480](https://togithub.com/bazelbuild/bazel-gazelle/pull/1480) - bzlmod: Test BCR test module on all platforms by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1481](https://togithub.com/bazelbuild/bazel-gazelle/pull/1481) - bzlmod: Allow overriding default Go module configuration by [@​seh](https://togithub.com/seh) in [https://github.com/bazelbuild/bazel-gazelle/pull/1456](https://togithub.com/bazelbuild/bazel-gazelle/pull/1456) - fix(bzlmod): apply go.sum sums after version resolution by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1477](https://togithub.com/bazelbuild/bazel-gazelle/pull/1477) - fix(bzlmod/go_deps): don't read go.sum for empty go.mod files by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1484](https://togithub.com/bazelbuild/bazel-gazelle/pull/1484) - feat(bzlmod): support go.mod replace directives by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1450](https://togithub.com/bazelbuild/bazel-gazelle/pull/1450) - README update mentioning gazelle-haskell-modules by [@​kczulko](https://togithub.com/kczulko) in [https://github.com/bazelbuild/bazel-gazelle/pull/1439](https://togithub.com/bazelbuild/bazel-gazelle/pull/1439) - Exclude `.ijwb` from repository tools srcs by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1490](https://togithub.com/bazelbuild/bazel-gazelle/pull/1490) - bzlmod: Fix interaction between replace and implicit upgrade check by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1492](https://togithub.com/bazelbuild/bazel-gazelle/pull/1492) #### New Contributors - [@​darist](https://togithub.com/darist) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1410](https://togithub.com/bazelbuild/bazel-gazelle/pull/1410) - [@​mbicz](https://togithub.com/mbicz) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1432](https://togithub.com/bazelbuild/bazel-gazelle/pull/1432) - [@​cpsauer](https://togithub.com/cpsauer) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1384](https://togithub.com/bazelbuild/bazel-gazelle/pull/1384) - [@​manuelnaranjo](https://togithub.com/manuelnaranjo) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1438](https://togithub.com/bazelbuild/bazel-gazelle/pull/1438) - [@​moisesvega](https://togithub.com/moisesvega) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1454](https://togithub.com/bazelbuild/bazel-gazelle/pull/1454) - [@​stevebarrau](https://togithub.com/stevebarrau) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1447](https://togithub.com/bazelbuild/bazel-gazelle/pull/1447) - [@​seh](https://togithub.com/seh) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1456](https://togithub.com/bazelbuild/bazel-gazelle/pull/1456) - [@​kczulko](https://togithub.com/kczulko) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1439](https://togithub.com/bazelbuild/bazel-gazelle/pull/1439) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.29.0...v0.30.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/kreempuff/rules_unreal_engine). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4yMy4zIiwidXBkYXRlZEluVmVyIjoiMzUuNDAuMCJ9-->
I just found this because I was wondering why "external" is not followed anymore. I am happy that I no longer need to exclude all the directories, but I would still like to follow some symlinks. It seems like the I propose we follow a symlink if it is as part of the |
Example: If I put
I expect gazelle to look into the external directory. This becomes useful with #1573 where we can actually resolve targets in external repositories. |
Hi wonderful Bazelers,
This PR is somewhere between a bug fix and a feature. It generalizes existing functionality that is missing some cases.
It's focused on the walk package's auto-ignoring of symlinks.
Right now, Gazelle will happily traverse symlinks into bazel's output base, so long as they don't start with bazel-*. This is a problem because IDE adapters often create such symlinks. I know Tulsi does, for example, and a user just reported this issue over at a tool I maintain. Since I could see where the issue was, I figured I'd take a quick shot at proposing a fix, despite not currently being a Gazelle or go user. (So please have patience with me :) It seemed worth fixing the default since Gazelle could write a considerable number of files before the user realized what was going on.
This PR also makes progress towards fixing #168, removing the dependence on a bazel-* prefix for the ignoring convenience symlinks, instead ignoring a more general class. However, a full fix to #168 will require more work and wasn't the intent; this is an incremental, separate improvement, just written in such a way as to set the stage for future improvements there. I'll save state into that issue, but note that the output_base resolving code will likely be swapped out then.
I should also note: The deleted comment in repo.go is intentional. The current behavior of --symlink_prefix has changed to also rename bazel-out. I'm also skeptical that the neighboring, similar, symlink resolution code will work on windows; hence the use of Dir in my implementation. In my (python) experience, .. traverses back out of a Windows junction the way it came, as opposed to getting the parent of the symlinks destination, as on posix. But this problematic code will get removed when #168 gets fixed some day.
One final note: The reordering of the default behavior behind the user override is also intentional. It's more consistent with the other automatic defaults and gives the user an escape hatch if they really want it.
Thanks for reading!
Chris
(ex-Googler)
Edit: Now fixes #168