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

Setup script example project fails on macOS #1016

Closed
symbiont-joseph-kachmar opened this issue Jul 29, 2019 · 9 comments · Fixed by #1017
Closed

Setup script example project fails on macOS #1016

symbiont-joseph-kachmar opened this issue Jul 29, 2019 · 9 comments · Fixed by #1017

Comments

@symbiont-joseph-kachmar
Copy link

symbiont-joseph-kachmar commented Jul 29, 2019

Description
The rules_haskell setup script creates an example project that does not successfully build on macOS using the GHC bindist toolchain.

Running bazel build //... in the example project created by the setup script results in the following error:

ERROR: /Users/jkachmar/src/bazel_test/WORKSPACE:19:1: file '@rules_haskell//haskell:repositories.bzl' does not contain symbol 'rules_haskell_dependencies'
ERROR: /Users/jkachmar/src/bazel_test/WORKSPACE:26:1: name 'rules_haskell_dependencies' is not defined
ERROR: /Users/jkachmar/src/bazel_test/WORKSPACE:30:1: name 'rules_haskell_toolchains' is not defined
ERROR: Error evaluating WORKSPACE file
ERROR: error loading package 'external': Package 'external' contains errors
INFO: Elapsed time: 0.096s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

When the version of rules_haskell in the WORKSPACE file is modified to point to the latest commit (06519dfd30ab78bf70bccc01afffde704b1677afed98bf669e023e8c1ea7e68e at the time of writing), the build gets much further but fails with a different error message:

INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
INFO: Found 2 targets...
ERROR: /Users/jkachmar/src/bazel_test/BUILD.bazel:29:1: HaskellRegisterPackage link-config-example/link-config-example.conf failed (Exit 126) ghc-pkg failed: error executing command external/rules_haskell_ghc_darwin_amd64/bin/ghc-pkg recache '--package-db=bazel-out/darwin-fastbuild/bin/link-config-example' -v0 --no-expand-pkgroot

Use --sandbox_debug to see verbose messages from the sandbox
external/rules_haskell_ghc_darwin_amd64/bin/ghc-pkg: line 11: /lib/bin/ghc-pkg: No such file or directory
external/rules_haskell_ghc_darwin_amd64/bin/ghc-pkg: line 11: exec: /lib/bin/ghc-pkg: cannot execute: No such file or directory
INFO: Elapsed time: 0.187s, Critical Path: 0.07s
INFO: 2 processes: 1 darwin-sandbox, 1 local.
FAILED: Build did NOT complete successfully

Steps To Reproduce

  1. Download and install Bazel v0.28.1
  2. Run curl https://haskell.build/start | sh in a fresh directory
  3. Verify that the generated WORKSPACE file specifies rules_haskell version 0.9.1
  4. Run bazel build //...
  5. Observe the first error message referenced above
  6. Modify the WORKSPACE file to point to rules_haskell commit 06519dfd30ab78bf70bccc01afffde704b1677afed98bf669e023e8c1ea7e68e
  7. Run bazel build //...
  8. Observe the second error message referenced above

Expected behavior
The setup script and initial bazel build //... should succeed in a fresh directory on macOS with the GHC bindist toolchain.

Environment - First Attempt

  • OS name + version: macOS
  • Bazel version: 0.28.1
  • Version of the rules: 0.9.1

Environment - Second Attempt

  • OS name + version: macOS
  • Bazel version: 0.28.1
  • Version of the rules: 06519dfd30ab78bf70bccc01afffde704b1677afed98bf669e023e8c1ea7e68e
@mboes
Copy link
Member

mboes commented Jul 29, 2019

I can reproduce. This appears to be happening because on Darwin the patching in https://github.com/tweag/rules_haskell/blame/master/haskell/ghc_bindist.bzl#L224-L232 needs to be modified.

@mboes
Copy link
Member

mboes commented Jul 29, 2019

@symbiont-joseph-kachmar Could you give #1017 a spin?

@mboes
Copy link
Member

mboes commented Jul 29, 2019

As noted in #884, we have CI jobs to cover {(linux, bindists), (linux, nixpkgs), (macos, nixpkgs)}, but not (macos, bindist). We better add it, because even simple and very old tools like sed can't be assumed to behave in exactly the same way on all platforms. :-/

@symbiont-joseph-kachmar
Copy link
Author

INFO: Analyzed 2 targets (9 packages loaded, 417 targets configured).
INFO: Found 2 targets...
INFO: From HaskellBuildBinary //:example:
clang: warning: no such sysroot directory: '__BAZEL_XCODE_SDKROOT__' [-Wmissing-sysroot]
INFO: Elapsed time: 149.669s, Critical Path: 1.34s
INFO: 7 processes: 6 darwin-sandbox, 1 local.
INFO: Build completed successfully, 8 total actions

Looks good, thanks!

@axman6
Copy link

axman6 commented Aug 2, 2019

Has this actually been fixed? I'm still getting the same issue with the the start script from master

 https://raw.githubusercontent.com/tweag/rules_haskell/master/start | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4030  100  4030    0     0  28896      0 --:--:-- --:--:-- --:--:-- 28992
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
.bazelrc
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Warning: a too new version of Bazel detected: v0.28.1.
         Recommended versions are from v0.27.0 to v0.28.x.
WORKSPACE and initial BUILD files created. To run Bazel and build the example:
> bazel run //:example
ERROR: /Users/amason/code/bazel-test/WORKSPACE:19:1: file '@rules_haskell//haskell:repositories.bzl' does not contain symbol 'rules_haskell_dependencies'
ERROR: /Users/amason/code/bazel-test/WORKSPACE:26:1: name 'rules_haskell_dependencies' is not defined
ERROR: /Users/amason/code/bazel-test/WORKSPACE:30:1: name 'rules_haskell_toolchains' is not defined
ERROR: Error evaluating WORKSPACE file
ERROR: Skipping '//:example': error loading package 'external': Package 'external' contains errors
WARNING: Target pattern parsing failed.
ERROR: error loading package 'external': Package 'external' contains errors
INFO: Elapsed time: 0.283s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

@mboes
Copy link
Member

mboes commented Aug 2, 2019

@axman6 that error is due to the start script assuming a master checkout of rules_haskell, but actually checking out the release. Older start scripts don't do this. It's just that we're deploying a version that is too new. You can alter the http_archive rule to checkout master like @symbiont-joseph-kachmar did, or you can track #1020, where @Profpatsch is solving this.

@axman6
Copy link

axman6 commented Aug 2, 2019

Can you help me out with what I'd need to change? I'm just trying to follow the tutorial and have no idea what's going on

@jkachmar
Copy link
Contributor

jkachmar commented Aug 2, 2019

@axman6 If you take a look at this snippet you can see the modifications I made to the WORKSPACE file generated in the startup script:

https://github.com/jkachmar/bazel_haskell_bindist_sandbox/blob/master/WORKSPACE#L3-L26

All I did was grab the commit hash where the changes were introduced and updated both the archive link and SHA256 hash to reflect these changes.

Otherwise you should be good to go; feel free to use that repository as a small reference, if it helps.

@axman6
Copy link

axman6 commented Aug 2, 2019

@jkachmar Thanks for that, that looks like it's working. Looking forward to playing with this

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

Successfully merging a pull request may close this issue.

4 participants