I’m trying to setup a Ruby dev environment with a shell.nix file:
with (import <nixpkgs> {});
let
gems = bundlerEnv {
ruby = ruby_3_2;
name = "gems-for-ruby-template";
gemdir = ./.;
extraConfigPaths = [ "${./.}/.ruby-version" ];
};
in mkShell {
packages = [
bundix
gems
gems.wrappedRuby
];
}
but I’m getting the following error:
direnv: loading /data/code/newstore/middleware/.envrc
direnv: using nix
error: builder for '/nix/store/8wwlx9ccxjk7fdwg32jj9nxlbky7l39y-ruby3.2-libxml-ruby-4.0.0.drv' failed with exit code 1;
last 10 log lines:
> In file included from ruby_libxml.h:29:
> ruby_xml_sax2_handler.h:6:8: error: unknown type name 'xmlSAXHandler'
> 6 | extern xmlSAXHandler rxml_sax_handler;
> | ^~~~~~~~~~~~~
> make: *** [Makefile:248: libxml.o] Error 1
>
> make failed, exit code 2
>
> Gem files will remain installed in /nix/store/dbh8apjiv413m6i0m1ld2j2d54dims1q-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/gems/libxml-ruby-4.0.0 for inspection.
> Results logged to /nix/store/dbh8apjiv413m6i0m1ld2j2d54dims1q-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/libxml-ruby-4.0.0/gem_make.out
For full logs, run 'nix-store -l /nix/store/8wwlx9ccxjk7fdwg32jj9nxlbky7l39y-ruby3.2-libxml-ruby-4.0.0.drv'.
error: 1 dependencies of derivation '/nix/store/rcadbhq4vnd70mmnsz1k8ndbz3ryy2vy-gems-for-ruby-template.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hvwr6v0prx3dh9kwmly9r4n676x5sd93-nix-shell-env.drv' failed to build
I’ve tried adding various dependent packages such as libxml2, libiconv, etc to packages but I get the same error.
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "installPhase" }
Running phase: installPhase
buildFlags: --with-xml2-lib=/nix/store/dyp7mrhrarzilxxia7xxx4z14rzbd016-libxml2-2.12.6/lib --with-xml2-include=/nix/store/n07zr76pkcqi7ycmc5yihdjf5qm7rda1-libxml2-2.12.6-dev/include/libxml2
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/bin
Gem home: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0
Plugins dir: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/plugins
Building native extensions with: '--with-xml2-lib=/nix/store/dyp7mrhrarzilxxia7xxx4z14rzbd016-libxml2-2.12.6/lib --with-xml2-include=/nix/store/n07zr76pkcqi7ycmc5yihdjf5qm7rda1-libxml2-2.12.6-dev/include/libxml2'
This could take a while...
ERROR: Error installing /nix/store/zvb3g18lnlfwkq085njxhzld3h6arpmd-libxml-ruby-4.0.0.gem:
ERROR: Failed to build gem native extension.
current directory: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/gems/libxml-ruby-4.0.0/ext/libxml
/nix/store/arjxhz4mliqx28zrvcjkcwr7i8p840lk-ruby-3.2.4/bin/ruby extconf.rb --with-xml2-lib\=/nix/store/dyp7mrhrarzilxxia7xxx4z14rzbd016-libxml2-2.12.6/lib --with-xml2-include\=/nix/store/n07zr76pkcqi7ycmc5yihdjf5qm7rda1-libxml2-2.12.6-dev/include/libxml2
/nix/store/arjxhz4mliqx28zrvcjkcwr7i8p840lk-ruby-3.2.4/bin/ruby: warning: shebang line ending with \r may cause problems
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2,/usr/local/include... yes
checking for xmlParseDoc() in -lxml2... yes
creating extconf.h
creating Makefile
current directory: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/gems/libxml-ruby-4.0.0/ext/libxml
make DESTDIR\= sitearchdir\=./.gem.20240522-26-pakgvf sitelibdir\=./.gem.20240522-26-pakgvf clean
current directory: /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/gems/libxml-ruby-4.0.0/ext/libxml
make DESTDIR\= sitearchdir\=./.gem.20240522-26-pakgvf sitelibdir\=./.gem.20240522-26-pakgvf
compiling libxml.c
In file included from ruby_libxml.h:13,
from libxml.c:1:
ruby_xml_encoding.h:12:27: error: unknown type name 'xmlChar'
12 | VALUE rxml_new_cstr(const xmlChar* xstr, const xmlChar* xencoding);
| ^~~~~~~
ruby_xml_encoding.h:12:48: error: unknown type name 'xmlChar'
12 | VALUE rxml_new_cstr(const xmlChar* xstr, const xmlChar* xencoding);
| ^~~~~~~
ruby_xml_encoding.h:13:31: error: unknown type name 'xmlChar'
13 | VALUE rxml_new_cstr_len(const xmlChar* xstr, const long length, const xmlChar* xencoding);
| ^~~~~~~
ruby_xml_encoding.h:13:71: error: unknown type name 'xmlChar'
13 | VALUE rxml_new_cstr_len(const xmlChar* xstr, const long length, const xmlChar* xencoding);
| ^~~~~~~
ruby_xml_encoding.h:15:60: error: unknown type name 'xmlCharEncoding'
15 | rb_encoding* rxml_xml_encoding_to_rb_encoding(VALUE klass, xmlCharEncoding xmlEncoding);
| ^~~~~~~~~~~~~~~
ruby_xml_encoding.h:16:41: error: unknown type name 'xmlChar'
16 | rb_encoding* rxml_figure_encoding(const xmlChar* xencoding);
| ^~~~~~~
In file included from ruby_libxml.h:14:
ruby_xml_attributes.h:9:27: error: unknown type name 'xmlNodePtr'
9 | VALUE rxml_attributes_new(xmlNodePtr xnode);
| ^~~~~~~~~~
In file included from ruby_libxml.h:15:
ruby_xml_attr.h:9:22: error: unknown type name 'xmlAttrPtr'
9 | VALUE rxml_attr_wrap(xmlAttrPtr xattr);
| ^~~~~~~~~~
In file included from ruby_libxml.h:16:
ruby_xml_attr_decl.h:9:27: error: unknown type name 'xmlAttributePtr'
9 | VALUE rxml_attr_decl_wrap(xmlAttributePtr xattribute);
| ^~~~~~~~~~~~~~~
In file included from ruby_libxml.h:17:
ruby_xml_document.h:8:26: error: unknown type name 'xmlDocPtr'; did you mean 'xmlErrorPtr'?
8 | VALUE rxml_document_wrap(xmlDocPtr xnode);
| ^~~~~~~~~
| xmlErrorPtr
ruby_xml_document.h:10:9: error: unknown type name 'xmlChar'
10 | typedef xmlChar * xmlCharPtr;
| ^~~~~~~
In file included from ruby_libxml.h:18:
ruby_xml_node.h:9:21: error: unknown type name 'xmlNodePtr'
9 | void rxml_node_mark(xmlNodePtr xnode);
| ^~~~~~~~~~
ruby_xml_node.h:10:22: error: unknown type name 'xmlNodePtr'
10 | VALUE rxml_node_wrap(xmlNodePtr xnode);
| ^~~~~~~~~~
ruby_xml_node.h:11:23: error: unknown type name 'xmlNodePtr'
11 | void rxml_node_manage(xmlNodePtr xnode, VALUE node);
| ^~~~~~~~~~
ruby_xml_node.h:12:25: error: unknown type name 'xmlNodePtr'
12 | void rxml_node_unmanage(xmlNodePtr xnode, VALUE node);
| ^~~~~~~~~~
In file included from ruby_libxml.h:19:
ruby_xml_namespace.h:9:27: error: unknown type name 'xmlNsPtr'; did you mean 'xmlCharPtr'?
9 | VALUE rxml_namespace_wrap(xmlNsPtr xns);
| ^~~~~~~~
| xmlCharPtr
In file included from ruby_libxml.h:29:
ruby_xml_sax2_handler.h:6:8: error: unknown type name 'xmlSAXHandler'
6 | extern xmlSAXHandler rxml_sax_handler;
| ^~~~~~~~~~~~~
make: *** [Makefile:248: libxml.o] Error 1
make failed, exit code 2
Gem files will remain installed in /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/gems/libxml-ruby-4.0.0 for inspection.
Results logged to /nix/store/fz1p6ij71i9ay5s2d7qvb4jvw8n5fi0s-ruby3.2-libxml-ruby-4.0.0/lib/ruby/gems/3.2.0/extensions/x86_64-linux/3.2.0/libxml-ruby-4.0.0/gem_make.out