Rails port/OS X

From OpenStreetMap Wiki
< Rails port(Redirected from Rails on OS X)
Jump to: navigation, search

Some useful info if you're trying to get the Rails port installed on OS X. It is possible to install an OSM test server on OS X 10.3 or later.

Contents

From source: Snow Leopard (10.6)

You need to make sure that you have a 64 bit postgres if you are running on Snow Leopard. There is currently (8/9/09) a prebuilt installer with the contrib module, so you will need to compile Postgres and Postgis from source. It is pretty painless assuming that you have the developer tools installed.

I'd recommend installing the PROJ and GEOS frameworks from http://www.kyngchaos.com/software:frameworks rather than trying to compile them yourself.

You can then just follow the standard instructions for Postgres [1] and Postgis [2] with the exceptions of the configure line on Postgis and the creation of the postgres user. For the postgres user you should use the instructions in the first comment of http://www.postgresql.org/docs/8.3/interactive/postgres-user.html. For the postgis instructions you should use the following configure line instead ./configure --with-geosconfig=/Library/Frameworks/GEOS.framework/unix/bin/geos-config --with-projdir=/Library/Frameworks/PROJ.framework/unix

When you install pg you may need to add a custom env, so you should use the following command sudo env ARCHFLAGS='-arch x86_64' gem install pg

From source: Leopard (10.5)

Ruby and Rails

rvm will help you manage versions of Ruby (given that you probably have 1.8.6 on your system and we need 1.8.7). Note that when using rvm, you don't need to sudo gem install, just gem install.

You may need to install the latest version of RubyGems (1.3.1+) [3] and Rails (gem install rails).

RMagick

See http://onrails.org/articles/2007/11/03/installing-rmagick-on-leopard-without-macports-or-fink . Read the comments - some of the URLs in the shell script are likely to fail; good alternatives are provided in the comments. Alternatively try http://benr75.com/articles/2008/03/16/install-rmagick-on-mac-os-x-leopard-from-source .

You'll need the latest libpng from source, and to remove any outdated libpngs from /usr/local/lib . Then, when building ImageMagick from source:

./configure --without-wmf
make
sudo make install

Postgres

Good distributions are available on the Postgres site [4] [5]. It is probably more sensible to put it in /usr/local/pgsql (the installer will prompt you for a location).

If you build from source, don't forget to install the contrib extensions:

cd contrib/
make
sudo make install

If you get "no such file to load -- postgres" then try

sudo gem install postgres -- --with-pgsql-dir=/usr/local/pgsql/

You will need the gist extension for the changeset indexes. To install this:

cd /usr/local/pgsql/share/postgresql/contrib
psql -d openstreetmap -U postgres < btree_gist.sql

or if you have used the installer by EnterpriseDB (linked from postgresql.org), the file is stored in /Library/PostgreSQL/8.3/share/postgresql/contrib/btree_gist.sql .

nokogiri

First build libxml2 from source, then install nokogiri:

export LD_LIBRARY_PATH=/usr/local/lib
export DYLD_LIBRARY_PATH=/usr/local/lib
gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2

You'll want to execute the two exports every time before firing up your OSM server. But don't put it in your .profile as it'll break other stuff. Just make an alias to do the whole lot at once.

libv8

To avoid problems with building, add this to your .profile:

export RUBYOPT="-r rubygems"

From source: Tiger (10.4)/Panther (10.3)

Ruby and Rails

RMagick

RMagick, the Ruby binding for ImageMagick, draws the gpx traces. Installing RMagick on OS X is notoriously complex - the dependencies are difficult enough, but RMagick itself is a complete bitch (for no good reason). RMagick is required for the migrations: if you don't install it then you'll have to configure the database by hand.

http://macournoyer.wordpress.com/2007/06/19/dont-you-wanna-feel-the-rmagick-pain/ is the best bet for Tiger and may be acceptable for Panther. You may need to use your Google mojo for individual libraries (libjpeg, libpng etc. etc.)

The good instructions at http://rmagick.rubyforge.org/install-osx.html but have sadly been neutered to rely on MacPorts.

libxml

You'll need to install libxml, as per here. That's easy - simply download source, ./configure, make, sudo make install.

The next step, Ruby libxml bindings, can be a bit hairy on OS X. You may be able to get them to build straight from source. If not:

Note: this installs Ruby under /usr/local. By default on OS X, Ruby is under /usr. It is possible to use all your old gems/libraries from the new location without reinstalling, but it's a bit involve - ping Richard for details.

Installing using package managers

MacPorts and Fink are designed to make installation easier, but bear in mind that they install stuff in their own directories (/opt or /sw) rather than the OS X standard, /usr/local. If you decide to use either of these, make sure your paths are set up correctly.

MacPorts

sudo port install rb-libxml2 will pull lots of it in for you (and so on).

Fink

Note: this installs Ruby under /sw. By default on OS X, Ruby is under /usr.

Installing the quadtile function

See the main install page.

Fun with paths

This is not necessary for installing OSMRails on OS X, but may be useful if you have some legacy Ruby stuff you don't want to have to reinstall.

The instructions on hivelogic will install in /usr/local. OS X's default Ruby is simply under /usr. If you don't want to have to reinstall all your old gems, then add this to your .profile:

export RUBYLIB=/usr/lib/ruby/1.8:/usr/lib/ruby/1.8/powerpc-darwin8.9.0:/usr/lib/ruby/site_ruby/1.8:/usr/lib/ruby/site_ruby/1.8/powerpc-darwin8.0
export RUBYLIB=/usr/local/lib/ruby/1.8:/usr/local/lib/ruby/1.8/powerpc-darwin8.9.0:/usr/local/lib/ruby/site_ruby/1.8:/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.0:$RUBYLIB
export GEM_HOME=/usr/lib/ruby/gems/1.8

This, however, won't fix anything that's invoked via CGI (i.e. a #!/usr/bin/ruby shebang line). To fix this, change your shebang line to:

#!/usr/local/bin/ruby -I /usr/lib/ruby/1.8:/usr/lib/ruby/1.8/powerpc-darwin8.9.0:/usr/lib/ruby/site_ruby/1.8:/usr/lib/ruby/site_ruby/1.8/powerpc-darwin8.0:/usr/local/lib/ruby/1.8:/usr/local/lib/ruby/1.8/powerpc-darwin8.9.0:/usr/local/lib/ruby/site_ruby/1.8:/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.0

then:

sudo ln -s /usr/lib/ruby/gems /usr/local/lib/ruby/gems
Personal tools
Namespaces
Variants
Actions
site
Toolbox