bazelbuild/bazel

Add `bazel init` to setup new workspaces

Open

#15,604 opened on 2022年6月1日

GitHub で見る
 (8 comments) (14 reactions) (0 assignees)Java (4,465 forks)batch import
P3help wantednot staleteam-OSStype: feature request

Repository metrics

Stars
 (25,384 stars)
PR merge metrics
 (平均マージ 22d 20h) (30d で 77 merged PRs)

説明

Description of the feature request:

Add a bazel init command that sets up a skeleton Bazel workspace for new projects. It could create WORKSPACE, BUILD.bazel, .bazelrc and maybe others, using a template that applies modern best practices.

The init command is popular in other tools. E.g.,

  • git init - create a new git repo
  • npm init - create a new npm package
  • poetry init - create a new Poetry (python) package
  • cargo init - create a new Cargo (rust) package

What underlying problem are you trying to solve with this feature?

New users often get tripped up by environment variables leaking into their builds and invalidating caches. The --incompatible_strict_action_env flag has existed for years and often solves the problem, but it is disabled by default due (I think) to not being compatible with many existing workspaces.

Arguably --incompatible_strict_action_env should be enabled by default, as well as a variety of other flags for correctness, performance, and dev experience detailed in this post. bazel init would offer a place to put these more recent, incompatible flags for use in new repos, and also provide a skeleton to help new users get started.

コントリビューターガイド