+ Reply to Thread
Results 1 to 10 of 10

Thread: HowTo: Install Subversion, Local Ruby Gems, and a Local Ruby on Rails App

  1. #1
    Join Date
    Aug 2007
    Posts
    1

    Default HowTo: Install Subversion, Local Ruby Gems, and a Local Ruby on Rails App

    HowTo:
    Install Subversion, Ruby Gems, and a locally developed Ruby on Rails App on Bluehost

    Nota Bena: After much searching, many experiments, and a few tears this is the best way I have found to set the aforementioned things up. I have cited my virtual sources where I had any. Many thanks to the other developers who have struggled before us.

    1. Install Subversion
    #
    # this is how I installed subversion 1.4.3 on my bluehost account
    #

    mkdir ~/src

    # get and make 'apr-0.9.13' (this isn't included in the subversion tarball)
    cd ~/src
    wget http://apache.ausgamers.com/apr/apr-0.9.13.tar.gz
    tar -xzf apr-0.9.13.tar.gz
    cd apr-0.9.13
    ./configure --prefix=$HOME
    make
    make install

    # get and make 'apr-util 0.9.13' (this isn't included in the subversion tarball either)

    cd ~/src
    wget http://apache.planetmirror.com.au/di...-0.9.13.tar.gz
    tar -xzf apr-util-0.9.13.tar.gz
    cd apr-util-0.9.13
    ./configure --prefix=$HOME --with-apr=$HOME
    make
    make install

    # get and make 'subversion-1.4.3'

    cd ~/src
    wget http://subversion.tigris.org/downloa...n-1.4.3.tar.gz
    tar -xzf subversion-1.4.3.tar.gz
    cd subversion-1.4.3
    ./configure --prefix=$HOME --without-berkeley-db --with-zlib --with-ssl
    # at this point there's a bit of complaining about berkeley db, let's ignore that...
    make
    make install

    # check it works!

    cd
    svn --version
    # yay!

    From: Subversion [Archive] - bluehostforum.com
     http://www.bluehostforum.com/archive...php/t-134.html

    2. Enable Local Gems

    Howto Install your own Gems for Rails

    What you need to know:
    - path to where you will store your local gems
    eg: /home/yourusername/gems
    - path to the base gems
    eg: /usr/lib/ruby/gems/1.8

    What you will do:
    - Setup GEM_HOME which is where you will INSTALL new gems and GEM_PATH which is where you will FIND gems.
    - Make the gem program, your shell, and rails know about your gems
    - Install a gem
    - Test to see if its working

    How to do it:

    1. ssh to your account
    $ ssh yourusername@yourdomain.com

    2. Make sure you are in YOUR home directory
    $ cd ~

    3. Find the path you are in
    $ pwd
    /home/yourusername

    4. Find where the base gems are installed
    $ gem environment
    Rubygems Environment:
    - VERSION: 0.8.10 (0.8.10)
    - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
    - GEM PATH:
    - /usr/lib/ruby/gems/1.8
    - REMOTE SOURCES:
    - http://gems.rubyforge.org

    5. Create a directory to install your local gems
    $ mkdir gems

    6. Create a .gemrc file in your home directory (~) to declare GEM_PATH and GEM_HOME for the gem program. This is in yaml format. Replace gemhome with the full path to where you will store the gems locally in your account. Replace the gempath with whatever the path is on your machine if its different.

    $ vi .gemrc
    # add what is below
    gemhome: /home/yourusername/gems
    gempath:
    - /home/yourusername/gems
    - /usr/lib/ruby/gems/1.8

    7. Verify the environment is changed.
    $ gem environment
    Rubygems Environment:
    - VERSION: 0.8.10 (0.8.10)
    - INSTALLATION DIRECTORY: /home/yourusername/gems
    - GEM PATH:
    - /home/yourusername/gems
    - /usr/lib/ruby/gems/1.8
    - REMOTE SOURCES:
    - http://gems.rubyforge.org

    8. Install a gem
    $ gem install RedCloth
    Attempting local installation of 'RedCloth'
    Local gem file not found: RedCloth*.gem
    Attempting remote installation of 'RedCloth'
    Successfully installed RedCloth-3.0.4


    9. Add the GEM_PATH to your Rails envorinments.rb file. Do this on each of your apps that will use the local gems. This will tell Rails where to find your gems. For this example, my rails apps are in the RailsApps directory and I'm modifying the app1 configuration.

    You will add the ENV line into the environment.rb file. A good place to put it would be at the top of the file, so you remember you added it.

    $ vi ~/RailsApps/app1/config/environment.rb
    ENV['GEM_PATH'] = '/home/yourusername/gems:/usr/lib/ruby/gems/1.8'

    11. Add to your shell environment. This is assuming you are using bash. The .bash_profile will be read next time you login and do this automatically for you.

    $ vi .bash_profile
    export GEM_PATH=/home/yourusername/gems:/usr/lib/ruby/gems/1.8
    export GEM_HOME=/home/yourusername/gems

    Then from the command line

    $ export GEM_PATH=/home/yourusername/gems:/usr/lib/ruby/gems/1.8
    $ export GEM_HOME=/home/yourusername/gems

    Verify it
    $ echo $GEM_PATH
    $ echo $GEM_HOME

    12. Run irb to test. You'll see require_gem 'RedCloth' came back as true and 'NotARealGem' throw an error.

    $ irb
    irb(main):001:0> require 'rubygems'
    => true
    irb(main):002:0> require_gem 'RedCloth'
    => true
    irb(main):003:0> puts RedCloth.new("h1. Header 1\n\nparagraph\n\n").to_html
    <h1>Header 1</h1>


    <p>paragraph</p>
    => nil
    irb(main):004:0> require_gem 'NotARealGem'
    Gem::LoadError: Could not find RubyGem NotARealGem (> 0.0.0)

    from /usr/lib/site_ruby/1.8/rubygems.rb:194:in `report_activate_error'
    from /usr/lib/site_ruby/1.8/rubygems.rb:136:in `activate'
    from /usr/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
    from /usr/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
    from (irb):4

    13. Now test it out in your app too to make sure that Rails picked up that ENV setting.

    (from: http://forums.site5.com/showthread.php?t=11954)

    3. Update config/environment.rb

    #add this line
    ENV['GEM_PATH'] = '/home/yourusername/gems:/usr/lib/ruby/gems/1.8'

    4. Update the public/dispatch.* files (if you developed locally and FTPed yourapp to the server)

    - create a new testapp with the rails command on the host server
    - delete the public/dispatch.* files from YourApp
    - copy the public/dispatch.* files from testapp to yourapp/public

    5. Configure Subversion for Rails
    This was originally written by Jake at http://blog.unquiet.net/archives/200...th-subversion/ .. but that site seems not to be showing content properly, so I salvaged this from the Google cache. I also added two new lines to make it remove /tmp folder which is now in Rails.

    Just dump this into a file called svn.rake in your lib/tasks folder, and use rake configure_for_svn to sort everything out on your initial check out:

    desc "Configure Subversion for Rails"
    task :configure_for_svn do
    system "svn remove log/*"
    system "svn commit -m 'removing all log files from subversion'"
    system 'svn propset svn:ignore "*.log" log/'
    system "svn update log/"
    system "svn commit -m 'Ignoring all files in /log/ ending in .log'"
    system 'svn propset svn:ignore "*.db" db/'
    system "svn update db/"
    system "svn commit -m 'Ignoring all files in /db/ ending in .db'"
    system "svn move config/database.yml config/database.example"
    system "svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'"
    system 'svn propset svn:ignore "database.yml" config/'
    system "svn update config/"
    system "svn commit -m 'Ignoring database.yml'"
    system "svn remove tmp/*"
    system "svn commit -m 'Removing /tmp/ folder'"
    system 'svn propset svn:ignore "*" tmp/'
    end

    desc "Add new files to subversion"
    task :add_new_files do
    system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
    end

    desc "shortcut for adding new files"
    task :add => [ :add_new_files ]

    # see also: http://railscasts.com/episodes/36
    # and
    #http://blog.teksol.info/articles/200...rails-projects

    6. Check out yourapp and scream for joy!

    I hope this is helpful - it certainly is what it took to get my project off the ground (or at least on the server).

  2. #2
    Join Date
    Aug 2007
    Posts
    1

    Default Thanks a lot

    Thanks for posting this very helpful how-to. I was interested in the installing local gem part and it worked perfectly.

    The bluehost knowledge base article on how to install local gems didnt work for me but yours did!

    Again, thanks.

  3. #3

    Default Subversion

    You might also need neon if you get the URL Unrecognized scheme

    wget http://www.webdav.org/neon/neon-0.25.5.tar.gz
    tar -xzf neon-0.25.5.tar.gz
    cd neon-0.25.5
    ./configure --enable-shared --prefix=$HOME
    make
    make install

    email me if with the previous tutorial you can't get HOBO for rails (http://hobocentral.net/) running

  4. #4

    Default

    Quote Originally Posted by classicist View Post
    HowTo:
    Install Subversion, Ruby Gems, and a locally developed Ruby on Rails App on Bluehost



    # get and make 'subversion-1.4.3'

    cd ~/src
    wget http://subversion.tigris.org/downloa...n-1.4.3.tar.gz
    tar -xzf subversion-1.4.3.tar.gz
    cd subversion-1.4.3
    ./configure --prefix=$HOME --without-berkeley-db --with-zlib --with-ssl
    # at this point there's a bit of complaining about berkeley db, let's ignore that...
    make
    make install
    Hi classicist - thanks for the excellent howto! I'm having one problem with the above, due to my lack of experience with unix and svn: i installed the more up to date versionf of apr and apr_utils:

    apr-1.2.11
    apr-util-1.2.10

    and also downloaded the later version of subversion, 1.4.5 to be precise.

    when i try to run the configure for subversion, it's saying that i need to use an appropriate --with-apr command. Looking at configure --help, it says

    --with-apr=PATH prefix for installed APR, path to APR build tree,
    or the full path to apr-config

    But i can't seem to get this command right. I'm trying to point to the apr folder with

    --with-apr=~/src/apr-1.2.11

    but it says

    the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.

    To make life more complicated, there's no apr-config file, not quite anyway: i have

    apr-1-config
    apr-config.in
    apr-config.out

    Should i point it at one of these, and if so do you know the proper syntax for the --with-apr command?

    thanks!
    max

  5. #5

    Default

    Quote Originally Posted by classicist View Post
    # get and make 'subversion-1.4.3'

    cd ~/src
    wget http://subversion.tigris.org/downloa...n-1.4.3.tar.gz
    tar -xzf subversion-1.4.3.tar.gz
    cd subversion-1.4.3
    ./configure --prefix=$HOME --without-berkeley-db --with-zlib --with-ssl
    # at this point there's a bit of complaining about berkeley db, let's ignore that...
    make
    make install

    # check it works!

    cd
    svn --version
    # yay!
    Hi, me again... I got the answer to my other problem, where to point "--with-apr" at (i needed the full path, ie "/home/domain/src/" rather than "~/src").

    But now i have another problem - i finally managed to confgure subversion, then do make, then make install. Each time it looked like it was doing a bunch of stuff. But now when i type "svn" it says 'command not recognised', as if it's not installed after all. Does anyone know what might be wrong here?

    thanks
    max

  6. #6
    Join Date
    May 2007
    Posts
    13

    Default comments

    Thank you! Works good, even on gatorhost.
    Note you may need to add
    ENV['GEM_PATH'] = '/home/wilkboar/local/gems:/usr/lib/ruby/gems/1.8'
    ENV['GEM_HOME'] = '/home/wilkboar/local/gems'

    to boot.rb (since boot.rb loads up rubygems, so you need those things BEFORE it loads up rubygems).

    I'm also not entirely sure if the .gemrc file is necessary--you might be able to get away with just editing .bashrc and setting that right.
    Editing the rails apps' environment seems necessary as when it is run by the 'master server' then it doesn't load the users' .bashrc, so needs to find the gems some other way.
    Last edited by rogerdpack; 01-12-2008 at 03:12 PM.

  7. #7
    Join Date
    Nov 2006
    Posts
    1

    Post if you face problems with libexpat

    When installing subversion I kept getting an error during the compile: incorrect symbols when trying to read libexpat.so.

    To fix this add options to CFLAGS when running configure on subversion:
    CFLAGS="-L/usr/lib64" ./configure --prefix=....

  8. #8
    Join Date
    Oct 2006
    Location
    Ohio
    Posts
    4

    Default

    Thanks for the expat tip, it saved me a lot of head-scratching.

    Of course, you have to run a "make clean" before running "make" again to rebuild the project properly (you already know that, but just in case someone stumbles into this thread...)

  9. #9

    Default Local Ruby Gems, and a Local Ruby on Rails App

    I'm also not entirely sure if the .gemrc file is necessary--you might be able to get away with just editing .bashrc and setting that right.
    Editing the rails apps' environment seems necessary as when it is run by the 'master server' then it doesn't load the users' .bashrc, so needs to find the gems some other way.

  10. #10
    Join Date
    Jan 2009
    Posts
    4

    Default not working

    Code:
    irb(main):002:0> require 'rubygems'
    =>  true
    irb(main):003:0> require_gem 'flickr'
    NoMethodError: undefined method `require_gem' for main:Object
            from (irb):3
    irb(main):004:0>
    ... now what?
    Last edited by gbh; 01-14-2009 at 11:10 AM. Reason: code not showing up

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts