↓ Archives ↓

Posts Tagged → rvm

Install RVM, Passenger, Nginx and Rails 3 on Ubuntu Lucid Lynx

This has been a problem encountered by several developers including myself:

Getting RVM, Passenger and Rails3 to work

Here's a quick and short post. Supposing you already have updated Ubuntu and have Ruby installed. These are the only commands you should need:


rvm install 1.9.2

rvm 1.9.2 --passenger

rvm 1.9.2
gem install passenger

rvmsudo passenger-install-nginx-module

#use rvm by default
rvm 1.9.2-preview3 --default

#edit the nginx config file. mine is on /opt/nginx/conf/nginx.conf. just change username 

passenger_root /home/username/.rvm/gems/ruby-1.9.2-preview3/gems/passenger-2.2.15;
passenger_ruby /home/username/.rvm/bin/passenger_ruby;

#reboot if you can. I recommend rebooting over restarting/stopping and starting nginx server. reboot was actually the fix I needed after following all the steps above. 

sudo reboot 


#.rvmrc file on your Rails 3 app should contain. this may be optional but in case you've set a different ruby version, this helps. 

if [[ -s "~/.rvm/environments/ruby-1.9.2-preview3" ]] ; then
  . "~/.rvm/environments/ruby-1.9.2-preview3"
else
  rvm --create use  "ruby-1.9.2-preview3"



If nothing works for you. Check your path, your ruby version and check whether bundler is installed.

How to installed bundler for Rails 3:


gem install bundler --pre

Most gems for Rails 3 require "--pre" by the way.

Installing gems


cd app/dir && bundle install

It's that simple. But something failed. I use mysql and pg gem. I use mysql gem for test and development environment because they work better for testing. But I use postgresql for production and staging. Mysql gem was not installed by bundler. You have to run this:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

Hope this helped someone.

This post by Katz Pe is from BridgeUtopia.

RVM Gemsets: Awesomeness

If you have recently been keeping up to date with Ruby, and have tried using multiple versions at the same time, you’re most probably using RVM to manage these different versions. RVM is pretty awesome. But like any tool, you have to grok it a little so you know what it does behind the scenes when you use it.

Gemsets allow you to isolate gems per project

Ever since RVM released the gemset feature, I’ve never stopped using it on all projects. One very interesting, and probably underused feature of it is the ability to automatically switch to a gemset after cding to a directory, i.e. If you want to know more see RVM’s section on workflows.

How to remain DRY

Every time you start a project, you’re probably wondering “oh now what I’m gonna have to install all the gems I need again? Of course you don’t have to do this, if you make use of the %global gemset.

It’s no Silver bullet

Over time, I’ve discovered a few stuff that, like with any tool, are “good-to-knows”.
  1. If you have like 100 gems in a gemset, then that would probably equate to 100++ entries in your $LOAD_PATH. I try to keep my gemsets as small as possible.
  2. Huge $LOAD_PATHs impact your application’s load time. Like I said in #1, I guess it’s good practice to keep ‘em gemsets nice and manageable, this way you don’t impact your application’s load time.
  3. RVM and Bundler doesn’t play nice with each other. Our M.O. so far regarding this issue is to situate your Rails 3 app that uses bundler in an environment unaware of RVM, this way isolating each from the other. Bundler loads wwwwwwwwwwwayy tooooo slow with RVM.

This post by cyx is from pipe :to => /dev/null.

How to Install RVM and Rails 3 on Snow Leopard

This is a continuation of my post on installing Ruby version manager or multiple versions of Ruby for Unix. This time it's about OS X 10.6.1 or the Snow Leopard.

Snow Leopard includes Ruby and Rails by default if you install XCode. The version is 1.8.7 and 2.2.2 for each, respectively. This would not suffice for most developers because we need to start porting to Ruby 1.9 and start experimenting with Rails 3. The goal is to just keep moving forward and use the best version that exists.

Update: Since I am getting a lot of feedback regarding this post. I noticed it's not newbie-friendly. Sorry. Here are the missing steps.

My Apache2 is installed in /usr/local and PHP5 is compiled by source. I do not use what Leopard has by default because it wasn't working well for me.

In case it happens for you and you want to install PHP5 and more modules. See the following guides:

Compiling Apache in 64-bits Mode on Leopard


Installing PHP


Starting Apache at boot on Leopard


I also installed Fink

So at the very least, you can skip reading what's written on the links above if your Apache2 installed is OK.

Install WGET (but you can also use curl) or just download via web browser.

tar -xzvf wget-latest.tar.gz
cd wget-1.11.4/
./configure
make
sudo make install

Install Readline

wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
tar -xvzf readline-6.0.tar.gz
cd readline-6.0
./configure
make
sudo make install

Install Most

wget ftp://space.mit.edu/pub/davis/most/most-5.0.0.tar.gz
tar xvzf most-5.0.0.tar.gz
cd most-5.0.0
./configure
make
sudo make install

RVM installation for OS X.

Please read the guides on the website of Wayne. Click here to go there.

Note: The path "/usr/local" is important. This makes a bit of a difference between installing on Ubuntu/Debian and OS X.

sudo gem install rvm #install rvm 
rvm-install 
rvm install 1.8.7 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.1 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local
rvm 1.8.7 --default

Install Prerequisites

Git

Hivelogic tutorials are good. Check out how to install Git on Leopard.

SQLite 3

wget http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz
tar xvzf sqlite-amalgamation-3.6.22.tar.gz
cd sqlite-3.6.22/
./configure
make
sudo make install

MySQL

Download from MYSQL website

Select the version compatible with your Mac.

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Install Rails 3.0 Pre

rvm use 1.8.7%rails3 
gem install rake rack test-spec thor sqlite3-ruby 
gem install mysql -- --with-mysql-dir=/usr/local/mysql    
git clone git://github.com/rails/rails.git && cd rails
rake package && gem install -f */pkg/*.gem pkg/*.gem  
cd arel && thor :build && thor :install 
cd ~

And all this didn't take time for me even while writing this post. I now have a successful install for Rails 3 Pre. Same result with Ubuntu Karmic Koala.


Katherine-Pes-iMac:~ katz$ rails -v
Rails 3.0.pre

rails new yourawesomeapp -d mysql 

I suggest replacing the .gitignore file immediately with the .gitignore you've been using or add those necessary entries.

An example of a complete .gitignore file is here.

But often this is just what you need:

*~
.#*
.DS_Store
backups/* #[I keep some files relevant to the application like the database dump on the same folder] 
log/* #[we don't need the the log files submitted
 

Keep adding in other entries later.

Update:

Install Rails 3 Beta

gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre

Some guides out there are wrong. Do not use "sudo" when you are using RVM. Your gems are on your user's home directory.

If things are not working and you have followed installation guides. You're missing an important part which is called the .bash_profile. Please review your .bash_profile first. I can't explain every line but every line is important.

This is what I have right now:

Katherine-Pes-iMac:~ katz$ cat .bash_profile

export PATH=/usr/local/bin/:/usr/local/sbin/:/opt/local/bin/:/opt/local/sbin/
:/Users/katz/.rvm/rubies/ruby-1.8.7-p248/bin:
/Users/katz/.rvm/gems/ruby-1.8.7-p248/bin:
/Users/katz/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
export PATH="/usr/local/bin:/usr/local/sbin:
/usr/local/mysql/bin:$PATH" 

export APACHE2="/usr/local/apache2/bin"
export PATH="${APACHE2}:${PATH}"

export EDITOR='mate -w'
export CLICOLOR=1

export LSCOLORS=ExFxCxDxBxegedabagacad
export PAGER=most

if [[ -s /Users/katz/.rvm/scripts/rvm ]] ; then source /Users/katz/.rvm/scripts/rvm ; fi


alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"

. /sw/bin/init.sh

function gemdir {
if [[ -z "$1" ]] ; then
echo "gemdir expects a parameter, which should be a valid rvm Ruby selector"
else
rvm "$1"
cd `rvm gemdir`
pwd
fi
}

As you can see, there's RVM code. If you follow RVM installation properly you should have something like that. Aliases are shortcuts for starting/stopping MYSQL but mine is automatically loaded on startup.

Have fun :)

This post by Katz Pe is from BridgeUtopia.