Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build the tutorial on macOS Sierra #944

Closed
franckrasolo opened this issue Jun 13, 2019 · 7 comments
Closed

Cannot build the tutorial on macOS Sierra #944

franckrasolo opened this issue Jun 13, 2019 · 7 comments

Comments

@franckrasolo
Copy link

franckrasolo commented Jun 13, 2019

Describe the bug
Following the tutorial at commit 6d9d065, building everything from the tutorial workspace on macOS Sierra, I get the following error:

$ bazel build @io_tweag_rules_haskell_tutorial//... \
    --incompatible_depset_union=false \
    --verbose_failures \
    --sandbox_debug
[...]
INFO: Analyzed target @io_tweag_rules_haskell_tutorial//lib:booleans (28 packages loaded, 576 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell_tutorial/lib/BUILD.bazel:6:1: HaskellRegisterPackage ../io_tweag_rules_haskell_tutorial/lib/link-config-booleans/link-config-booleans.conf failed (Exit 126) sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/sandbox/darwin-sandbox/2/execroot/io_tweag_rules_haskell && \
  exec env - \
    TMPDIR=/var/folders/9s/blggq5hs5px7rr778b1px8lr0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/sandbox/darwin-sandbox/2/sandbox.sb /var/tmp/_bazel_fraz/install/9be5dadb2a2b38082dbe665bf2db6464/_embedded_binaries/process-wrapper '--timeout=0' '--kill_delay=15' external/io_tweag_rules_haskell_ghc_darwin_amd64/bin/ghc-pkg recache '--package-db=bazel-out/darwin-fastbuild/bin/external/io_tweag_rules_haskell_tutorial/lib/link-config-booleans' -v0 --no-expand-pkgroot): sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/sandbox/darwin-sandbox/2/execroot/io_tweag_rules_haskell && \
  exec env - \
    TMPDIR=/var/folders/9s/blggq5hs5px7rr778b1px8lr0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/sandbox/darwin-sandbox/2/sandbox.sb /var/tmp/_bazel_fraz/install/9be5dadb2a2b38082dbe665bf2db6464/_embedded_binaries/process-wrapper '--timeout=0' '--kill_delay=15' external/io_tweag_rules_haskell_ghc_darwin_amd64/bin/ghc-pkg recache '--package-db=bazel-out/darwin-fastbuild/bin/external/io_tweag_rules_haskell_tutorial/lib/link-config-booleans' -v0 --no-expand-pkgroot)
external/io_tweag_rules_haskell_ghc_darwin_amd64/bin/ghc-pkg: line 11: /lib/bin/ghc-pkg: No such file or directory
external/io_tweag_rules_haskell_ghc_darwin_amd64/bin/ghc-pkg: line 11: exec: /lib/bin/ghc-pkg: cannot execute: No such file or directory
Target @io_tweag_rules_haskell_tutorial//lib:booleans failed to build
INFO: Elapsed time: 184.650s, Critical Path: 0.10s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

To Reproduce

git clone https://github.com/tweag/rules_haskell.git && cd rules_haskell
git checkout 6d9d0651fd1e0047d1dc27aa26c86ba0cb216fc8

bazel build @io_tweag_rules_haskell_tutorial//... \
    --incompatible_depset_union=false \
    --verbose_failures \
    --sandbox_debug

Expected behavior
Bazel should build the tutorial workspace successfully.

Environment

  • OS name + version: macOS Sierra 10.12.6
  • Bazel version: 0.26.1 (Homebrew)
$ bazel version
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Build label: 0.26.1
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jun 6 11:08:11 2019 (1559819291)
Build timestamp: 1559819291
Build timestamp as int: 1559819291

$ brew info bazel
bazelbuild/tap/bazel: stable 0.26.1
Fast, scalable, multi-language and extensible build system
https://bazel.build/
/usr/local/Cellar/bazel/0.26.1 (6 files, 54.6MB) *
  Built from source on 2019-06-12 at 14:51:53
From: https://github.com/bazelbuild/homebrew-tap/blob/master/Formula/bazel.rb

Additional context
Inspecting the generated script below, it seems that DISTDIR was not successfully initialised using BSD tools:

$ cat /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/sandbox/darwin-sandbox/2/execroot/io_tweag_rules_haskell/external/io_tweag_rules_haskell_ghc_darwin_amd64/bin/ghc-pkg

#!/bin/sh
exedir="$DISTDIR/lib/bin"
exeprog="ghc-pkg"
executablename="$exedir/$exeprog"
datadir="$DISTDIR/lib"
bindir="$DISTDIR/bin"
topdir="$DISTDIR/lib"
#!/bin/sh

PKGCONF="$topdir/package.conf.d"
exec "$executablename" --global-package-db "$PKGCONF" ${1+"$@"}

This might be related to #884, #855, #938, #939.

@franckrasolo
Copy link
Author

With --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs as suggested in #855, I get:

$ cd tutorial
$ bazel build @io_tweag_rules_haskell_tutorial//... --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs

Starting local Bazel server and connecting to it...
/nix/store/yi32h8x80yafjl2y97zgfzdzw6bd2i24-bazel-cc-toolchain
these paths will be fetched (123.48 MiB download, 1378.98 MiB unpacked):
  /nix/store/94wxjdk46ss2yb5xr25k06d1llwkbqvp-libffi-3.2.1-dev
  /nix/store/bscvmps4dn31jzz03y182d6qs0qff8j7-gmp-6.1.2-dev
  /nix/store/jgsw4jm45vzma6y79q879isqa1jdd5iy-ghc-8.6.5
  /nix/store/pjlv0yi0rrizn1nzdizh8w3x0hx9x5lw-ghc-8.6.5-doc
copying path '/nix/store/pjlv0yi0rrizn1nzdizh8w3x0hx9x5lw-ghc-8.6.5-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/bscvmps4dn31jzz03y182d6qs0qff8j7-gmp-6.1.2-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/94wxjdk46ss2yb5xr25k06d1llwkbqvp-libffi-3.2.1-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/jgsw4jm45vzma6y79q879isqa1jdd5iy-ghc-8.6.5' from 'https://cache.nixos.org'...
/nix/store/jgsw4jm45vzma6y79q879isqa1jdd5iy-ghc-8.6.5
ERROR: /private/var/tmp/_bazel_fraz/0edabef14e56bce999275d8dfbe13879/external/io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain/BUILD:20:1: @io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain//:toolchain-impl: invalid label '' in each branch in select expression of attribute 'locale_archive' in '_haskell_toolchain' rule (including '@io_tweag_rules_haskell//haskell/platforms:linux'): empty package-relative label
INFO: Call stack for the definition of repository 'remote_coverage_tools' which is a http_archive (rule definition at /private/var/tmp/_bazel_fraz/0edabef14e56bce999275d8dfbe13879/external/bazel_tools/tools/build_defs/repo/http.bzl:229:16):
 - /DEFAULT.WORKSPACE.SUFFIX:5:1
INFO: Repository 'remote_coverage_tools' used the following cache hits instead of downloading the corresponding file.
 * Hash 'cc470e529fafb6165b5be3929ff2d99b38429b386ac100878687416603a67889' for https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v1.0.zip
If the definition of 'remote_coverage_tools' was updated, verify that the hashes were also updated.
ERROR: /private/var/tmp/_bazel_fraz/0edabef14e56bce999275d8dfbe13879/external/io_tweag_rules_haskell/haskell/BUILD.bazel:65:1: Target '@io_tweag_rules_haskell//haskell:toolchain-libraries' depends on toolchain '@io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain//:toolchain-impl', which cannot be found: Target '@io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain//:toolchain-impl' contains an error and its package is in error'
ERROR: /private/var/tmp/_bazel_fraz/0edabef14e56bce999275d8dfbe13879/external/io_tweag_rules_haskell_tutorial/main/BUILD.bazel:9:1: Target '@io_tweag_rules_haskell_tutorial//main:demorgan' depends on toolchain '@io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain//:toolchain-impl', which cannot be found: Target '@io_tweag_rules_haskell_ghc_nixpkgs_haskell_toolchain//:toolchain-impl' contains an error and its package is in error'
ERROR: Analysis of target '@io_tweag_rules_haskell_tutorial//main:base' failed; build aborted: Cannot compute config conditions
INFO: Elapsed time: 90.926s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (24 packages loaded, 99 targets configured)

@mboes
Copy link
Member

mboes commented Jun 13, 2019

See #941 that was merged yesterday. You should not cd tutorial.

@franckrasolo
Copy link
Author

franckrasolo commented Jun 13, 2019

Thanks @mboes. With 5b0c9d9 from rules_haskell, I get:

$ bazel build @io_tweag_rules_haskell_tutorial//... --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs
Starting local Bazel server and connecting to it...
INFO: Call stack for the definition of repository 'go_sdk' which is a _go_host_sdk (rule definition at /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl:32:16):
 - /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl:38:5
 - /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/toolchain/toolchains.bzl:267:13
 - /Users/fraz/Projects/Bazel/rules_haskell/WORKSPACE:382:45
ERROR: An error occurred during the fetch of repository 'go_sdk':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 27
		_detect_host_sdk(ctx)
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 181, in _detect_host_sdk
		fail("Could not detect host go versio...")
Could not detect host go version
ERROR: While resolving toolchains for target @io_tweag_rules_haskell_tutorial//main:demorgan: invalid registered toolchain '@go_sdk//:go_android_386': no such package '@go_sdk//': Traceback (most recent call last):
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 27
		_detect_host_sdk(ctx)
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 181, in _detect_host_sdk
		fail("Could not detect host go versio...")
Could not detect host go version
ERROR: Analysis of target '@io_tweag_rules_haskell_tutorial//main:demorgan' failed; build aborted: invalid registered toolchain '@go_sdk//:go_android_386': no such package '@go_sdk//': Traceback (most recent call last):
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 27
		_detect_host_sdk(ctx)
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_bazel_rules_go/go/private/sdk.bzl", line 181, in _detect_host_sdk
		fail("Could not detect host go versio...")
Could not detect host go version
INFO: Elapsed time: 4.678s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (15 packages loaded, 18 targets configured)
    Fetching @local_config_cc; Restarting.
    Fetching @nixpkgs_cc_toolchain; fetching

@franckrasolo
Copy link
Author

In order to get the tutorial working without nix-shell,

  1. I created .bazelrc.local under rules_haskell as follows:
$ cat << EOF > .bazelrc.local

build --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs --incompatible_depset_union=false --verbose_failures --sandbox_debug
run   --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs

EOF
  1. I edited WORKSPACE to let Bazel download a Go SDK:
$ git diff WORKSPACE
diff --git a/WORKSPACE b/WORKSPACE
index 0c82809..ae0a2b2 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -379,7 +379,7 @@ go_rules_dependencies()

 # If Windows, ask Bazel to download a Go SDK. Otherwise use the nix-shell
 # provided GO SDK.
-go_register_toolchains() if is_windows else go_register_toolchains(go_version = "host")
+go_register_toolchains() # if is_windows else go_register_toolchains(go_version = "host")

 load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")

With the above in place, I am now able to proceed with the tutorial:

$ bazel build @io_tweag_rules_haskell_tutorial//...
INFO: Analyzed 3 targets (37 packages loaded, 795 targets configured).
INFO: Found 3 targets...
INFO: Elapsed time: 1.541s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action

$ bazel query @io_tweag_rules_haskell_tutorial//...
@io_tweag_rules_haskell_tutorial//main:demorgan
@io_tweag_rules_haskell_tutorial//main:base
@io_tweag_rules_haskell_tutorial//lib:booleans
Loading: 3 packages loaded

$ bazel run @io_tweag_rules_haskell_tutorial//main:demorgan
INFO: Analyzed target @io_tweag_rules_haskell_tutorial//main:demorgan (36 packages loaded, 795 targets configured).
INFO: Found 1 target...
Target @io_tweag_rules_haskell_tutorial//main:demorgan up-to-date:
  bazel-bin/external/io_tweag_rules_haskell_tutorial/main/demorgan
INFO: Elapsed time: 1.367s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from @io_tweag_rules_haskell_tutorial//main:demorgan
-----------------------------------------------------------------------------
True

Remarks
Building with --incompatible_depset_union=false is required due to:

$ bazel build @io_tweag_rules_haskell_tutorial//...

ERROR: /private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell_tutorial/lib/BUILD.bazel:6:1: in haskell_library rule @io_tweag_rules_haskell_tutorial//lib:booleans:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell_tutorial/lib/BUILD.bazel", line 6
		haskell_library(name = 'booleans')
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell/haskell/private/haskell_impl.bzl", line 443, in haskell_library_impl
		link_library_dynamic(hs, cc, dep_info, cc_info, <3 more arguments>)
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell/haskell/private/actions/link.bzl", line 353, in link_library_dynamic
		create_link_config(hs = hs, cc_info = cc_info, dynamic ..., <3 more arguments>)
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell/haskell/providers.bzl", line 333, in create_link_config
		write_package_conf(hs, conf_file, {"name": package_name...])})
	File "/private/var/tmp/_bazel_fraz/c919eb54a35f01b9fec4087382612d34/external/io_tweag_rules_haskell/haskell/providers.bzl", line 337, in write_package_conf
		cc_static_libs + cc_dynamic_libs
`+` operator on a depset is forbidden. See https://docs.bazel.build/versions/master/skylark/depsets.html for recommendations. Use --incompatible_depset_union=false to temporarily disable this check.
ERROR: Analysis of target '@io_tweag_rules_haskell_tutorial//lib:booleans' failed; build aborted: Analysis of target '@io_tweag_rules_haskell_tutorial//lib:booleans' failed; build aborted
INFO: Elapsed time: 0.182s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

@Profpatsch
Copy link
Contributor

We don’t support 0.26 officially yet (which is why we should implement #923).

The cd issue was solved yesterday (in #946), so one should cd into the tutorial to get the right WORKSPACE file.

The tutorial should not require nix to be installed, at all.

@mboes
Copy link
Member

mboes commented Aug 11, 2019

@franckrasolo we now support all the way up to the latest Bazel release, and as @Profpatsch pointed out, #946 fixes the cd behaviour. Could you perhaps give this another go so that we can close the ticket?

@Profpatsch
Copy link
Contributor

Everything related to the tutorial should work now. We can reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants