Unexpected gem version after pinning
After pinning sass-embedded to v1.78.0 in my Gemfile, accordingly updating my Gemfile.lock and my gemset.nix, and entering my ruby-nix environment, I observe sass v1.80.5 being present despite there being no references to that version anywhere in the lock file or gemset.
The project in question is a jekyll blog using a local gem (hence why I ended up here), but I've been able to reproduce the behavior with this jekyll starter kit. It serves as a good example as the Jekyll dev server shows Sass color function deprecation warnings that were only introduced in v1.79.0 and import deprecation warnings that were only introduced in v1.80.0.
Reproduction:
- Clone or download and unzip v9.2.1 of hydejack-starter-kit
- Pin
sass-embeddedin the Gemfile:echo 'gem "sass-embedded", "~> 1.78.0"' >> Gemfile - Create Gemfile.lock and gemset.nix, ignoring platform-specific gems:
nix run nixpkgs#bundler -- config set --local force_ruby_platform true export BUNDLE_PATH=vendor/bundle nix run nixpkgs#bundler -- lock nix run github:inscapist/bundix -- lock - Add the following flake.nix:
{ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; ruby-nix.url = "github:inscapist/ruby-nix"; }; outputs = { self, nixpkgs, ruby-nix, }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; rubyNix = ruby-nix.lib pkgs; rubyNixEnv = (rubyNix { name = "example"; ruby = pkgs.ruby; gemset = ./gemset.nix; }) .env; bundixEnv = pkgs.bundlerEnv { name = "example"; ruby = pkgs.ruby; gemdir = ./.; }; in { devShells.${system} = { default = pkgs.mkShell { packages = [ rubyNixEnv ]; }; bundix-example = pkgs.mkShell { packages = [ bundixEnv ]; }; basic-example = pkgs.mkShell { packages = [ pkgs.ruby ]; }; }; }; } - After entering the default dev shell (
nix develop) which usesruby-nix, observe the sass bin version and the deprecation warning when running jekyll:sass --version # 1.80.5 jekyll serve # Sass deprecation notices observed - After entering the "bundix" dev shell (
nix develop .#bundix-example) which uses the defaultbundlerEnvimplementation, observe the sass bin version and the deprecation warning when running jekyll:sass --version # 1.80.5 jekyll serve # Sass deprecation notices observed - After entering the "basic" dev shell (
nix develop .#basic-example) and doing a traditionalbundle install, observe the sass version and the lack of deprecation warnings when running jekyll:export BUNDLE_PATH=vendor/bundle bundle install bundle exec sass --version # 1.78.0 bundle exec jekyll serve # No sass deprecation notices observed
I'm unsure how to further diagnose from here so apologies if this issue better belongs in the inscapist/bundix repo or elsewhere. Let me know if I can do anything else to assist!
I really appreciate the writeup here! I've been encountering a similar issue for a while but every time I started peeking into things, it somehow corrected itself. I suspect this might be related: I can change references (including the hash) in the gemset.nix and the develop shell starts instantly - no new downloads observed and gem versions remain the same. Perhaps it's some kind of caching issue.
Interestingly, /nix/store/qmgngwsg7xi6rdkgv6p925nwkxs88ys2-ruby3.3-sass-embedded-1.78.0/lib/ruby/gems/3.3.0/gems/sass-embedded-1.78.0/ext/sass/cli.rb contains this:
# frozen_string_literal: true
module Sass
module CLI
COMMAND = [
File.absolute_path('/nix/store/k4l60jsfc8qb2rr0pkfmavdshlxjlqsj-dart-sass-1.80.5/bin/sass', __dir__).freeze
].freeze
end
private_constant :CLI
end
Some nix behavior is fixed here https://github.com/sass-contrib/sass-embedded-host-ruby/issues/116#issuecomment-2417547868 but using sass-embedded v1.79.6, the sass version is unaffected:
# frozen_string_literal: true
require_relative '../../lib/sass/elf'
module Sass
module CLI
INTERPRETER = '/nix/store/maxa3xhmxggrc5v2vc0c3pjb79hjlkp9-glibc-2.40-66/lib/ld-linux-x86-64.so.2'
INTERPRETER_SUFFIX = '/ld-linux-x86-64.so.2'
COMMAND = [
*(ELF::INTERPRETER if ELF::INTERPRETER != INTERPRETER && ELF::INTERPRETER&.end_with?(INTERPRETER_SUFFIX)),
File.absolute_path('/nix/store/k4l60jsfc8qb2rr0pkfmavdshlxjlqsj-dart-sass-1.80.5/bin/sass', __dir__).freeze
].freeze
end
private_constant :CLI
end
@emptyflask this is a great observation. Thanks! Indeed, when I check the actual gem version installed, I see it's the intended gem version:
$ gem list | grep sass-embedded
sass-embedded (1.78.0)
So it sounds like it's not my issue of mis-cached or mis-versioned gems. I'll have to keep digging and file a different ticket. That said, it sounds like issue here is resolved via the sass-embedded fix and thus we can close this?
I changed the nixpkgs version in the flake inputs to 24.05, and the sass version changed to 1.77.2, so it's definitely coming from there. Even though I'm not exactly sure how that's happening, it does make sense, since otherwise it seems unlikely that dart-sass would be built successfully. If you need a specific version, maybe you could use an overlay?
Actually my issue is due to some direnv caching issues. @inscapist gave me a solution in https://github.com/inscapist/ruby-nix/issues/31#issuecomment-2330800192 but I'm only just now trying it out. And it works! So yeah definitely a different issue. I'm not even using this sass gem - I've just been on the lookout for anything resembling my issue. I promise I'm not trying to hijack threads 😅