-
-
Notifications
You must be signed in to change notification settings - Fork 928
Development Setup
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.
Some things you’ll need to do in order to get this project up and running:
Environment:
- 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
, if you use macports, dosudo port install redis
. - Rubygems is configured to use PostgreSQL (>= 8.4.x), for MySQL see below. Install with:
brew install postgres
Get the code:
- 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
Setup the database:
- Get set up:
./script/setup
- Run the database rake tasks if needed:
rake db:create:all db:drop:all db:setup db:test:prepare --trace
Running tests:
- Start redis:
redis-server
(The test environment expects Redis to be available via a unix socket) - Run the tests:
rake
Developing on rubygems.org:
- Set the REDISTOGO_URL environment variable. For example:
REDISTOGO_URL="redis://localhost:6379"
- Import gems if you want to seed the database.
rake gemcutter:import:process PATHTO_GEMS/cache
– To import a small set of gems (rather than all you have installed) you can point the import process to any gems cache directory, like a very small `rvm` gemset for instance. - If you need the index available – needed when working in conjunction with bundler-api – then run
gemcutter:index:update
. This primes the filesystem gem index for local use. - Start the web server:
rails server
and browse to localhost:3000 or use Pow !
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
- Modify Gemfile to use
mysql
instead ofpg
- 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 autf8_bin
collation, but it appears that you still need to doBINARY name = ?
for searching. It is recommended that you stick to PostgreSQL >= 8.4.x for development.
- Remove
pg
andsilent-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.
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.
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.
Courtesy of Rails ERD
Be sure to read through the Contribution Guidelines.