Skip to content

"Could not find nokogiri..." when starting a new Rails project on macOS 11.4 #88

@vmsp

Description

@vmsp

On an empty directory, I generated a new rails project and ran bundix.

nix-shell \
  -p "ruby_3_0.withPackages (ps: with ps; [ rails ])" \
  -p bundix \
  --run "rails new . && bundle lock && bundix --ruby=ruby_3_0"

Then I wrote a shell.nix.

with (import <nixpkgs> {});
let
  ruby = ruby_3_0;
  gems = bundlerEnv {
    name = "project-bundler-env";
    inherit ruby;
    gemdir = ./.;
  };
in mkShell { packages = [ gems gems.wrappedRuby ]; }

After running nix-shell, I got a wrong hash error for the nokogiri gem.

trying https://rubygems.org/gems/nokogiri-1.11.7.gem
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9134k  100 9134k    0     0  9330k      0 --:--:-- --:--:-- --:--:-- 9320k
hash mismatch in fixed-output derivation '/nix/store/a35hgacdgwh9a52mx6ssf0ijb60axkcn-nokogiri-1.11.7.gem':
  wanted: sha256:09gvjipcs9yq3hdxk1cvyjmkrsykg2y6vmcyhr36bcmcpb3xjqc7
  got:    sha256:1vrn31385ix5k9b0yalnlzv360isv6dincbcvi8psllnwz4sjxj9
cannot build derivation '/nix/store/rn68g11q177bvb95s5bps2vxki8p5lsx-ruby3.0.2-nokogiri-1.11.7.drv': 1 dependencies couldn't be built

I changed the hash in gemset.nix to the correct one, re-ran nix-shell and I got a shell. But, all commands complain that nokogiri is missing and I'm stuck:

$ rails --help
Warning: the running version of Bundler (2.2.20) is older than the version that created the lockfile (2.2.22). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.2.22`.
/nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/spec_set.rb:95:in `block in materialize': Could not find nokogiri-1.11.7-x86_64-darwin in any of the sources (Bundler::GemNotFound)
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/spec_set.rb:90:in `map!'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/spec_set.rb:90:in `materialize'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/definition.rb:189:in `specs'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/definition.rb:258:in `specs_for'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/definition.rb:240:in `requested_specs'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/runtime.rb:91:in `block in definition_method'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/runtime.rb:20:in `setup'
	from /nix/store/9jd5clm6bgqiyxpnlchr4iqm9n490kk4-bundler-2.2.20/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler.rb:149:in `setup'
	from /nix/store/p8wa7vvcjq5rxl56rr8wmbgmrfq8r6z2-oioi/bin/rails:18:in `<main>'

Any idea of what I'm doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions