Gems / How to install to your home directory

From WhyNotWiki

Jump to: navigation, search

Before making any changes:

> gem env
RubyGems Environment:
  - VERSION: 0.9.2 (0.9.2)
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - GEM PATH:
     - /usr/lib/ruby/gems/1.8
  - REMOTE SOURCES:
     - http://gems.rubyforge.org
> sudo gem install svn-command
(asks you for a root password, which you don't have)

Download from http://rubyforge.org/frs/?group_id=126 and install:

> wget http://rubyforge.org/frs/download.php/20585/rubygems-0.9.3.tgz
...
> tar -xzf rubygems-0.9.3.tgz

> cd rubygems-0.9.3
rubygems-0.9.3 > ruby setup.rb config --prefix=~/gems
rubygems-0.9.3 > ruby setup.rb setup

rubygems-0.9.3 > ruby setup.rb install
rm -f InstalledFiles
---> bin
mkdir -p /home/tylerrick/gems/bin
install gem /home/tylerrick/gems/bin/
install gem_mirror /home/tylerrick/gems/bin/
install gem_server /home/tylerrick/gems/bin/
install gemlock /home/tylerrick/gems/bin/
install gemri /home/tylerrick/gems/bin/
install gemwhich /home/tylerrick/gems/bin/
install index_gem_repository.rb /home/tylerrick/gems/bin/
install update_rubygems /home/tylerrick/gems/bin/
<--- bin
---> lib
mkdir -p /usr/local/lib/site_ruby/1.8
install gemconfigure.rb /usr/local/lib/site_ruby/1.8/
install rubygems.rb /usr/local/lib/site_ruby/1.8/
setup.rb:633:in `initialize': Permission denied - /usr/local/lib/site_ruby/1.8/rubygems.rb (Errno::EACCES)
        from setup.rb:633:in `open'
        from setup.rb:633:in `install'
        from setup.rb:1377:in `install_files'
        from setup.rb:1376:in `each'
        from setup.rb:1376:in `install_files'
        from setup.rb:1350:in `install_dir_lib'
        from setup.rb:1532:in `__send__'
        from setup.rb:1532:in `traverse'
         ... 7 levels...
        from setup.rb:826:in `__send__'
        from setup.rb:826:in `invoke'
        from setup.rb:773:in `invoke'
        from setup.rb:1578

Try again...

> PREFIX=$HOME
> export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
> export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
> ruby setup.rb all --prefix=~/gems --installdirs=home
...
mkdir -p /home/tylerrick/bin/
install gem /home/tylerrick/bin/
install gem_mirror /home/tylerrick/bin/
install gem_server /home/tylerrick/bin/
install gemlock /home/tylerrick/bin/
install gemri /home/tylerrick/bin/
install gemwhich /home/tylerrick/bin/
install index_gem_repository.rb /home/tylerrick/bin/
install update_rubygems /home/tylerrick/bin/
<--- bin
---> lib
mkdir -p /home/tylerrick/lib/ruby/
install gemconfigure.rb /home/tylerrick/lib/ruby/
install rubygems.rb /home/tylerrick/lib/ruby/
install ubygems.rb /home/tylerrick/lib/ruby/
---> lib/rbconfig
mkdir -p /home/tylerrick/lib/ruby/rbconfig
install datadir.rb /home/tylerrick/lib/ruby/rbconfig
<--- lib/rbconfig
---> lib/rubygems
mkdir -p /home/tylerrick/lib/ruby/rubygems
install builder.rb /home/tylerrick/lib/ruby/rubygems
install command.rb /home/tylerrick/lib/ruby/rubygems
install command_manager.rb /home/tylerrick/lib/ruby/rubygems
install config_file.rb /home/tylerrick/lib/ruby/rubygems
install custom_require.rb /home/tylerrick/lib/ruby/rubygems
install dependency_list.rb /home/tylerrick/lib/ruby/rubygems
install doc_manager.rb /home/tylerrick/lib/ruby/rubygems
install format.rb /home/tylerrick/lib/ruby/rubygems
install gem_commands.rb /home/tylerrick/lib/ruby/rubygems
install gem_open_uri.rb /home/tylerrick/lib/ruby/rubygems
install gem_openssl.rb /home/tylerrick/lib/ruby/rubygems
install gem_runner.rb /home/tylerrick/lib/ruby/rubygems
install installer.rb /home/tylerrick/lib/ruby/rubygems
install old_format.rb /home/tylerrick/lib/ruby/rubygems
install open-uri.rb /home/tylerrick/lib/ruby/rubygems
install package.rb /home/tylerrick/lib/ruby/rubygems
install remote_fetcher.rb /home/tylerrick/lib/ruby/rubygems
install remote_installer.rb /home/tylerrick/lib/ruby/rubygems
install rubygems_version.rb /home/tylerrick/lib/ruby/rubygems
install security.rb /home/tylerrick/lib/ruby/rubygems
install server.rb /home/tylerrick/lib/ruby/rubygems
install source_index.rb /home/tylerrick/lib/ruby/rubygems
install source_info_cache.rb /home/tylerrick/lib/ruby/rubygems
install source_info_cache_entry.rb /home/tylerrick/lib/ruby/rubygems
install specification.rb /home/tylerrick/lib/ruby/rubygems
install timer.rb /home/tylerrick/lib/ruby/rubygems
install user_interaction.rb /home/tylerrick/lib/ruby/rubygems
install validator.rb /home/tylerrick/lib/ruby/rubygems
install version.rb /home/tylerrick/lib/ruby/rubygems
---> lib/rubygems/commands
mkdir -p /home/tylerrick/lib/ruby/rubygems/commands
install build_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install cert_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install check_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install cleanup_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install contents_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install dependency_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install environment_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install help_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install install_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install list_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install outdated_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install pristine_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install query_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install rdoc_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install search_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install sources_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install specification_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install uninstall_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install unpack_command.rb /home/tylerrick/lib/ruby/rubygems/commands
install update_command.rb /home/tylerrick/lib/ruby/rubygems/commands
<--- lib/rubygems/commands
---> lib/rubygems/digest
mkdir -p /home/tylerrick/lib/ruby/rubygems/digest
install digest_adapter.rb /home/tylerrick/lib/ruby/rubygems/digest
install md5.rb /home/tylerrick/lib/ruby/rubygems/digest
install sha1.rb /home/tylerrick/lib/ruby/rubygems/digest
install sha2.rb /home/tylerrick/lib/ruby/rubygems/digest
<--- lib/rubygems/digest
<--- lib/rubygems
<--- lib
  Successfully built RubyGem
  Name: sources
  Version: 0.0.1
  File: sources-0.0.1.gem


> gem env
RubyGems Environment:
  - VERSION: 0.9.3 (0.9.3)
  - INSTALLATION DIRECTORY: /home/tylerrick/lib/ruby/gems/1.8
  - GEM PATH:
     - /home/tylerrick/lib/ruby/gems/1.8
  - REMOTE SOURCES:
     - http://gems.rubyforge.org

> ln -s /home/tylerrick/lib/ruby/gems/1.8 ~/gems
> ls ~/gems
cache  doc  gems  specifications

Add to ~/.bash_profile:

# gems -> /home/tylerrick/lib/ruby/gems/1.8/
export GEM_PATH=$HOME/gems/gems:/usr/lib/ruby/gems/1.8/gems # Causes it to *read* from both of them combined
export GEM_HOME=$HOME/gems                                  # Causes it to *install* to this location

How I got the [svn-command (category)] gem installed on my [Dreamhost (category)] account.

> . ~/.bash_profile

> gem install svn-command
Bulk updating Gem source index for: http://gems.rubyforge.org
Killed
# Huh? Does Dreamhost have some kind of watchdog that kills any "long-running" process or something??

> ls -l  ~/lib/ruby/gems/1.8/source_cache
-rw-rw-r--  1 tylerrick pg817420 4 May 15 22:56 /home/tylerrick/lib/ruby/gems/1.8/source_cache
> cp ~/lib/ruby/gems/1.8/source_cache ~/lib/ruby/gems/1.8/source_cache.orig

> cp /usr/lib/ruby/gems/1.8/source_cache ~/lib/ruby/gems/1.8/source_cache
cp: cannot stat `/usr/lib/ruby/gems/1.8/source_cache': No such file or directory
> ls /usr/lib/ruby/gems/1.8/
bin  cache  doc  gems  specifications
# What?! Dreamhost, you pretty much suck.

[other host] > scp /usr/lib/ruby/gems/1.8/source_cache tylerrick@tylerrick.com:
[other host] > gem env
Rubygems Environment:
  - VERSION: 0.8.11 (0.8.11)
> mv ~/source_cache ~/lib/ruby/gems/1.8/source_cache
tylerrick: ~ > ls -l  ~/lib/ruby/gems/1.8/source_cache
-rw-r--r--  1 tylerrick pg817420 1834597 May 15 23:04 /home/tylerrick/lib/ruby/gems/1.8/source_cache
> gem install termios
ERROR:  While executing gem ... (NoMethodError)
    undefined method `refresh' for #<Hash:0x405eb3f8>

[other other host] > gem env
RubyGems Environment:
  - VERSION: 0.9.2 (0.9.2)
[other other host] > scp /usr/lib/ruby/gems/1.8/source_cache tylerrick@tylerrick.com:
> mv ~/source_cache ~/lib/ruby/gems/1.8/source_cache
tylerrick: ~ > ls -l  ~/lib/ruby/gems/1.8/source_cache
-rw-r--r--  1 tylerrick pg817420 3251890 May 15 23:08 /home/tylerrick/lib/ruby/gems/1.8/source_cache
tylerrick: ~ > gem install termios
Bulk updating Gem source index for: http://gems.rubyforge.org
Killed
# Stop killing my process, Dreamhost!!

[other other host] > sudo gem install termios
Bulk updating Gem source index for: http://gems.rubyforge.org
Building native extensions.  This could take a while...
Successfully installed termios-0.9.4
[other other host] > scp /usr/lib/ruby/gems/1.8/source_cache tylerrick@tylerrick.com:
> mv ~/source_cache ~/lib/ruby/gems/1.8/source_cache
tylerrick: ~ > ls -l  ~/lib/ruby/gems/1.8/source_cache
-rw-r--r--  1 tylerrick pg817420 3286191 May 15 23:12 /home/tylerrick/lib/ruby/gems/1.8/source_cache
tylerrick: ~ > gem install termios
Building native extensions.  This could take a while...
Successfully installed termios-0.9.4
# That's more like it!!!

> gem install svn-command --include-dependencies
ERROR:  While executing gem ... (RuntimeError)
    Error instaling svn-command:
        svn-command requires colored > 0.0.0
# What?? It should have installed colored automatically. --include-dependencies isn't working like it normally does....

> gem install colored
Successfully installed colored-1.0

 > gem install facets
Successfully installed facets-1.8.54
Installing ri documentation for facets-1.8.54...
Killed

> gem install svn-command --include-dependencies
Successfully installed svn-command, version 0.2.7

> _svn_command_post_install
chmod 755 /home/tylerrick/lib/ruby/gems/1.8/gems/svn-command-0.2.7/bin/rscm_test /home/tylerrick/lib/ruby/gems/1.8/gems/svn-command-0.2.7/bin/command_completion_for_svn_command /home/tylerrick/lib/ruby/gems/1.8/gems/svn-command-0.2.7/bin/svn /home/tylerrick/lib/ruby/gems/1.8/gems/svn-command-0.2.7/bin/_svn_command_post_install

# Add to ~/.bash_profile:
export PATH=`ls -dt --color=never ~/lib/ruby/gems/1.8/gems/svn-command* | head -n1`/bin:$PATH

> . ~/.bash_profile

> svn help
You are using svn-command version 0.2.7

Finally!

Personal tools