admin管理员组

文章数量:1293969

Is it possible to change or provide a custom path for execRoot in Bazel 7.4 with Bazelmod enabled ?

Or at least change the name of the main repository from _main to something else ?

My problem is, before enabling Bazelmod, Some files were available at path like:

/home/ssahoo/.cache/bazel/_bazel_ssahoo/eb5a6bd7163c3bba3080b98009823a76/execroot/<workspace_name>/APP_NAME/app/javascript/styles/charges/charges.sass

Now, after enabling Bzlmod, the path has changed to

/home/ssahoo/.cache/bazel/_bazel_ssahoo/eb5a6bd7163c3bba3080b98009823a76/execroot/_main/APP_NAME/app/javascript/styles/charges/charges.sass

So TS imports that are using path <workspace_name>/APP_NAME/app/javascript/styles/charges/charges.sass fails as there is no workspace_name in the path anymore.

I know I can use _main or a relative path here, but I am trying to avoid making changes to too many files. There are hundreds of files in this mono repo using such import paths. Can I use the module name or workspace name here instead of _main? Or are there any other solutions?

Is it possible to change or provide a custom path for execRoot in Bazel 7.4 with Bazelmod enabled ?

Or at least change the name of the main repository from _main to something else ?

My problem is, before enabling Bazelmod, Some files were available at path like:

/home/ssahoo/.cache/bazel/_bazel_ssahoo/eb5a6bd7163c3bba3080b98009823a76/execroot/<workspace_name>/APP_NAME/app/javascript/styles/charges/charges.sass

Now, after enabling Bzlmod, the path has changed to

/home/ssahoo/.cache/bazel/_bazel_ssahoo/eb5a6bd7163c3bba3080b98009823a76/execroot/_main/APP_NAME/app/javascript/styles/charges/charges.sass

So TS imports that are using path <workspace_name>/APP_NAME/app/javascript/styles/charges/charges.sass fails as there is no workspace_name in the path anymore.

I know I can use _main or a relative path here, but I am trying to avoid making changes to too many files. There are hundreds of files in this mono repo using such import paths. Can I use the module name or workspace name here instead of _main? Or are there any other solutions?

Share asked Feb 12 at 14:37 SajanSajan 1,9232 gold badges20 silver badges40 bronze badges 2
  • Maybe I'm misunderstanding your approach, but I'd say that those paths inside Bazel's cache are implementation details which you should never build upon. Instead, declare these dependencies explicitly. – Ulrich Eckhardt Commented Feb 12 at 14:46
  • @UlrichEckhardt I don't think those are implementation details, as those are packages defined by our code and referenced in the build. Anyway, we should have used relative paths(relative to the package not the workspace) instead of building on these but it's a very old project so I am not sure about the reason. – Sajan Commented Feb 12 at 15:01
Add a comment  | 

1 Answer 1

Reset to default 0

You can set a different output base directory (--output_base=... flag), but within that output base directory, you cannot change the main repository name; the name "_main" is hard-coded in bazel's BazelRuleClassProvider.java.

Using paths that contain a hard-coded repo name in your import statements seems fragile and generally a bad idea. For one thing, such import statements will break depending on whether your bzlmod module is the root module or a dependency of another module (even if you think you wouldn't need to use it as a dependency, it might be treated a dependency in some integration tests).

本文标签: Change execRoot in Bazel 7Stack Overflow