rubyPackages.rails has been removed from nix package store starting 22.05

I’m not sure why but the ruby on rails package was removed in 22.11

You can see it here for 22.05

https://search.nixos.org/packages?channel=22.05&show=rubyPackages.rails&from=0&size=50&buckets={"package_attr_set"%3A["rubyPackages"]%2C"package_license_set"%3A[]%2C"package_maintainers_set"%3A[]%2C"package_platforms"%3A[]}&sort=relevance&type=packages&query=rails

I’m wondering why this was removed and whether there is a new recommended alternate way to install?

A quick search shows it was removed here due to some issues with Bundler.

ahh interesting - i don’t want to write a rails derivation from scratch. What would be the best way to find out what other rails developers in the community are doing to install rails?

Surely somebody has got a nice solution handy?

In https://devenv.sh we have a test for rails as an example, hope that helps :slight_smile:

Probably the best way forward is to implement ruby support in dream2nix

ok thanks I’ll give devenv a go.

Is devenv.sh like easy to use preconfigured nix environments?

1 Like

Ok so i took the ruby example from the devenv.sh examples:

{ pkgs, ... }:

{
  languages.ruby.enable = true;

  enterShell = ''
    bundle
  '';
}

It’s getting further and was relatively pain free - however it winges because rails needs the sqlite headers installed on the system. In ubuntu you would normally do something like sudo apt install libsqlite3-dev to get them - however nix doesn’t appear to have a similar package.

Is there a way to solve this using devenv?

{ pkgs, ... }:

{
  languages.ruby.enable = true;

  enterShell = ''
    bundle
  '';

  packages = [ pkgs.sqlite ];
}

There’s a bunch of gems that are failing to build - I suspect it could be related to needing the ruby headers?

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/vagrant/BestLibraries/api/.devenv/state/.bundle/ruby/3.1.0/gems/io-console-0.6.0/ext/io/console
/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/bin/ruby -I /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0 extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/bin/$(RUBY_BASE_NAME)
/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:498:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:624:in `block in try_compile'
        from /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:573:in `with_werror'
        from /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:624:in `try_compile'
        from /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/mkmf.rb:900:in `macro_defined?'
        from extconf.rb:7:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/vagrant/BestLibraries/api/.devenv/state/.bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/io-console-0.6.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/vagrant/BestLibraries/api/.devenv/state/.bundle/ruby/3.1.0/gems/io-console-0.6.0 for inspection.
Results logged to /home/vagrant/BestLibraries/api/.devenv/state/.bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/io-console-0.6.0/gem_make.out

  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:102:in `run'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:171:in `build_extension'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:205:in `block in build_extensions'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `each'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `build_extensions'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/rubygems/installer.rb:843:in `build_extensions'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in `install'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in `install'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in `do_install'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
  /nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing io-console (0.6.0), and Bundler cannot continue.

In Gemfile:
  debug was resolved to 1.7.1, which depends on
    irb was resolved to 1.6.2, which depends on
      reline was resolved to 0.3.2, which depends on
        io-console

When I look specifically in the gem logs I get errors like these:

vagrant@carverlinux ~/B/api (master) [5]> cat   /home/vagrant/BestLibraries/api/.devenv/state/.bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/io-console-0.6.0/mkmf.log

LD_LIBRARY_PATH=.:/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib:/nix/store/kz7sbh10ns27ldcq72hq6jw3xpx9hcpz-devenv-profile/lib: "gcc -o conftest -I/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/include/ruby-3.1.0/x86_64-linux -I/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/include/ruby-3.1.0/ruby/backward -I/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/include/ruby-3.1.0 -I.    -O3 -fPIC conftest.c  -L. -L/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib -Wl,-rpath,/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed     -Wl,-rpath,/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib -L/nix/store/jqkpdp70i5qcwn7val5d0vbb7dlw1ij1-ruby-3.1.2/lib -lruby-3.1.2  -lm  -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

Any ideas?

added gcc and clang and it compiles fine cheers all