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

skyscope_linux/skyscope/import: line 4: /bin/skyscope: No such file or directory #85

Closed
Strum355 opened this issue May 4, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@Strum355
Copy link

Strum355 commented May 4, 2023

Describe the bug
Running skyscope on https://github.com/sourcegraph/sourcegraph after running bazel build //cmd/gitserver

To Reproduce

Append to WORKSPACE:

http_archive(
    name = "skyscope",
    sha256 = "2acf7b7f5bf3e66b83e1fac3aa6bcf71d173433ca6786f83d62fb5e9241fe7dc",
    urls = ["https://github.com/tweag/skyscope/releases/download/v0.2.6/skyscope.zip"],
)

load("@skyscope//:repository.bzl", "configure_skyscope")

configure_skyscope()

Run bazel shutdown && bazel build //cmd/gitserver && bazel run -- @skyscope//:import

Expected behavior
It works I guess 😅

Environment

  • OS name + version: NixOS using bazel (6.1.2) from the repos devshell
  • Version of the code: 0.2.6

Additional context
Output with SKYSCOPE_DEBUG set:

$ SKYSCOPE_DEBUG=1 bazel run -- @skyscope//:import
INFO: Build option --action_env has changed, discarding analysis cache.
INFO: Analyzed target @skyscope//:import (93 packages loaded, 350 targets configured).
INFO: Found 1 target...
Target @skyscope_linux//skyscope:import up-to-date:
  bazel-bin/external/skyscope_linux/skyscope/import
INFO: Elapsed time: 0.316s, Critical Path: 0.00s
INFO: 2 processes: 2 internal.
INFO: Build completed successfully, 2 total actions
INFO: Running command line: bazel-bin/external/skyscope_linux/skyscope/import
+++ find . -type d -name skyscope -printf '/home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/external/skyscope_linux/skyscope/import.runfiles/__main__/%P\n' -quit
++ RELEASE_DIR=
++ export SKYSCOPE_BINARY=/closure/skyscope
++ SKYSCOPE_BINARY=/closure/skyscope
++ /bin/skyscope import
/home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/external/skyscope_linux/skyscope/import: line 4: /bin/skyscope: No such file or directory
@benradf
Copy link
Contributor

benradf commented May 4, 2023

I had a few problems trying to reproduce this exactly (wrong hash for pnpm when running nix develop, and some issue running cargo for the crate_index repository). After a couple of tweaks to shell.nix and WORKSPACE I was able to get the same error.

It looks like an assumption I made about the current working directory for bazel run doesn't hold in this case:

.../execroot/__main__/bazel-out/k8-fastbuild/bin/external/skyscope_linux/skyscope/import.runfiles
├── __main__
├── MANIFEST
└── skyscope_linux
    └── skyscope

The working directory is actually __main__ and not import.runfiles as I assumed, so the skyscope directory is never found. Changing find . to find .. would fix it, but that feels like a hack so I'll take some time and come up with a proper solution (particularly as this same find command is causing issues on MacOS).

For now, you can download a release and unzip it manually if you want to give it a try. I just tested that on NixOS for the sourcegraph repository and it works.

@benradf benradf added the bug Something isn't working label May 4, 2023
@Strum355
Copy link
Author

Strum355 commented May 4, 2023

Thanks for the response! Curious what the diff was for getting devshell and bazel to work, it was a lot of work to get things working in the first place so itd be very interested to know what fell through the gaps (always good to have a fresh uncached system trying it out 😅)

@benradf
Copy link
Contributor

benradf commented May 5, 2023

If you change http_archive to get the latest v0.2.7 release, this should be fixed.

Curious what the diff was for getting devshell and bazel to work

One change was to the expected sha512 hash for pnpm. I'm not sure why it didn't match; maybe the archive changed and you still have the old one cached?

The other change wasn't so much a fix as a way to let me bazel run -- @skyscope//:import without this error:

[ben@nixos:~/git/sourcegraph]$ bazel query //...
Starting local Bazel server and connecting to it...
INFO: Repository crate_index instantiated at:
  /home/ben/git/sourcegraph/WORKSPACE:239:18: in <toplevel>
Repository rule crates_repository defined at:
  /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rules_rust/crate_universe/private/crates_repository.bzl:107:36: in <toplevel>
ERROR: An error occurred during the fetch of repository 'crate_index':
   Traceback (most recent call last):
	File "/home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rules_rust/crate_universe/private/crates_repository.bzl", line 45, column 28, in _crates_repository_impl
		repin = determine_repin(
	File "/home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rules_rust/crate_universe/private/generate_utils.bzl", line 372, column 21, in determine_repin
		result = execute(
	File "/home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rules_rust/crate_universe/private/common_utils.bzl", line 48, column 13, in execute
		fail(_EXECUTE_ERROR_MESSAGE.format(
Error in fail: Command [/home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/cargo-bazel, "query", "--lockfile", /home/ben/git/sourcegraph/docker-images/syntax-highlighter/Cargo.Bazel.lock, "--config", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/cargo-bazel.json, "--splicing-manifest", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/splicing_manifest.json, "--cargo", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo, "--rustc", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/rustc] failed with exit code 1.
STDOUT ------------------------------------------------------------------------
 
<snip>
 
ERROR: Error computing the main repository mapping: no such package '@crate_index//': Command [/home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/cargo-bazel, "query", "--lockfile", /home/ben/git/sourcegraph/docker-images/syntax-highlighter/Cargo.Bazel.lock, "--config", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/cargo-bazel.json, "--splicing-manifest", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/crate_index/splicing_manifest.json, "--cargo", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo, "--rustc", /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/rustc] failed with exit code 1.
STDOUT ------------------------------------------------------------------------
 
STDERR ------------------------------------------------------------------------
Error: Failed to run /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo to get its version
 
Caused by:
    No such file or directory (os error 2)
 
 checking cached actions

It looks like the interpreter for that cargo binary isn't right for NixOS:

[ben@nixos:~/git/sourcegraph]$ patchelf --print-interpreter /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo
/lib64/ld-linux-x86-64.so.2
 
[ben@nixos:~/git/sourcegraph]$ file $(!!)
file $(patchelf --print-interpreter /home/ben/.cache/bazel/_bazel_ben/7e1bda7c4ebab10dabb8c44c3c5f7d93/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/bin/cargo)
/lib64/ld-linux-x86-64.so.2: cannot open `/lib64/ld-linux-x86-64.so.2' (No such file or directory)

To work around this error I commented out this whole section of WORKSPACE. But of course, without crates_repositories pretty much nothing builds 😅

Anyway, thanks for reporting this issue. Let me know if you have any more problems with the new v0.2.7 release.

@Strum355
Copy link
Author

Strum355 commented May 5, 2023

It looks like the interpreter for that cargo binary isn't right for NixOS:

Thats weird, we're specifically using rust toolchain from rules_nixpkgs when the host is nixos for this reason 🤔 wonder is the order of when we load them the issue here, i may have only tested when we configured the toolchain before calling crates_index, but I digress.
Thanks for the fix, will test asap!

@benradf
Copy link
Contributor

benradf commented Dec 4, 2023

Should be resolved now that Skyscope is distributed as a single statically linked binary.

@benradf benradf closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants