bazel: Building fails with "ERROR: Source forest creation failed: ... (File exists)"

In CLion 2017.2.2 with the Bazel plugin 2017.08.29.0.2 I import this sample workspace: https://github.com/danieldanciu/clion-bazel

First time I press Sync it says it succeeds, but the second time it does an incremental build and this error is printed: ERROR: Source forest creation failed: /private/var/tmp/_bazel_ab/fc7ea4530f9bdd4f1119eb797c96880e/execroot/__main__/bazel-clion-bazel (File exists).

You can see here the diff between the first run and the second, and the command which generated that error: https://gist.github.com/aleb/7f306b83d681f8283c2368c8f5a244c6/revisions

Command: /usr/local/bin/bazel build --tool_tag=ijwb:CLion --keep_going --experimental_build_event_binary_file=/var/folders/yd/nc6_vq355v352hm7_q86gfmw0000gn/T/intellij-bep-627b7f50-2b93-4f0d-bb2d-a5aca85aa48d --noexperimental_build_event_binary_file_path_conversion --curses=no --color=no --noexperimental_ui --noprogress_in_terminal_title --aspects=@intellij_aspect//:intellij_info.bzl%intellij_info_aspect --override_repository=intellij_aspect=/Users/ab/Library/Application Support/CLion2017.2/clwb/aspect --output_groups=intellij-info-cpp,intellij-info-py,intellij-info-generic -- //...:all //:all //bazel-clion-bazel:all

Further “Syncs” fail or succeed depending on whether it’s an incremental sync or a full sync, respectively.

Environment info

macOS 10.12.6 release 0.6.0-homebrew

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 29 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Ha I think in our case it’s because we have a directory called external at the top level checked into our repo. Removing that works around this

Something to do with .gitignore 🤷‍♂️ ? With https://github.com/wcurrie/bazel-kt-test I was seeing this error on the second sync:

Error:Source forest creation failed: /private/var/tmp/_bazel_wcurrie/1a27f38007016ddde30139a478158fc3/execroot/__main__/bazel-bazel-kt-test (File exists).

Until I added this to .gitignore:

bazel-*

The IJ plugin does execute git for Computing VCS working set...

Also seeing this issue, ERROR: Source forest creation failed: /home/jenkins/workspace/test/master/origin/master/execroot/__main__/.git (File exists)

$ bazel version
Build label: 0.11.0
Build target: bazel-out/k8-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 9 15:39:59 +50117 (1519402203599)
Build timestamp: 1519402203599
Build timestamp as int: 1519402203599

On ubuntu 16.04.3

I’m also seeing this with .../__main__/.#out.json on Mac OSX with Bazel version 0.11.0

$ bazel build [redacted]
INFO: Analysed target //[redacted] (93 packages loaded).
INFO: Found 1 target...
ERROR: Source forest creation failed: /private/var/tmp/_bazel_test/6f6133ece88806ce1513398e26791cf1/execroot/__main__/.#out.json (File exists)
INFO: Elapsed time: 24.107s
FAILED: Build did NOT complete successfully
$
$ bazel version
Build label: 0.11.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sun May 1 04:50:25 +50118 (1519414519825)
Build timestamp: 1519414519825
Build timestamp as int: 1519414519825

It works if I manually remove the file. However, I then have to manually remove that file before/after every build. bazel clean has the same affect: it must be run before/after every build.