Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

registry: add runtime inputs for openssl-sys #199

Merged
merged 2 commits into from
Jan 11, 2023
Merged

registry: add runtime inputs for openssl-sys #199

merged 2 commits into from
Jan 11, 2023

Conversation

figsoda
Copy link
Contributor

@figsoda figsoda commented Jan 10, 2023

cargo run didn't work for me without openssl in runtime inputs
didn't test with the registry, but adding runtime-inputs = ["openssl"] to package.metadata.riff fixes the issue for me

registry.json got emptied when I ran the script without jq in PATH
@cole-h
Copy link
Member

cole-h commented Jan 11, 2023

I just tested this on one of our macs and was unable to reproduce. Could you describe the circumstances under which cargo run didn't work? Logs would help as well.

@figsoda
Copy link
Contributor Author

figsoda commented Jan 11, 2023

I think this is only needed for linux (I don't think LD_LIBRARY_PATH is even a thing on darwin), I will update to only include this for linux

$ nix run . run cargo run
✓ 🦀 rust: cargo, openssl, pkg-config, rustc, rustfmt
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/riff`
target/debug/riff: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
The command you attempted to run was not found.
Try running it in a shell; for example:
        riff run -- sh -c 'cargo run'

@cole-h
Copy link
Member

cole-h commented Jan 11, 2023

....oh yeah. Derp 😆

Testing on a Linux box now.

@cole-h
Copy link
Member

cole-h commented Jan 11, 2023

Hmm... I tested this on a NixOS machine, a freshly-installed Steam Deck VM, and a freshly-installed Ubuntu VM, and I am still unable to reproduce. What distro are you seeing this on?

@figsoda
Copy link
Contributor Author

figsoda commented Jan 11, 2023

NixOS

@cole-h
Copy link
Member

cole-h commented Jan 11, 2023

Rereading the PR body, I notice you say you weren't using the registry. Does the issue persist if you do use the registry?

EDIT: Maybe I'm misreading, and you just didn't test if adding it to the registry fixes it...

@figsoda
Copy link
Contributor Author

figsoda commented Jan 11, 2023

by "didn't test with the registry" I meant I didn't test whether my change to the registry fixes the issue, however I was able to reproduce the issue on main, and this addition to Cargo.toml resolves the issue for me

[package.metadata.riff]
runtime-inputs = ["openssl"]

@cole-h
Copy link
Member

cole-h commented Jan 11, 2023

If you could, the output of RUST_LOG=riff=trace nix run . run cargo run where it fails would be useful. It would also be useful to know if this is only a problem with riff (somehow?), or if other openssl-sys-binding crates, like the git2 library have the same problem.

I'm hesitant to merge this because I'm not sure if this is the right solution (partially because I can't reproduce the issue in the first place).

@figsoda
Copy link
Contributor Author

figsoda commented Jan 11, 2023

I have tested with --offline and this patch does fix the issue if only I use .#riff instead of .#riffStatic, I will open a new issue for that

@Hoverbear
Copy link
Contributor

Hmm I wonder if the reason you're not seeing a reproduction @cole-h is because all those VMs have libssl.so.3 on them?

@figsoda
Copy link
Contributor Author

figsoda commented Jan 11, 2023

$ RUST_LOG=riff=trace nix run .#riff run cargo run
  2023-01-11T20:24:27.554847Z DEBUG riff::flake_generator: Project directory is '/home/figsoda/riff'.
    at src/flake_generator.rs:24
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.555095Z DEBUG riff::dev_env: Adding Cargo dependencies...
    at src/dev_env.rs:79
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.555111Z TRACE riff::dev_env: Running, command: "cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/figsoda/riff/Cargo.toml"
    at src/dev_env.rs:91
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

Running `cargo metadata` 🥁♩                                                                                                                                                   
  2023-01-11T20:24:27.575024Z TRACE riff::dependency_registry: Fetching new registry data from https://registry.riff.determinate.systems/riff-registry.json
    at src/dependency_registry/mod.rs:90

  2023-01-11T20:24:27.680717Z DEBUG riff::dependency_registry: Refreshed remote registry into XDG cache, path: /home/figsoda/.cache/riff/registry.json.new1746617
    at src/dependency_registry/mod.rs:140

  2023-01-11T20:24:27.680929Z DEBUG riff::dependency_registry: Renamed new registry to replace cached registry, new: /home/figsoda/.cache/riff/registry.json.new1746617, curren
t: /home/figsoda/.cache/riff/registry.json
    at src/dependency_registry/mod.rs:149

  2023-01-11T20:24:27.753875Z DEBUG riff::dev_env: Cache freshness, fresh: true
    at src/dev_env.rs:135
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.753938Z DEBUG riff::dev_env: Detected known crate information, package_name: core-foundation-sys, build-inputs: , environment-variables: , runtime-inputs
: 
    at src/dev_env.rs:143
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.753958Z DEBUG riff::dev_env: Detected known crate information, package_name: openssl-sys, build-inputs: openssl, environment-variables: , runtime-inputs:
 
    at src/dev_env.rs:143
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.753971Z DEBUG riff::dev_env: Detected known crate information, package_name: pkg-config, build-inputs: pkg-config, environment-variables: , runtime-input
s: 
    at src/dev_env.rs:143
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.753984Z DEBUG riff::dev_env: Detected `package.metadata.riff` in `Crate.toml`, package: riff, build-inputs: , environment-variables: , runtime-inputs: 
    at src/dev_env.rs:163
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.753995Z DEBUG riff::dev_env: Detected known crate information, package_name: security-framework-sys, build-inputs: , environment-variables: , runtime-inp
uts: 
    at src/dev_env.rs:143
    in riff::dev_env::add_deps_from_cargo with project_dir: /home/figsoda/riff
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

✓ 🦀 rust: cargo, openssl, pkg-config, rustc, rustfmt
  2023-01-11T20:24:27.773965Z TRACE riff::telemetry: Sending telemetry data to https://registry.riff.determinate.systems/telemetry, data: Telemetry { distinct_id: Some(Secret(
[REDACTED riff::telemetry::DistinctId])), system_os: "linux", system_arch: "x86_64", os_release_name: Some("NixOS"), os_release_version_id: Some("23.05"), riff_version: "1.0.2
", nix_version: Some("nix (Nix) 2.12.0"), is_tty: true, subcommand: Some("run"), detected_languages: {Rust}, in_ci: false }
    at src/telemetry.rs:121
    in riff::telemetry::send
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.929498Z DEBUG riff::telemetry: Sent telemetry data to https://registry.riff.determinate.systems/telemetry, telemetry: Telemetry { distinct_id: Some(Secre
t([REDACTED riff::telemetry::DistinctId])), system_os: "linux", system_arch: "x86_64", os_release_name: Some("NixOS"), os_release_version_id: Some("23.05"), riff_version: "1.0
.2", nix_version: Some("nix (Nix) 2.12.0"), is_tty: true, subcommand: Some("run"), detected_languages: {Rust}, in_ci: false }
    at src/telemetry.rs:129
    in riff::telemetry::send
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.929561Z TRACE riff::flake_generator: Generated 'flake.nix':
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  outputs = { self, nixpkgs }:
    let
      nameValuePair = name: value: { inherit name value; };
      genAttrs = names: f: builtins.listToAttrs (map (n: nameValuePair n (f n)) names);
      allSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];

      forAllSystems = f: genAttrs allSystems (system: f rec {
        inherit system;
        pkgs = import nixpkgs { inherit system; };
        lib = pkgs.lib;
      });
    in
    {
      devShells = forAllSystems ({ system, pkgs, ... }: {
        default = with pkgs;
          stdenv.mkDerivation {
            name = "riff-shell";
            buildInputs = [
              bashInteractive
              cargo pkg-config rustc rustfmt openssl
            ] ++ lib.optionals (stdenv.isDarwin) [
              libiconv
            ];

            

            
          };
      });

      # Compatibility with older Nix installations that don't check for `devShells.<arch>.default` first.
      devShell = forAllSystems ({ system, ... }: self.devShells.${system}.default);
  };
}

    at src/flake_generator.rs:82
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:27.929874Z TRACE riff::flake_generator: Running, command: "nix" "flake" "lock" "--extra-experimental-features" "flakes nix-command" "-L" "path:///tmp/.tmpgt
bIsX"
    at src/flake_generator.rs:103
    in riff::flake_generator::generate_flake_from_project_dir with project_dir: None, offline: false

  2023-01-11T20:24:28.184449Z TRACE riff::nix_dev_env: Running, command: "nix" "print-dev-env" "--json" "--extra-experimental-features" "flakes nix-command" "-L" "path:///tmp/
.tmpgtbIsX"
    at src/nix_dev_env.rs:48

   Compiling riff v1.0.2 (/home/figsoda/riff)
    Finished dev [unoptimized + debuginfo] target(s) in 2.99s
     Running `target/debug/riff`
target/debug/riff: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
The command you attempted to run was not found.
Try running it in a shell; for example:
        riff run -- sh -c 'cargo run'
$ ldd target/debug/riff
        linux-vdso.so.1 (0x00007ffec4afb000)
        libssl.so.3 => not found
        libcrypto.so.3 => not found
        libgcc_s.so.1 => /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/libgcc_s.so.1 (0x00007fccc9fef000)
        libm.so.6 => /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/libm.so.6 (0x00007fccc9f0f000)
        libc.so.6 => /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/libc.so.6 (0x00007fccc8a00000)
        /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib/ld-linux-x86-64.so.2 => /nix/store/ayfr5l52xkqqjn3n4h9jfacgnchz1z7s-glibc-2.35-224/lib64/ld-linux-x86-64
.so.2 (0x00007fccca00b000)

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh...! Yeah, okay, this seems fine then. I guess this is really all we can do. Thanks for bearing with me 😅

@cole-h cole-h merged commit 92690a7 into DeterminateSystems:main Jan 11, 2023
@figsoda figsoda deleted the openssl branch January 11, 2023 20:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants