How to compile ruby with RVM on a low memory system?
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))
Can't install Ruby under Lion with RVM – GCC issues
This answer was edited multiple times and now contains several alternative solutions. Try the simple “Edit 3” solution first.
Ruby 1.9.3-p125 and later have official support for clang, so if you are installing such a version you should not need GCC. If you’re installing an older version of Ruby, read on.
To compile Ruby with GCC, you need a non-LLVM version of GCC, which is no longer included with Xcode 4.2. Install it yourself (or downgrade to Xcode 4.1 temporarily), then do CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3 --enable-shared
(substituting the path to your non-LLVM gcc).
Edit: https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC. There is also some info available by running rvm requirements
.
Edit 2: For an easier solution, you can try adding --with-gcc=clang
to the arguments to configure
for Ruby to use clang instead of GCC.
Edit 3: rvm install 1.9.3 --with-gcc=clang
does that for you.
Note: With current versions of Xcode you need to install the command-line tools separately from the Xcode menu -> Preferences -> Downloads -> Components. This is a pre-requisite for doing any compiling with Xcode on the command-line, not just Ruby.
Note 2: If something doesn't work after following the steps, try doing a reboot or re-login to ensure that the environment gets set correctly.
Note 3: Ruby versions prior to 1.9.3-p125 may not always be fully compatible with clang, so test your software thoroughly if using the “edit 3” solution in a production environment.
Phusion Passenger memory consumption increase from 1.9.3 (system) to 2.1.2 (RVM) on Ubuntu
The out of the box settings for ruby 2.1.2 do increase memory use compared to 2.0.0 (which I believe was on par with 1.9.3 if you don't consider the copy on write improvements in 2.0.0)
The reason is that Ruby 2.1 introduced a new garbage collection algorithm. In a nutshell the algorithm assumes that while some objects live for a long time (eg the objects representing your code) others are very short lived. Older rubies would spend a long time trying to see whether all objects were ready to be garbage collected, whereas ruby 2.1 switches between minor collections (only try to collect the short lived objects) and major collections (try to collect the long lived ones).
This increases performance (minor collections are much faster) at the expense of some memory usage.
You can tune this, using (among others) the RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR
environment variable. The default is 2, a setting of 0.9 turns off the the generational garbage collector and numbers in between will trade off memory for performance.
You can also use the jemalloc library (on any ruby version) to gain a little performance and reduce memory usage slightly.
Lastly part of the problem with rails apps is the many apps have what one might call medium lived objects that last for a whole request - Ruby's attempt to split objects into just 2 generations isn't quite sufficient. Ruby 2.2 is slated to improve on this.
Sam Saffron has a great post on this if you want to read more
In addition ruby 2.1.3 made some changes to gc timing that reduces memory uses in most cases compared to 2.1.2
Install ruby headers with rvm
you are checking in wrong location, check with:
$ find /home/mpapis/.rvm/rubies/ruby-1.9.3-p194/ -name ruby.h
/home/mpapis/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h
/home/mpapis/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h
rvm install 1.9.3 failing
It turns out this is a bug in RailsInstaller OSX 1.0.3 - (Found that out while reading Problems installing Ruby on Mountain Lion - ruby 1.9.3 wont' compile)
I needed to change /etc/rvmrc
to contain this:
umask g+w
export -a rvm_configure_env
rvm_configure_env=('LDFLAGS=-L/opt/sm/pkg/active/lib' 'CFLAGS=-I/opt/sm/pkg/active/include' 'CPATH=/opt/sm/pkg/active/include')
For more info see: https://github.com/railsinstaller/railsinstaller-nix/issues/10
How do I upgrade my ruby 1.9.2-p0 to the latest patch level using rvm?
First of all, update your RVM installation by running rvm get stable
.
To make sure you're running the new RVM version, you'll then need to run rvm reload
(or just open a new terminal).
Once that's done, you can ask RVM to list the ruby versions available to install by running rvm list known
.
In the output you should now see:
# MRI Rubies
...
[ruby-]1.9.2[-p320]
...
The square brackets around the patch level indicate that this is currently RVM's default patch level for ruby 1.9.2.
Finally, to install the new ruby version, just run rvm install 1.9.2
- and wait for it to compile!
Related Topics
What Command Opens Ruby's Repl
How to Compile Ruby with Rvm on a Low Memory System
How to Convert from a String to Object Attribute Name
Dynamic Rails Routes Based on Database Models
Ruby Compare Two Strings Similarity Percentage
Calculating Difference in Time Between Two Time Objects
How to Break from Nested Loops in Ruby
Ruby Code to Extract Host from Url String
Ruby: What's the Difference Between Stdin.Gets() and Gets.Chomp()
Visit_Psych_Nodes_Alias: Unknown Alias: Default (Psych::Badalias)
Install Ruby Curb Gem in Windows Xp
Rails Fixtures Not Loading with Rspec
Rails Strip Non Numeric Values Before Save
How to Validate a Non-Model Form in Rails 3
Bundler Could Not Find Compatible Versions for Gem "Bundler":