github / semantic

Parsing, analyzing, and comparing source code across many languages
8.97k stars 452 forks source link

Document what to do when bazel emits a DEVELOPER_DIR error. #629

Closed philderbeast closed 3 years ago

philderbeast commented 4 years ago

With a clone of semantic at aca39e86683cf09071fc884313d7ec676f4c2c4b and bazel installed with the 3.3.1 installer the bazel build of semantic fails at @happy//:happy:

> sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.6
BuildVersion:   17G14019

> chmod +x bazel-3.3.1-installer-darwin-x86_64.sh
> ./bazel-3.3.1-installer-darwin-x86_64.sh --user
> bazel --version
bazel 3.3.1

> gh repo clone github/semantic
> cd semantic
> mkdir -p .bazel-cache/bazel-disk
> mkdir .bazel-cache/bazel-repo
> bazel build //...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: ce472874-35af-4e18-910a-69c151d6aaca
INFO: Analyzed 111 targets (80 packages loaded, 13809 targets configured).
INFO: Found 111 targets...
INFO: Deleting stale sandbox base /private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox
ERROR: /private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/external/happy/BUILD.bazel:3:21: HaskellCabalBinary @happy//:happy failed (Exit 1) cabal_wrapper failed: error executing command bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper exe:happy happy false external/happy/Setup.hs external/happy bazel-out/host/bin/external/happy/_install/happy.conf.d '' '--flags=' --

Use --sandbox_debug to see verbose messages from the sandbox
Error: DEVELOPER_DIR not set.
`cc_wrapper-python' failed in phase `C Compiler'. (Exit code: 250)
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/cabal_wrapper.py", line 192, in <module>
    [ "--package-db=" + package_database ], # This arg must come last.
  File "/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cabal_wrapper.runfiles/rules_haskell/haskell/cabal_wrapper.py", line 39, in run
    subprocess.run(cmd, check=True, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/external/rules_haskell_ghc_darwin_amd64/bin/runghc', '/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/external/happy/Setup.hs', 'configure', 'exe:happy', '--verbose=0', '--user', '--with-compiler=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/external/rules_haskell_ghc_darwin_amd64/bin/ghc', '--with-hc-pkg=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/external/rules_haskell_ghc_darwin_amd64/bin/ghc-pkg', '--with-ar=/usr/bin/ar', '--with-gcc=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python', '--with-strip=/usr/bin/strip', '--enable-deterministic', '--ghc-option=-pgma', '--ghc-option=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmc', '--ghc-option=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgml', '--ghc-option=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python', '--ghc-option=-pgmP', '--ghc-option=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional', '--ghc-option=-optc-fno-stack-protector', '--enable-relocatable', '--builddir=../../bazel-out/host/bin/external/tmp7puzo3l8', '--prefix=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install', '--libdir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/happy_iface', '--dynlibdir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/lib', '--libsubdir=', '--bindir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/bin', '--datadir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/happy_data', '--datasubdir=', '--haddockdir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/happy_haddock', '--htmldir=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/happy_haddock_html', '--package-db=clear', '--package-db=global', '--flags=', '--package-db=/private/var/tmp/_bazel_pdejoux/94f3f75068ea6739061b29cbd4ce2b4d/sandbox/darwin-sandbox/1/execroot/semantic/bazel-out/host/bin/external/happy/_install/happy.conf.d']' returned non-zero exit status 1.
INFO: Elapsed time: 14.822s, Critical Path: 3.12s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
patrickt commented 4 years ago

Ah, this is a problem with rules_haskell for macOS: as per here, the solution is to

export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1

in your .profile or location of choice. I’m rewriting the documentation about Bazel soon, and I’ll be sure to mention what to do if this occurs. Changing the title to reflect that.

philderbeast commented 4 years ago

Thanks, I can report that the bazel build completed when that environment variable was set.

patrickt commented 3 years ago

This is documented in docs/build.md. Closing.