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

Add default platform value to #fetch_local_hash #12

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

SkyWriter
Copy link

@SkyWriter SkyWriter commented May 3, 2024

Not having this pulls in the wrong target value into gemset.nix for gems like so:

  coderay = {
    groups = ["default"];
    platforms = [];
    source = {
      remotes = ["https://rubygems.org"];
      sha256 = "0jvxqxzply1lwp7ysn94zjhh57vc14mcshw1ygw14ib8lhc00lyw";
      target = null;
      type = "gem";
    };
    targets = [];
    version = "1.1.3";
  };

Whereas it should be "ruby" instead:

  coderay = {
    groups = ["default"];
    platforms = [];
    source = {
      remotes = ["https://rubygems.org"];
      sha256 = "0jvxqxzply1lwp7ysn94zjhh57vc14mcshw1ygw14ib8lhc00lyw";
      target = "ruby";
      type = "gem";
    };
    targets = [];
    version = "1.1.3";
  };

Which results in a weird Nix shell error:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/6nfpbajyzwxq6wrhn20l13rhckhv26rc-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/6nfpbajyzwxq6wrhn20l13rhckhv26rc-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot coerce null to a string

One can reproduce it by:

$ nix flake init -t github:inscapist/ruby-nix/main
$ nix develop
$ echo 'source "https://rubygems.org"' > Gemfile
$ echo 'gem "pry"' >> Gemfile
$ bundle-lock
$ bundix
$ exit
$ nix develop

It may fail to reproduce on the first take since it seems to be caused by the branch fetching gems from the local store.

Not having this pulls in the wrong `target` value into gemset.nix for
gems like so:

  coderay = {
    groups = ["default"];
    platforms = [];
    source = {
      remotes = ["https://rubygems.org"];
      sha256 = "0jvxqxzply1lwp7ysn94zjhh57vc14mcshw1ygw14ib8lhc00lyw";
      target = null;
      type = "gem";
    };
    targets = [];
    version = "1.1.3";
  };

Whereas it should be "ruby" instead:

  coderay = {
    groups = ["default"];
    platforms = [];
    source = {
      remotes = ["https://rubygems.org"];
      sha256 = "0jvxqxzply1lwp7ysn94zjhh57vc14mcshw1ygw14ib8lhc00lyw";
      target = "ruby";
      type = "gem";
    };
    targets = [];
    version = "1.1.3";
  };

Which results in a weird Nix shell error:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/6nfpbajyzwxq6wrhn20l13rhckhv26rc-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/6nfpbajyzwxq6wrhn20l13rhckhv26rc-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot coerce null to a string
@SkyWriter
Copy link
Author

@inscapist , thank you for the wonderful work on this!

I am wondering if I am going in a right direction, and what else needs to be done for this PR to land?

@@ -111,6 +111,7 @@ def format_hash(hash)
end

def fetch_local_hash(spec)
platform = Gem::Platform::RUBY # default platform value
Copy link
Author

Choose a reason for hiding this comment

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

Ultimately, the issue seems to stem from this value remaining nil as never assigned for the gems that don't have platform dependent versions. This nil ended up being returned on https://github.com/inscapist/bundix/pull/12/files#diff-6c1d40dc95e017380bc6a0cd183b22f63fef5ac09356ae7ba8a288009a6355c7R128 .

I've amended it by pre-assigning the default value.

@inscapist
Copy link
Owner

sorry @SkyWriter I was swarmed in work! let me review this

Copy link
Owner

@inscapist inscapist left a comment

Choose a reason for hiding this comment

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

lgtm

@inscapist inscapist merged commit 8fba753 into inscapist:main Jun 29, 2024
@SkyWriter
Copy link
Author

No worries! Thank you for your hard work!

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

Successfully merging this pull request may close these issues.

None yet

2 participants