You are not logged in.

  • Index
  •  » Rails
  •  » How to install gems for your Rails application.

#1 2007-11-22 22:16:49

IAIHMB
Member
From: Hudson, Florida.
Registered: 2006-09-19
Posts: 1362

How to install gems for your Rails application.

If you're a WebFaction customer the best way to install gems for your Rails application is to install Ruby and RubyGems in your home directory and update your application of type Rails' autostart.cgi to use your local installation of Ruby. The procedure looks something like this:

Code:

# Install Ruby
cd
mkdir ruby1.8/ ruby1.8/src/
cd ruby1.8/src/
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
tar fxz ruby-1.8.6-p110.tar.gz
cd ruby-1.8.6-p110/
./configure --prefix=$HOME/ruby1.8/
make
make install
cd ../../
rm -fr src/

# Add ~/ruby1.8/bin/ and ~/ruby1.8/lib/ruby/gems/1.8/bin/ to your PATH.
cd
echo "export PATH=$HOME/ruby1.8/bin/:$HOME/ruby1.8/lib/ruby/gems/1.8/bin/:\$PATH" >> .bash_profile
source .bash_profile

# Install RubyGems
cd
mkdir temp/
cd temp/
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar fxz rubygems-0.9.4.tgz
cd rubygems-0.9.4/
ruby setup.rb config
ruby setup.rb install
cd
rm -fr temp/

# Update RubyGems
gem update --system

# Install the Mongrel, MySQL, and PostgreSQL gems.
export POSTGRES_INCLUDE=/usr/local/pgsql/include/
export POSTGRES_LIB=/usr/local/pgsql/lib/
gem install --platform=ruby mongrel mysql postgres

At this point you should install every gem that your Rails application needs.

Code:

# Replace XXX with the name of your application of type Rails in the following command.
cd ~/webapps/XXX/

# Update autostart.cgi to use your installation of Mongrel.
sed -i "s|/usr/local/bin/mongrel_rails|$HOME/ruby1.8/lib/ruby/gems/1.8/bin/mongrel_rails|" autostart.cgi

# Restart Mongrel
kill `cat log/mongrel.pid`
./autostart.cgi

That's it, now you can install gems using "gem install (Gem Name)".

Hope it helps. smile

Last edited by IAIHMB (2008-03-26 01:55:11)


-David Sissitka

Offline

 

#2 2008-03-31 13:03:33

seanharper
Member
Registered: 2008-03-31
Posts: 4

Re: How to install gems for your Rails application.

Hi - I got a little bit stuck following these instructions:

I got ruby installed, I added the paths, I downloaded Gems, and now Gems is stuck.


[seanharper@web1 rubygems-1.1.0]$ pwd
/home2/seanharper/tmp/rubygems-1.1.0
[seanharper@web1 rubygems-1.1.0]$ ~/ruby1.8/bin/ruby setup.rb
./lib/rubygems.rb:10:in `require': no such file to load -- thread (LoadError)
        from ./lib/rubygems.rb:10
        from setup.rb:19:in `require'
        from setup.rb:19
[seanharper@web1 rubygems-1.1.0]$

Any ideas?

[seanharper@web1 rubygems-1.1.0]$ $PATH
-bash: /home2/josh/git_app/bin:/home2/seanharper/ruby1.8/bin/:/home2/seanharper/ruby1.8/lib/ruby/gems/1.8/bin/:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home2/seanharper/bin:

Offline

 

#3 2008-04-01 17:25:00

seanf
Administrator
Registered: 2008-02-01
Posts: 1899
Website

Re: How to install gems for your Rails application.

Sean,

I su'd into your account and ran Step 1 of the procedure here:
https://help.webfaction.com/index.php?_ … p;nav=0,21

No errors, so I think you're good to go.. just pick up at Step 2

Regards,

Offline

 

#4 2008-07-08 14:45:48

vomitols
Member
From: Hertfordshire
Registered: 2008-01-23
Posts: 12

Re: How to install gems for your Rails application.

@IAIHMB

Im trying to set up Ozark (http://github.com/brennandunn/ozark/tree/master). Have successfully installed Ruby, all the required gems and mongrel but when I try to restart mongrel:

[vomitols@web22 ozark]$ kill `cat log/mongrel.pid`
cat: log/mongrel.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

Could you please take a look?

Didn't migrate the db yet. Waiting for this step.
All the best,
Bernardo.

Offline

 

#5 2008-07-08 21:13:53

seanf
Administrator
Registered: 2008-02-01
Posts: 1899
Website

Re: How to install gems for your Rails application.

I'm looking in your 'ozark' directory now, and I see no "log" subdirectory.

You can get your PID from:

ps -u vomitols -o pid,command

The PID will be the first column.

Regards,

Offline

 

#6 2008-07-09 11:02:50

vomitols
Member
From: Hertfordshire
Registered: 2008-01-23
Posts: 12

Re: How to install gems for your Rails application.

@seanf

thank you!

Offline

 

#7 2008-07-09 11:51:43

vomitols
Member
From: Hertfordshire
Registered: 2008-01-23
Posts: 12

Re: How to install gems for your Rails application.

@seanf

Now the site is restarting over and over again.

Offline

 

#8 2009-05-07 15:58:50

conner
Member
Registered: 2009-01-04
Posts: 17

Re: How to install gems for your Rails application.

I went with 1.8.6 (patch level 110) of ruby since that appears to be what webfaction is already using (patch level 0), didn't want to shake the boat too much, not convinced it matters, but anyway,

I'm getting stuck hereabouts:

Code:

[conner@web41 ~]$ gem update --system
Updating RubyGems
Bulk updating Gem source index for: http://gems.rubyforge.org/
Updating rubygems-update
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /usr/local/lib/ruby/gems/1.8/cache/rubygems-update-1.3.3.gem
[conner@web41 ~]$ export POSTGRES_INCLUDE=/usr/local/pgsql/include/
[conner@web41 ~]$ export POSTGRES_LIB=/usr/local/pgsql/lib/
[conner@web41 ~]$ gem install --platform=ruby mongrel mysql postgres
Bulk updating Gem source index for: http://gems.rubyforge.org/
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /usr/local/lib/ruby/gems/1.8/cache/fastthread-1.0.7.gem
[conner@web41 ~]$ gem -v
1.1.1
[conner@web41 ~]$ which gem
~/ruby1.8/bin/gem

Is there some environment variable i should be setting to keep it inside my space?

Offline

 

#9 2009-05-07 16:05:43

conner
Member
Registered: 2009-01-04
Posts: 17

Re: How to install gems for your Rails application.

Code:

[conner@web41 ~]$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.1.1
  - RUBY VERSION: 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org

a lot of that looks wrong... i'll keep plugging away at it

Offline

 

#10 2009-05-07 16:11:32

conner
Member
Registered: 2009-01-04
Posts: 17

Re: How to install gems for your Rails application.

apparantly running 'source .bash_profile' wasn't enough, a logout/login seemed to make everything happy.

'which gem' gave me my install of gem, but when interacting with it any other way i got the usr/local install

Offline

 

#11 2009-05-07 16:17:31

seanf
Administrator
Registered: 2008-02-01
Posts: 1899
Website

Re: How to install gems for your Rails application.

conner wrote:

apparantly running 'source .bash_profile' wasn't enough, a logout/login seemed to make everything happy.

'which gem' gave me my install of gem, but when interacting with it any other way i got the usr/local install

That's strange... first time I've heard of  'source .bash_profile' not working. But, glad you were able to sort it out smile

Offline

 

#12 2009-05-07 16:23:13

conner
Member
Registered: 2009-01-04
Posts: 17

Re: How to install gems for your Rails application.

Not to keep spamming this thread, but I've got another problem: mysql failed to install

Code:

[conner@web41 ~]$ gem install --platform=ruby mongrel mysql postgres
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Successfully installed fastthread-1.0.7
Successfully installed cgi_multipart_eof_fix-2.5.0
Successfully installed mongrel-1.1.5
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/home/conner/ruby1.8//bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/conner/ruby1.8//bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /home/conner/ruby1.8/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /home/conner/ruby1.8/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

My environment:

Code:

[conner@web41 ~]$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.3
  - RUBY VERSION: 1.8.6 (2007-09-23 patchlevel 110) [i686-linux]
  - INSTALLATION DIRECTORY: /home/conner/ruby1.8//lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /home/conner/ruby1.8//bin/ruby
  - EXECUTABLE DIRECTORY: /home/conner/ruby1.8//bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/conner/ruby1.8//lib/ruby/gems/1.8
     - /home/conner/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
[conner@web41 ~]$ echo $PATH
/home/conner/ruby1.8/bin/:/home/conner/ruby1.8/lib/ruby/gems/1.8/bin/:/home/conner/webapps/gitosis/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/conner/bin

I first got an error for mongrel and mysql, fastthread needs 1.1.2 or higher of rubygem. Couldn't seem to upgrade it using the traditional means, so I used the update rubygem plugin to bring me up, which left me here.

Offline

 

#13 2009-05-07 16:29:08

seanf
Administrator
Registered: 2008-02-01
Posts: 1899
Website

Re: How to install gems for your Rails application.

Try the following for the MySQL gem:

Code:

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

Hope that helps!

Offline

 

#14 2009-05-07 20:49:13

conner
Member
Registered: 2009-01-04
Posts: 17

Re: How to install gems for your Rails application.

woot

that works

thank you!

Offline

 
  • Index
  •  » Rails
  •  » How to install gems for your Rails application.

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson