rubyrubygemscpu-architecture

How does gem decide, which arch-specific gem to install?


For example; if I want to install any architecture-dependent gem, like nokogiri (xml library for ruby), but for any architecture-dependent gem, the case is the same.

I use an x86 distribution, but on an x86_64 kernel. My ruby is 32-bit, but a gem install nokogiri installs the 64-bit version (what will cause an error, because its shared lib can not link to the 32-bit ruby).

How is it being decided? My ruby is 32-bit, I want the 32-bit gem. The problem is very similar in an armhf/arm64 constellation or if I am trying to use any different emulation layer (like qemu-user or cygwin or wine). In general, I want to install the gem which matches my ruby interpreter and not the one which is autodetected by something.

What to do?


Solution

  • After tracking the ruby internals a little, I found these:

    Thus, for example, in a 32-bit system on a 64-bit kernel, arch and uname -m reports x86-64 and not i386 (or x32).

    However, you can alter this quite easily with the flag --target to the compilation script. In the specific case if you want to compile a 32-bit ruby on a 64-bit system, use configure --target=i386-linux-gnu, even if it does not look needed (because you are using a 32-bit gcc).