Rules_docker: Bazel 4.0.0 fails with 'nvalid escape sequence: \{' in push.bzl

Created on 21 Jan 2021  路  8Comments  路  Source: bazelbuild/rules_docker

I'm brushing off an old branch to try out bazel in a project, but I'm running into this error:

% bazelisk run //:gazelle
INFO: Invocation ID: ccbaff0e-f7d3-40b8-baab-1f647c88b702
ERROR: /home/msi/.cache/bazel/_bazel_msi/019d14d44ce04d4882c7ce8ed729dc39/external/io_bazel_rules_docker/container/push.bzl:34:28: invalid escape sequence: \{. You can enable unknown escape sequences by passing the flag --incompatible_restrict_string_escapes=false
...

Re-running with --incompatible_restrict_string_escapes=false does indeed make the problem go away.

(The offending line is return "%RUNFILES%\{}".format(runfile(ctx, f).replace("/", "\\")))

As I haven't updated the branch in quite a while nothing should've changed in the workspace. So I'm quite at a loss as to what may have caused this.

Most helpful comment

Can we release a new version of rules docker with #1675 and #1676 ?

All 8 comments

Aha! Turns out that bazelisk had changed from bazel 3.5.0 to 4.0.0 without making a big fuzz about it, which broke things.

Found out when I discovered differences between bazelisk version and the tag of the docker-image I pulled in CI (which still worked).

Fixed with echo 3.5.0 > .bazelversion in the project root.

Thanks for raising this, had exactly the same issue but instead of pinning Bazel to 3.7.2, I've instead modified .bazelrc to include:

run --incompatible_restrict_string_escapes=false

Bazel 4.0.0 works fine with rules_docker otherwise.

I stuck with 3.5.0, as that is the latest for which an official Docker image exists (see https://l.gcr.io/google/bazel).

Can we release a new version of rules docker with #1675 and #1676 ?

@or-shachar I took it upon myself to fork and release 0.15.1-alpha, which is all of the bugfixes up to this point, as well as replacing the core README to explain that the fork is just to create the much needed release:

https://github.com/dmayle/rules_docker/releases/tag/v0.15.1-alpha

Any release planned with the fixes for 4.0.0?

v0.16.0 has been released: https://github.com/bazelbuild/rules_docker/releases/tag/v0.16.0. Works for me now :tada:

This issue should be closed now 馃檪

Was this page helpful?
0 / 5 - 0 ratings