Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile ruby with RVM on a low memory system?

rvm install 1.9.3

leads to the error in the make.log:

...
compiling ./enc/trans/emoji_sjis_docomo.c
compiling ./enc/trans/emoji_sjis_kddi.c
gcc: internal compiler error: Killed (program cc1)
gcc: internal compiler error: Killed (program cc1)
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
...

dmesg shows

[180031.341709] send sigkill to 3705 (cc1), adj 0, size 3394

free shows at some point running configure process:

             total       used       free     shared    buffers     cached
Mem:        241668     238676       2992          0         92       2020
-/+ buffers/cache:     236564       5104
Swap:       262140     262140          0

So I assume that 256MB RAM and 256MB Swap is not enough to compile Ruby on it.

I read that it should be possible using some parameters for gcc, see: http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps

But

  rvm install 1.9.3 --with-CFLAGS="$CFLAGS --param ggc-min-expand=0 --param ggc-min-heapsize=8192"

Does not work to give the flags to gcc, log is still the same for the flags:

command(2): __rvm_make -j4
        CC = gcc
        LD = ld
        LDSHARED = gcc -shared
        CFLAGS = -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-fiel$
        XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
        CPPFLAGS =   -I. -I.ext/include/x86_64-linux -I./include -I.
        DLDFLAGS = -Wl,-soname,libruby.so.1.9
        SOLIBS = -lpthread -lrt -ldl -lcrypt -lm

How to compile ruby on that machine?

like image 544
marc Avatar asked Nov 04 '13 03:11

marc


People also ask

How do I install Ruby on RVM?

To install a version of Ruby using RVM, use the command rvm install <version number>. So to install version 2.6.3 of Ruby enter the following into the terminal: Depending on your operating system, the above command may use precompiled binaries or compile the Ruby binaries from source. If compiling from source, this may take a long time to complete.

What is Ruby Version Manager (RVM)?

Different versions of Ruby may be necessary for different projects. With conventional installations, this would impede your ability to be flexible. Luckily, the Ruby Version Manager, known more widely as RVM, allows you to easily install multiple, contained versions of Ruby and easily switch between them.

How is memory managed in Ruby?

Primarily, memory management relies on the Ruby runtime, the host operating system, and the system kernel. Apart from these, the runtime garbage collection also plays an important role in determining how memory is managed and recycled. Ruby organizes objects into segments called heap pages.

What is RVM and why should you use it?

You can use RVM to configure development conditions, server installations, and even to deploy your application. If you work with Ruby on a regular basis, learning how to craft individualized Ruby environments with RVM is well worth it.


1 Answers

Creating a 512MB swap-file solved the problem. Here are the steps:

sudo mkdir -p /var/cache/swap/
sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=1M count=512
sudo chmod 0600 /var/cache/swap/swap0
sudo mkswap /var/cache/swap/swap0 
sudo swapon /var/cache/swap/swap0

The swap file is not used after a restart. It can be integrated in /etc/fstab to use it after restart:

 /var/cache/swap/swap0    none    swap    sw      0 0

The above steps to create a swap-file I found here (in German): http://wiki.ubuntuusers.de/Swap#Swap-als-Datei - licence for the above content: http://creativecommons.org/licenses/by-nc-sa/2.0/de/deed.en (Attribution-NonCommercial-ShareAlike 2.0 Germany (CC BY-NC-SA 2.0 DE))

like image 158
marc Avatar answered Oct 16 '22 22:10

marc