bazel: "foo-bar is not a legal workspace name" error is reported on Bazel@HEAD

It seems that on Bazel@HEAD (e6cce762d846f3915b834c278fcb7fa0072ea530) hyphen character is not accepted any more in workspace name?

/** A collection of global Starlark build API functions that apply to WORKSPACE files. */
public class WorkspaceGlobals implements WorkspaceGlobalsApi {

  // Must start with a letter and can contain letters, numbers, and underscores
  private static final Pattern LEGAL_WORKSPACE_NAME = Pattern.compile("^\\p{Alpha}\\w*$");

Am I missing something? I see these errors:

 $ bazel build org.eclipse.jgit.ssh.apache/...
[...]
ERROR: /home/davido/.cache/bazel/_bazel_davido/e1ee1c2b4d81e57e5c4b6fbb219eece8/external/sshd-osgi/WORKSPACE:2:10: sshd-osgi is not a legal workspace name
ERROR: /home/davido/.cache/bazel/_bazel_davido/e1ee1c2b4d81e57e5c4b6fbb219eece8/external/sshd-sftp/WORKSPACE:2:10: sshd-sftp is not a legal workspace name
ERROR: /home/davido/.cache/bazel/_bazel_davido/e1ee1c2b4d81e57e5c4b6fbb219eece8/external/log-api/WORKSPACE:2:10: log-api is not a legal workspace name
INFO: Analyzed target //org.eclipse.jgit.ssh.apache:ssh-apache (28 packages loaded, 1339 targets configured).
INFO: Found 1 target...

The error is reported for the workspace line, e.g. in external/log-api/WORKSPACE:2:10:

# DO NOT EDIT: automatically generated WORKSPACE file for maven_jar rule
workspace(name = "log-api")

The build still succeeds.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I’m counting this as concensus.

  • I will shortly send a PR to allow dot in the name.
  • When it lands I will cherrypick into the next Bazel 3.5 rc.

It looks like the hyphen character has never been accepted in a workspace name.

Gerrit Code Review and JGit projects are using hyphen character in workspace names for years, started from Bazel 0.6.

See this CL: [1] from July 2018, quoting the commit message:

Bazel: Harmonize names of external repositories

Recent Bazel versions support dash character in external repository
names. Consistently use them with one exception: javax_inject. This is
needed to match the name in the rules_closure.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/183530