Robby on Rails: Install Ruby, Rails, and PostgreSQL on OSXthoughts.sort_by{|t| t[:topic]}.collect tag:www.robbyonrails.com,2005:TypoTypo2007-06-19T16:09:12-04:00Robby Russellurn:uuid:6faf4e72-89d7-433c-8e6a-0595090015622006-05-29T09:46:00-04:002007-06-19T16:09:12-04:00Install Ruby, Rails, and PostgreSQL on OSX<div class="warning">
<strong><span class="caps">WARNING</span>:</strong> This post contains some outdated instructions. Please read <a href="http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition"> Installing Ruby on Rails and PostgreSQL on <span class="caps">OS X</span>, Second Edition</a>.
</div>
<p>Our Creative Director, Allison Beckwith, picked up a new black MacBook this weekend and I had the luxury of getting it setup to model our standard setup. We all try to keep our setups fairly similar so that we don’t hit too many issues when working together on projects.</p>
<p>I’ll try to keep this short and to the point… because if you’re like me… you just want to start playing with Rails! ;-)</p>
<p>The steps I followed to get her setup like the rest of the development team at <a href="http://www.planetargon.com"><span class="caps">PLANET ARGON</span></a> went something like this.</p>
<h3>XCode and DarwinPorts</h3>
<ul>
<li>Download and install <a href="http://iterm.sf.net/">iterm</a> (the Universal dmg)</li>
<li>Download and install XCode tools from Apple (dmg)</li>
<li>Download and install <a href="http://darwinports.opendarwin.org/">DarwinPorts</a> (dmg)</li>
<li>Start up iterm.</li>
</ul>
In this step we are going to modify the default bash profile so that every user on the machine that uses bash will get the path for darwinports in their bash_profile.
<pre><code>sudo vi /etc/profile</code></pre>
<p>Modify the following line to include <code>/opt/local/bin</code> in the <span class="caps">PATH</span>… save the file (see vim documentation for details)</p>
<pre><code>
PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin"
</code></pre>
<h3>Ruby and Rails</h3>
<ul>
<li>Open up a new iterm tab (apple-t)</li>
<li>Install ruby with darwinports with: <code>sudo port install ruby rb-rubygems</code></li>
<li>Install Ruby on Rails and all its dependencies with: <code>sudo gem install -y rails</code></li>
</ul><div class="warning">
<strong><span class="caps">WARNING</span>:</strong> This post contains some outdated instructions. Please read <a href="http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition"> Installing Ruby on Rails and PostgreSQL on <span class="caps">OS X</span>, Second Edition</a>.
</div>
<p>Our Creative Director, Allison Beckwith, picked up a new black MacBook this weekend and I had the luxury of getting it setup to model our standard setup. We all try to keep our setups fairly similar so that we don’t hit too many issues when working together on projects.</p>
<p>I’ll try to keep this short and to the point… because if you’re like me… you just want to start playing with Rails! ;-)</p>
<p>The steps I followed to get her setup like the rest of the development team at <a href="http://www.planetargon.com"><span class="caps">PLANET ARGON</span></a> went something like this.</p>
<h3>XCode and DarwinPorts</h3>
<ul>
<li>Download and install <a href="http://iterm.sf.net/">iterm</a> (the Universal dmg)</li>
<li>Download and install XCode tools from Apple (dmg)</li>
<li>Download and install <a href="http://darwinports.opendarwin.org/">DarwinPorts</a> (dmg)</li>
<li>Start up iterm.</li>
</ul>
In this step we are going to modify the default bash profile so that every user on the machine that uses bash will get the path for darwinports in their bash_profile.
<pre><code>sudo vi /etc/profile</code></pre>
<p>Modify the following line to include <code>/opt/local/bin</code> in the <span class="caps">PATH</span>… save the file (see vim documentation for details)</p>
<pre><code>
PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin"
</code></pre>
<h3>Ruby and Rails</h3>
<ul>
<li>Open up a new iterm tab (apple-t)</li>
<li>Install ruby with darwinports with: <code>sudo port install ruby rb-rubygems</code></li>
<li>Install Ruby on Rails and all its dependencies with: <code>sudo gem install -y rails</code></li>
</ul>
<h3>PostgreSQL and Ruby libs</h3>
<ul>
<li>Install PostgreSQL8 with: <code>sudo port install postgresql8</code></li>
<li>We need to modify the <code>/etc/profile</code> file again because the postgresql8 install doesn’t add programs like pg_ctl to /opt/local/bin. Change the <span class="caps">PATH</span> to now look like this and save.</li>
</ul>
<pre><code>
PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/opt/local/lib/pgsql8/bin"
</code></pre>
<ul>
<li>Install the <strong>postgres</strong> gem with: <code>sudo gem install postgres</code>
<ul>
<li>Oh NO!!! You should see an error about it not finding libraries… what will we do?</li>
</ul></li>
</ul>
<pre><code>
cd /opt/local/lib/ruby/gems/1.8/gems/postgres-0.7.1
sudo ruby extconf.rb --with-pgsql-include=/opt/local/include/pgsql8 --with-pgsql-lib=/opt/local/lib/pgsql8
sudo make && sudo make install
# for good measure...
sudo gem install postgres
</code></pre>
<p><strong>Successfully installed postgres-0.7.1</strong></p>
<h3>Configure PostgreSQL for single user</h3>
<p>In our development environments, we don’t find it necessary to keep PostgreSQL running all the time on our servers. We only want it running when we’re doing development. We also typically install it per user on a machine to keep us from needing things like usernames and passwords to connect to it from an application we’re running on the machine. Let’s setup PostgreSQL the <span class="caps">PLANET ARGON</span> way!</p>
<ul>
<li>Open up iterm and go to your home directory</li>
<li>Init your new PostgreSQL database with: <code>initdb -D pgdata</code></li>
<li>Start up PostgreSQL with: <code>pg_ctl -D pgdata -l pgdata/psql.log start</code></li>
<li>Create a new database with: <code>createdb argon_development</code></li>
<li>Test the new database with: <code>psql argon_development</code></li>
<li>Did it load up your new database? If so, great! If not… check your steps… :-)</li>
</ul>
<h3>Test Rails + PostgreSQL</h3>
<ul>
<li>Navigate to a directory where you don’t mind sticking projects… <code>mkdir development; cd development</code></li>
<li>Generate a new Rails application with: <code>rails -d postgresql argon</code></li>
<li>Navigate to new Rails application directory. <code>cd argon</code></li>
<li>Generate a new model to test with: <code>./script/generate model Argonista</code></li>
<li>Edit and save the migration that was generated ( <code>db/migrate/001_create_argonistas.rb</code> ) file with your favorite editor…</li>
</ul>
<pre><code>
class CreateArgonistas < ActiveRecord::Migration
def self.up
create_table :argonistas do |t|
t.column :name, :string
t.column :blog_url, :string
end
end
def self.down
drop_table :argonistas
end
end
</code></pre>
<ul>
<li>Edit <code>config/database.yml</code> to look like the following… you’ll notice that we don’t need to supply a username or password.</li>
</ul>
<pre><code>
development:
adapter: postgresql
database: argon_development
test:
adapter: postgresql
database: argon_test
production:
adapter: postgresql
database: argon_production
</code></pre>
* Run the migration with: <code>rake db:migrate</code>
<pre><code>
$ rake db:migrate
(in /Users/allisonbeckwith/development/argon)
== CreateArgonistas: migrating ================================================
-- create_table(:argonistas)
NOTICE: CREATE TABLE will create implicit sequence "argonistas_id_seq" for serial column "argonistas.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "argonistas_pkey" for table "argonistas"
-> 0.0399s
== CreateArgonistas: migrated (0.0402s) =======================================
</code></pre>
* Test your new model from console
<pre><code>
$ ./script/console
Loading development environment.
>> a = Argonista.new
=> #<Argonista:0x24569dc @attributes={"name"=>nil, "blog_url"=>nil}, @new_record=true>
>> a.name = 'Robby'
=> "Robby"
>> a.blog_url = 'http://www.robbyonrails.com'
=> "http://www.robbyonrails.com"
>> a.save
=> true
>> exit
</code></pre>
* Great, let’s go look at our database table…
<pre><code>
$ psql argon_development
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
argon_development=# SELECT * FROM argonistas;
id | name | blog_url
----+-------+-----------------------------
1 | Robby | http://www.robbyonrails.com
(1 row)
</code></pre>
<p>There we go, we’ve setup Ruby, Rails, and PostgreSQL on a brand new Intel MacBook without breaking a sweat!</p>
<h3>Extra Goodies</h3>
<ul>
<li>Subversion: <code>sudo port install subversion</code></li>
<li>Lighttpd: <code>sudo port install lighttpd</code></li>
<li>ImageMagick: <code>sudo port install ImageMagick</code> (known to take a while…)</li>
<li>GraphicsMagick: <code>sudo port install GraphicsMagick</code></li>
<li>Install the rmagick gem: <code>sudo gem install rmagick</code></li>
</ul>
<p>Have fun!</p>Manjoorurn:uuid:471c840b-9a3b-4fa1-b7d9-87a7e94537042006-07-13T06:00:30-04:002006-09-05T22:12:43-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Manjoor<p>mail me at <a href="mailto:manzoor@aboutd.com" rel="nofollow">manzoor@aboutd.com</a> phone me at +91-9829298623
india. i wat ur mail or phone</p>Manjoorurn:uuid:dc98afdc-2598-4ff9-bb54-ffe9ec5789b62006-07-13T05:59:03-04:002006-09-05T22:12:51-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Manjoor<p>hi</p>Manjoorurn:uuid:ee04c202-a69c-4a21-939e-c0ad31b57ea32006-07-13T05:58:26-04:002006-09-05T22:12:50-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Manjoor<p>hi isr i am manjoor alihere i want asoftware Cd of postgreSQl version 8.1.3
sir plz help me to run my project to it because it uninstall on my PC
your friend
Er. Manjoor Ali</p>Dan Burn:uuid:ffb527f7-9c0b-4302-a6ec-eb8d6dc3ee752006-07-09T16:05:47-04:002006-09-05T22:12:53-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Dan B<p>Nice writeup.
I’m having problems with getting ruby and postgresql installed. They both depend on readline and darwinports cannot install readline:</p>
<p>mac:~ mac$ sudo port install readline
Password:</p>
<p>-> Fetching readline
-> Attempting to fetch readline51-001 from
ftp://ftp.cwru.edu/pub/bash/readline-5.1-patches/
-> Attempting to fetch readline51-001 from
<a href="http://distfiles-od.opendarwin.org/" rel="nofollow">http://distfiles-od.opendarwin.org/</a>
-> Attempting to fetch readline51-001 from
<a href="http://distfiles-msn.opendarwin.org/" rel="nofollow">http://distfiles-msn.opendarwin.org/</a>
-> Attempting to fetch readline51-001 from
<a href="http://distfiles-bay13.opendarwin.org/" rel="nofollow">http://distfiles-bay13.opendarwin.org/</a>
Error: Target com.apple.fetch returned: fetch failed
Error: /opt/local/bin/port: Status 1 encountered during processing.
mac:~ mac$</p>
<p>I did find a readline tar-ball here:
ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz</p>
<p>Is there any way I can graft it on to /opt/local so that ports [ ruby for example ],
which depend on it can get installed?</p>
<p>Thanks,
-Dan</p>Joeurn:uuid:0ce9ff98-b8f7-481d-a35f-102a21a201652006-06-25T15:19:03-04:002006-09-05T22:12:51-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Joe<p>Well, since it’s aPple, why isn’t it xCode?</p>chrisurn:uuid:1ef907da-7555-4344-9e01-dfd15d191ce62006-06-24T13:54:05-04:002006-09-05T22:12:51-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by chris<p>Thanks for the help.</p>
<p>Good stuff.</p>zorphurn:uuid:aae2d3d5-5a5e-443e-a654-473f247633e52006-06-21T21:28:18-04:002006-09-05T22:12:51-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by zorph<p>Leaving out the username and password in database.yml caused an error when I tried to rake migrate. When I put the username and password back in, it migrated!
(I’m setting up rails/postgresql on windows XP though)</p>Chrisurn:uuid:2e173e68-3bf9-4f59-b84f-951571ba24ba2006-06-14T14:10:28-04:002006-09-05T22:12:51-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Chris<p>For a new developer, this site is so useful. Tips like these that help me streamline my own forming processes. Thanks!</p>Jim Greerurn:uuid:aa3d71ad-b936-4b6c-8394-b9e5a1c17eed2006-06-06T23:21:04-04:002006-09-05T22:12:50-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Jim Greer<p>Works for me!</p>David Salgadourn:uuid:cfe1df74-d3d0-4d07-ac66-26f833a0b8b82006-06-03T03:47:44-04:002006-09-05T22:12:54-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by David Salgado<p>Very useful article – many thanks.</p>
<p>On my Powerbook running Panther, I got a complaint about autoconf versions when trying to do “sudo port install ruby rb-rubygems”.</p>
<p>To fix this, simply;</p>
<pre><code>sudo port install autoconf
sudo port install ruby rb-rubygems</code></pre>
<p>Thanks again.</p>
<p>David</p>Al Hulatonurn:uuid:c335979a-0cd3-43b2-a2f3-14c4d089348b2006-05-31T09:40:42-04:002006-09-05T22:12:48-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Al Hulaton<p>Very timely article. I just got a Macbook Pro and was about to muddle through the postgres install. Now I can just copy your homework. Thanks!</p>Jacob Harrisurn:uuid:6dc0ffd3-94bd-4f37-b36e-461c180573992006-05-30T14:02:36-04:002006-09-05T22:12:54-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Jacob Harris<p>FYI, there was an issue where Postgresql would fight with iChat for shared memory when you attempted to do a video chat (it would get a signal fine from the iSight for preview, but then complain there was no signal when a chat is initiated). There is a fix on the Interwebs, but I figured I’d let you know in case allisbe’s iChat starts acting up.</p>Davidurn:uuid:38cfa1f8-c97b-493a-be8e-bf25715126772006-05-30T09:36:32-04:002006-09-05T22:12:52-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by David<p>Just a minor correction: It’s spelled Xcode, not XCode. Seriously, nobody calls you RObby, do they?</p>Xenithurn:uuid:07f189ac-76a0-49a9-b754-21873bb081812006-05-29T16:21:14-04:002006-09-05T22:12:54-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by Xenith<p>There’s no need to recompile the postgres gem. You can pass the configure options straight to the gem using <code>--</code> as so:</p>
<code>sudo gem install postgres -- --with-pgsql-include=/opt/local/include/pgsql8 --with-pgsql-lib=/opt/local/lib/pgsql8</code>atmosurn:uuid:56c7c8be-d365-4457-81a1-ecafc1810e462006-05-29T11:30:27-04:002006-09-05T22:12:53-04:00Comment on Install Ruby, Rails, and PostgreSQL on OSX by atmos<p>I did a similar writeup but did a few things differently. :) You can check out my macbook pro how-to <a href="http://www.atmos.org/2006/5/10/macbook-rails-howto" rel="nofollow">here</a> .</p>