I’m trying to run the ruby-lsp
package with Nix. This is a Ruby package that depends, among others, on prism
, which is gem that requires native compilation.
I tried these two methods (not on NixOS but a distro that has a working Nix store):
nix-shell --pure -p ruby-lsp
, ornix develop .
with the followingflake.nix
file:
{
description = "Minimal Ruby env";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = {nixpkgs, ...}: {
devShells."x86_64-linux".default = let
pkgs = import nixpkgs {system = "x86_64-linux";};
in
pkgs.mkShellNoCC {
packages = [pkgs.ruby-lsp];
};
};
}
Both failed with this error:
/nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1417:in `rescue in block in activate_dependencies': Could not find 'prism' (>= 0.22.0, < 0.25) among 90 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/nix/store/9pipnpnsz3xvbqf5l8h0vfcb22hfw4s0-ruby3.3-ruby-lsp-0.15.0/lib/ruby/gems/3.3.0:/nix/store/da82d480ad9jypc7hngzcy4ki2bsznc9-ruby3.3-language_server-protocol-3.17.0.3/lib/ruby/gems/3.3.0:/nix/store/hk1d300i73p5wlcq4r7xjb0lxzx6b0j2-ruby3.3-prism-1.3.0/lib/ruby/gems/3.3.0:/nix/store/l9lz7h53y17jcw9ywl9rcfxcazhbp0vw-ruby3.3-sorbet-runtime-0.5.11319/lib/ruby/gems/3.3.0:/nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/gems/3.3.0:/home/user/.local/share/gem/ruby/3.3.0' at: /nix/store/9pipnpnsz3xvbqf5l8h0vfcb22hfw4s0-ruby3.3-ruby-lsp-0.15.0/lib/ruby/gems/3.3.0/specifications/ruby-lsp-0.15.0.gemspec, execute `gem env` for more information
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1414:in `block in activate_dependencies'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1403:in `each'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1403:in `activate_dependencies'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1385:in `activate'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:280:in `block in activate_bin_path'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:279:in `synchronize'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:279:in `activate_bin_path'
from /nix/store/9pipnpnsz3xvbqf5l8h0vfcb22hfw4s0-ruby3.3-ruby-lsp-0.15.0/bin/ruby-lsp:18:in `<main>'
/nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/dependency.rb:303:in `to_specs': Could not find 'prism' (>= 0.22.0, < 0.25) - did find: [prism-1.3.0,prism-0.19.0] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/nix/store/9pipnpnsz3xvbqf5l8h0vfcb22hfw4s0-ruby3.3-ruby-lsp-0.15.0/lib/ruby/gems/3.3.0:/nix/store/da82d480ad9jypc7hngzcy4ki2bsznc9-ruby3.3-language_server-protocol-3.17.0.3/lib/ruby/gems/3.3.0:/nix/store/hk1d300i73p5wlcq4r7xjb0lxzx6b0j2-ruby3.3-prism-1.3.0/lib/ruby/gems/3.3.0:/nix/store/l9lz7h53y17jcw9ywl9rcfxcazhbp0vw-ruby3.3-sorbet-runtime-0.5.11319/lib/ruby/gems/3.3.0:/nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/gems/3.3.0:/home/user/.local/share/gem/ruby/3.3.0' , execute `gem env` for more information
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1415:in `block in activate_dependencies'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1403:in `each'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1403:in `activate_dependencies'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems/specification.rb:1385:in `activate'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:280:in `block in activate_bin_path'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:279:in `synchronize'
from /nix/store/5p9309183rd8xayva62kzsbfil1wr4j2-ruby-3.3.6/lib/ruby/3.3.0/rubygems.rb:279:in `activate_bin_path'
from /nix/store/9pipnpnsz3xvbqf5l8h0vfcb22hfw4s0-ruby3.3-ruby-lsp-0.15.0/bin/ruby-lsp:18:in `<main>'
Now, my questions are:
- Am I doing this wrong, or could there be something wrong with the ruby-lsp package?
- Nix seems to be complaining that the
prism
dependency can not be found, at least not one with the right version. Is there a way to forceruby-lsp
to use a specificprism
version manually?
My workaround is currently to put ruby-lsp
as a development dependency in a Gemfile. I would like to use Nix for it and also to understand more about how this works ~ so any help is appreciated .