Skip to content

Commit 668bf4e

Browse files
committed
The wrong version actually got moved to this branch when I tried to clean some things up. This version should be correct :-)
1 parent ab8c1b7 commit 668bf4e

1 file changed

Lines changed: 79 additions & 11 deletions

File tree

docs/DEVELOPMENT-OSX-NATIVE.md

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,51 @@
22

33
These instructions assume you have read and understood the **[Discourse Advanced Developer Install Guide](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md)**.
44

5-
While you can, of course, build or use a vagrant environment on OS X, if you already develop Rails apps on OS X, you might prefer to just work in your native environment. These instructions assume you're already developing with Ruby, at least, if not with Rails, natively on OS X.
5+
OS X has become a popular platform for developing Ruby on Rails applications; as such, if you run OS X, you might find it more congenial to work on **[Discourse](http://discourse.org)** in your native environment. These instructions should get you there.
66

7-
As the OS X page at rvm.io suggests, setting up the environment to be "safe" for building one's own ruby environment is slightly fraught with peril because of Apple's switch to CLANG based compilers. If you're **not** already working successfully with RVM-based Ruby in OS X, it might be easier to stick with vagrant/Linux for now!
7+
Obviously, if you **already** develop Ruby on OS X, a lot of this will be redundant, because you'll have already done it, or something like it. If that's the case, you may well be able to just install Ruby 2.0 using RVM and get started! Discourse has enough dependencies, however (note: not a criticism!) that there's a good chance you'll find **something** else in this document that's useful for getting your Discourse development started!
88

99
## Unicode
1010

1111
OS X 10.8 uses Unicode by default. You can, of course, double-check this by examining LANG, which appears to be the only relevant environment variable.
1212

13+
## OSX Development Tools
14+
15+
As the [RVM website](http://rvm.io) makes clear, there are some serious issues between MRI Ruby and the modern Xcode command line tools, which are based on CLANG and LLVM, rather than classic GCC.
16+
17+
This means that you need to do a little bit of groundwork if you do not already have an environment that you know for certain yields working rubies and gems.
18+
19+
You will want to install XCode Command Line Tools. If you already have XCode installed, you can do this from within XCode's preferences. You can also install just the command line tools, without the rest of XCode, at [Apple's developer site](https://developer.apple.com/downloads/index.action). You will need these more for some of the headers they include than the compilers themselves.
20+
21+
You will then need the old GCC-4.2 compilers, which leads us to...
22+
23+
## Homebrew
24+
25+
**[Homebrew](http://mxcl.github.com/homebrew)** is a package manager for ports of various Open Source packages that Apple doesn't already include (or newer versions of the ones they do), and competes in that space with MacPorts and a few others. Brew is very different from Apt, in that it often installs from source, and almost always installs development files as well as binaries, especially for libraries, so there are no special "-dev" packages.
26+
27+
RVM (below) can automatically install homebrew for you with the autolibs setting, but doesn't install the GCC-4.2 compiler package when it does so, possibly because that package is not part of the mainstream homebrew repository.
28+
29+
So, you will need to install Homebrew separately, based on the instructions at the website above, and then run the following from the command line:
30+
31+
brew tap homebrew/dupes # roughly the same to adding a repo to apt/sources.list
32+
brew install apple-gcc42
33+
gcc-4.2 -v # Test that it's installed and available
34+
35+
(You may note the Homebrew installation script requires ruby. This is not a chicken-and-egg problem; OS X 10.8 comes with ruby 1.8.7)
36+
1337
## RVM and Ruby
1438

15-
RVM supports OS X. For other 'packages', **[Homebrew](http://mxcl.github.com/homebrew)** is recommended as the package manager. Brew is very different from Apt, in that it often installs from source, and almost always installs development files as well as binaries, especially for libraries, so there are no special '-dev' packages.
39+
While some people dislike magic, I recommend letting RVM do most of the dirty work for you.
40+
41+
### RVM from scratch
1642

17-
While some people dislike magic, I recommend letting RVM do the dirty work for you. The following invocations will cover all of the ground that the Ubuntu instructions cover with apt-get.
43+
If you don't have RVM installed, the "official" install command line on rvm.io will take care of just about everything you need, including installing Homebrew if you don't already have it installed. If you do, it will bring things up to date and use it to install the packages it needs.
1844

19-
If you don't have RVM installed, the "official" install command line on rvm.io will take care of just about everything you need:
45+
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
2046

21-
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled # Or, --ruby=1.9.3
47+
**IMPORTANT** As of this writing, there is a known bug in rubygems that will make it appear to not properly install. It's fibbing. It installs just fine.
48+
49+
### Updating RVM
2250

2351
If you do already have RVM installed, this should make sure everything is up to date for what you'll need.
2452

@@ -31,23 +59,48 @@ If you do already have RVM installed, this should make sure everything is up to
3159
# If autolibs is set to 0-2, it will give an error for things that are missing, instead.
3260
rvm requirements
3361

62+
Either way, you'll now want to install the 'turbo' version of Ruby 2.0.
63+
3464
# Now, install Ruby
3565
rvm install 2.0.0-turbo
3666
rvm use 2.0.0-turbo --default # Careful with this if you're already developing Ruby
3767

68+
## Git
69+
70+
### Command line
71+
72+
OS X comes with Git (which is why the LibXML2 dance above will work before this step!), but I recommend you update to Homebrew's version:
73+
74+
brew install git # 1.8.2 is current
75+
76+
You should now be able to check out a clone of Discourse.
77+
78+
### SourceTree
79+
80+
Atlassan has a free GIT client for OS X called [SourceTree](http://www.sourcetreeapp.com/download/) which can be extremely useful for keeping visual track of what's going on in Git-land. While it's arguably not a full substitute for command-line git (especially if you know the command line well), it's extremely powerful for a GUI version-control client.
81+
3882
## Postgres 9.2
3983

4084
**NOTA BENE** As I'm writing this, Postgres is known to have some sort of hideous security problem that is supposed to be patched Real Soon Now. Be careful!
4185

42-
OS X ships with postgres, but you're better off going with the latest from Homebrew.
86+
OS X ships with Postgres 9.1.5, but you're better off going with the latest from Homebrew or [Postgres.App](http://postgresapp.com).
4387

44-
Whereas Ubuntu installs postgres with 'postgres' as the default superuser, Homebrew installs it with the user who installed it as such...and yet with 'postgres' as the default database. Go figure. However, the seed data currently has some dependencies on their being a 'postgres' user, so we create one below.
88+
### Using Postgress.app
89+
90+
[Instructions pending]
4591

46-
In theory, you're not setting up with vagrant, either, and shouldn't need a vagrant user; however, again, all the seed data assumes 'vagrant'. To avoid headaches, it's probably best to go with this flow, so again, we create a 'vagrant' user.
4792

48-
Using Homebrew:
93+
### Using Homebrew:
94+
95+
Whereas Ubuntu installs postgres with 'postgres' as the default superuser, Homebrew installs it with the user who installed it as such...and yet with 'postgres' as the default database. Go figure.
96+
97+
However, the seed data currently has some dependencies on their being a 'postgres' user, so we create one below.
98+
99+
In theory, you're not setting up with vagrant, either, and shouldn't need a vagrant user; however, again, all the seed data assumes 'vagrant'. To avoid headaches, it's probably best to go with this flow, so again, we create a 'vagrant' user.
49100

50101
brew install postgresql # Installs 9.2
102+
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
103+
51104
export PATH=/usr/local/opt/postgresql/bin:$PATH # You may want to put this in your default path!
52105
initdb /usr/local/var/postgres -E utf8
53106
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@@ -63,11 +116,19 @@ Using Homebrew:
63116
psql -d discourse_development -c "CREATE EXTENSION hstore;"
64117
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
65118

66-
You should not need to alter /usr/local/var/postgres/pg_hba.conf
119+
You should not need to alter `/usr/local/var/postgres/pg_hba.conf`
120+
121+
### Loading seed data
122+
123+
From the discource source tree:
124+
125+
psql -d discourse_development < pg_dumps/development-image.sql
67126

68127
## Redis
69128

70129
brew install redis
130+
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
131+
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
71132

72133
That's about it.
73134

@@ -77,6 +138,13 @@ Homebrew loves you.
77138

78139
brew install phantomjs
79140

141+
## Now, test it out!
80142

143+
Copy `config/database.yml.sample` and `config/redis.yml.sample` to `config/database.yml` and `config/redis.yml` and input the correct values to point to your postgres and redis instances. If you stuck to all the defaults above, chances are the samples will work out of the box!
81144

145+
bundle install # Yes, this DOES take a while. No, it's not really cloning all of rubygems :-)
146+
rake db:migrate
147+
rake db:test:prepare
148+
rake db:seed_fu
149+
bundle exec rspec # All specs should pass
82150

0 commit comments

Comments
 (0)