Skip to content

Development Setup

cgriego edited this page Jan 9, 2012 · 27 revisions

This page is for setting up Rubygems on a local development machine to contribute patches/fixes/awesome stuff. If you need to host your own gem server, please consider checking out Geminabox. It’s a lot simpler than Rubygems and may suit your organization’s needs better.

Setup

Some things you’ll need to do in order to get this project up and running:

  • Use Ruby 1.9.3
  • Install bundler: gem install bundler
  • Install redis, version 2.0 or higher. If you have homebrew, do brew install redis -H.
  • Clone the repo: git clone git://github.com/rubygems/rubygems.org
  • Move into your cloned rubygems directory if you haven’t already: cd rubygems.org
  • Rubygems is configured to use PostgreSQL (>= 8.4.x), for MySQL see below. Install with: brew install postgres
  • Install dependencies: bundle --local
  • Setup a database.yml cp config/database.yml.example config/database.yml (double check/update)
  • Create the databases: rake db:create:all
  • Redis should be running already, if not, run redis-server.
  • Update the db schema: rake db:migrate
  • Run the tests: rake
  • Start the web server: rails server and browse to localhost:3000

If you need to host gems locally, *you probably don’t need to do this!): Make sure you run rake gemcutter:index:update before running the app on your own machine, this primes the filesystem gem index for local use.

MySQL

  • Modify Gemfile to use mysql instead of pg
  • If you’re running Max OS X Snow Leopard, the MySQL gem will fail to install without configuring it as follows:
bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
export ARCHFLAGS="-arch x86_64"
  • Continue setup as above, installing dependencies, setting up database.yml, etc.

Warning: Gem names are case sensitive (eg. BlueCloth vs. bluecloth 2). MySQL has a utf8_bin collation, but it appears that you still need to do BINARY name = ? for searching. It is recommended that you stick to PostgreSQL >= 8.4.x for development.

MySQL2

  • Remove pg and silent-postgres gems from your Gemfile
  • Add mysql2 gem to your Gemfile:
gem "mysql2", "~> 0.2.11" # Actually, you can use any 0.2.x version
  • Run bundle install command

Warning: Specify mysql2 version as I’ve provided, because it would not work with any 0.3.x gem versions.

Working on the Gem

For testing/developing the gem, cd into the gem directory. Please keep the code for the gem in there, don’t let it leak out into the Rails app.

Getting some test data

A good way to get some test data is to import from a local gem directory. gem env will tell you where rubygems stores your gems. Run rake gemcutter:import:process #{INSTALLATION_DIRECTORY}/cache

If you see “Processing 0 gems…” you’ve probably specified the wrong directory. The proper directory will be full of .gem files.

Pushing gems

In order to push a gem to your local installation use a command like the following:

RUBYGEMS_HOST=http://localhost:3000 gem push hola-0.0.3.gem 

Database Layout

Courtesy of Rails ERD

Contributing

Be sure to read through the Contribution Guidelines.

Clone this wiki locally