-
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
Allow artifacts (or maybe runfiles
?) to be marked non-symlinkable
#10299
Comments
I'm having a similar problem with python binaries. I have some packaging process outside bazel, which basically packages things from Of course, I can dereference symlinks before packaging, still, I find it quite scary these files are just symlinks, and would have hoped bazel would copy things during build time to ensure hermiticity of the artifacts. |
In general, the idea of copying files rather than symlinking them sounds pretty dangerous for performance. You could easily explode your disk usage with a quadratic number of copies. We do have a mode where instead of emitting symlinks, we emit just a manifest file that points back into the source and output trees. The language-specific runfiles libraries abstract over that so you can write scripts that are agnostic to how the runfiles are laid out. Maybe something there can be extended for the purpose you're describing. |
My use case is for writing stub entry points for |
Depending on how this feature were designed, there could still be a hazard whereby a downstream target aggregates your |
There is hardlinking, but that only works if output root and source root are on the same device, and it doesn't work for directories. |
I am also interested in this feature (and similar features), for similar reasons as the original request. I work on JS build tooling with a few other folks at my company, and we support >100 frontend JS developers. The general problem is that the JS ecosystem only occasionally acknowledges the existence of symlinks, and gets all the defaults wrong. E.g. the node.js default is to follow symlinks, and then resolve my last straw recently - I was debugging a build of storybook in bazel, which was using @storybook/addon-docs, which itself uses babel-loader, which was mis-resolving the @babel/preset-env to follow outside of our symlinks and then crashing because it needed the symlinked version of a dependency and had escaped the runfiles tree and so couldn't find it. A possible solution was to change the custom storybook preset which had used @storybook/addon-docs to pass babelOptions so that babel-loader could use anyhow some morals of that story:
anyhow we're likely going to figure out working copying into our system, whether it becomes a core bazel feature or not. the dev velocity of the alternative has proven over the last ~5.5 years to be too big of a handicap. |
For JS, I created and use http://github.com/rivethealth/rules_javascript which shims require.resolve, ESM, and fs module to behave nicely with symlinks. https://github.com/rivethealth/rules_javascript/blob/main/docs/module.md#solution |
Note that copying can be achieved today by using a rule that outputs a copied directory/files. Bazel will still create symlinks (or a manifest) for runfiles, but you can resolve it to the bazel-out location created by that rule and everything will work. |
copying to bazel-out can help. but wouldn't it then be possible for e.g. e.g. protobufjs has some code like |
It's always possible to find outside files (unless it's being used in a sandboxed build, but even then situation doesn't change). |
My suggestion is create a rule some_bin(
name = "bin0",
)
copy_bin(
name = "bin",
bin = ":bin0",
)
It's not efficient, but it's not really particularly less efficient than the proposal of building it into Bazel (and it could still use hard links, if that's an option you want). |
This would fix this particular issue as well encode/starlette#1083 (comment) where the used Python library is unable to deal with symlinks in the runfiles directory (accurately). |
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 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
I continue to hope for this feature every time I debug JavaScript rules. |
Description of the problem / feature request:
Node.js, a popular implementation of the MySpace theming language as a general-purpose programming environment, uses symlinks as part of its import resolution logic. This doesn't compose well with Bazel's use of symlinks in the execroot, especially the runfiles symlink forest.
It would be nice if certain parts of the runfiles tree could be marked "non-symlinkable", so that they always get written as regular files. I'm not sure whether this would be better at the
File
orrunfiles
level. I'm using library runfiles so the two are equivalent in my case.Feature requests: what underlying problem are you trying to solve with this feature?
Given a runfiles tree containing a crafted
node_modules/
directory, I'd like to have some files in there be symlinks (like today), and some be regular files. This would allow fine-grained control over the Node.js import resolver.The text was updated successfully, but these errors were encountered: