Open vmsp opened 2 years ago
I've the exact same issue on NixOS. Did you manage to find a fix or workaround?
Ok, I've found a workaround.
First the same issue seems to be happening here: https://github.com/NixOS/nixpkgs/pull/132708
So after changing the hash in the gemset.nix
I edited the Gemfile.lock
to remove the platform specific suffix.
- nokogiri (1.11.7-x86_64-linux)
+ nokogiri (1.11.7)
And it worked.
Ah, interesting. Yes, we recently updated our version of bundler
but have been having to delete that whole platform-specific section from the Gemfile.lock
every time we add a new gem
.
I'm having a very similar issue. Gemfile:
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 6.1', '>= 6.1.4.1'
shell.nix:
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
env = bundlerEnv {
name = "rails-template";
gemdir = ./.;
ruby = ruby_3_0;
};
in mkShell {
buildInputs = [ env env.wrappedRuby ];
}
Here's the trace:
error: hash mismatch in fixed-output derivation '/nix/store/45dir7w67m4bix82ix2r9dh0yh62ac00-nokogiri-1.12.5.gem.drv':
specified: sha256-CGjI0KFHkE1N7aqgWvXwZlby08Z+RDJgFxhVm/adbOo=
got: sha256-KyCQWUKsxYBpfIxJbQ0Wcqthf6y50w0Vazx2duZ5Auw=
error: 1 dependencies of derivation '/nix/store/nmy9l3sf834ibwkk2ppc4ggds8589vd3-ruby3.0.2-nokogiri-1.12.5.drv' failed to build
error: 1 dependencies of derivation '/nix/store/dim8jkkvbzacz03xk192431hmas15s4x-rails-template.drv' failed to build
error: build of '/nix/store/dim8jkkvbzacz03xk192431hmas15s4x-rails-template.drv', '/nix/store/dw9kgq7biihbgp933whidik9ihijb0ph-wrapped-ruby-rails-template.drv' failed
If I change the hash in gemset.nix
, this happens:
/nix/store/62v0v1c8gnxd77gfgkzml4ih68nqqrss-ruby-3.0.2/lib/ruby/3.0.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'mini_portile2' (~> 2.6.1) among 79 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/nix/store/rwznrv9bdy94s012risa9p150a9582z7-ruby3.0.2-racc-1.6.0/lib/ruby/gems/3.0.0:/nix/store/62v0v1c8gnxd77gfgkzml4ih68nqqrss-ruby-3.0.2/lib/ruby/gems/3.0.0:/nix/store/g2iizar0gic1bl31avf60dqdpnwzvmbs-ruby3.0.2-nokogiri-1.12.5/lib/ruby/gems/3.0.0' , execute `gem env` for more information
from /nix/store/62v0v1c8gnxd77gfgkzml4ih68nqqrss-ruby-3.0.2/lib/ruby/3.0.0/rubygems/dependency.rb:323:in `to_spec'
from /nix/store/62v0v1c8gnxd77gfgkzml4ih68nqqrss-ruby-3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
from extconf.rb:407:in `process_recipe'
from extconf.rb:900:in `<main>'
I'm kind of stuck here...
Looks like I've found an easy way to fix it! Simply run bundler config set force_ruby_platform true
and then bundler won't use platform specific gems anymore! No other actions needed.
bundler config set --local force_ruby_platform true
will make the change to your project local bundler config instead of system wide.
Also hit this issue. In my case platform-specific gem were likely not a factor. I'm was trying to setup a local jekyll environment for my github pages website.
Still hitting this. struggled for a while, and the things in this thread aren't working.
I changed the hash in gemset.nix to the correct one
Can this be explained to me please? gemset.nix
contains strings that get hashed, I think, not the hashes that start with sha256-
and end with =
.
For example, here's my gemset.nix
on nokogiri
nokogiri = {
dependencies = ["racc"];
groups = ["default" "development" "test"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1l5940v0s2yr4im2j7fjgi4k1cj21554cprinfqyg0jpwza6zcyw";
type = "gem";
};
version = "1.13.7";
};
Whereas the message, that I could presumably use to correct the sha256
field, looks like this:
error: hash mismatch in fixed-output derivation '/nix/store/vzx1dmrzwgfskl51xs2abfnr4gir96cv-nokogiri-1.13.7.gem.drv':
specified: sha256-3LNv1OdXguexszFfRkoJQrIwSXzSHSlqJNkLDTYgqdA=
got: sha256-bKHXUzNEGOdJvrm7aVFakGRRyav7mlsGCjZlBBm2EFI=
error: 1 dependencies of derivation '/nix/store/i4imakx9sl6nyqq0g4hx2jms11j90hb5-ruby2.7.6-nokogiri-1.13.7.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lz6l6il5zg37xcfvh6ilp24dzkb16wpr-guesstimate-backend-gems.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kmaxw9d6l3s1y0g80gnlwi1shxdis8l4-guesstimate-server-development-env.drv' failed to build
There are different ways to represent the hash.
Replace this:
sha256 = "1l5940v0s2yr4im2j7fjgi4k1cj21554cprinfqyg0jpwza6zcyw";
with this:
sha256 = "sha256-bKHXUzNEGOdJvrm7aVFakGRRyav7mlsGCjZlBBm2EFI=";
Or of course:
hash = "sha256-bKHXUzNEGOdJvrm7aVFakGRRyav7mlsGCjZlBBm2EFI=";
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
FYI: If you don't have a .bundle/config
yet you need to run BUNDLE_APP_CONFIG="$PWD/.bundle" bundler config set --local force_ruby_platform true
to apply @ymarkus / @jonknapp's fix.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/nokogiri-error-with-jekyll-on-nixos/23933/2
I just put BUNDLE_FORCE_RUBY_PLATFORM = "true";
in my call to mkShell. I had x86_64-linux
in my Gemfile.lock PLATFORMS
and it wouldn't work correctly until I removed that file then re-ran bundler. Then re-ran Bundix of course.
On an empty directory, I generated a new rails project and ran bundix.
Then I wrote a
shell.nix
.After running
nix-shell
, I got a wrong hash error for thenokogiri
gem.I changed the hash in
gemset.nix
to the correct one, re-rannix-shell
and I got a shell. But, all commands complain thatnokogiri
is missing and I'm stuck:Any idea of what I'm doing wrong?