openssl @1.0.1b_0 breaks Ruby in macports

Posted by face on May 02, 2012

Aloha,

When updating to the latest macports, openssl 1.0.1 is installed. Then whenever Ruby tries to connect to facebook, you get errors like:

Errno::ECONNRESET (Connection reset by peer – SSL_connect)

The solution…downgrade openssl. You can see what you versions you have installed:

port installed | grep  openssl
  openssl @1.0.0h_0
  openssl @1.0.1_2
  openssl @1.0.1b_0 (active)


Ok Great, we have the old version:


sudo port activate openssl @1.0.0h_0


Oh, but what if you don’t have the correct version already installed? Thats a little trickier:


svn co -r  90715 https://trac.macports.org/browser/trunk/dports/devel/openssl
cd openssl
sudo port install


Update: Installing Openssl 1.0.1c and rebuilding ruby also fixes the problem


sudo port selfupdate
sudo port update outdated
sudo port uninstall ruby19
sudo port install ruby19 +doc+nosuffix


And now I have ruby 1.9 and openssl 1.0.1c talking to facebook without peer resets.


References:

http://reinout.vanrees.org/weblog/2008/09/19/macports-downgrading-subversion.html https://trac.macports.org/wiki/howto/InstallingOlderPort https://trac.macports.org/log/trunk/dports/devel/openssl/Portfile

A hui hou!


Digg! Delicious! Technorati Blinklist Furl Reddit

Ruby is Paradise and Rails in Paradise

Posted by face on September 26, 2009

I Am Attending Aloha On Rails, The Hawaii Ruby on Rails Conference



I’ve been meaning to attend a rails conference and after moving to Oahu I figured it would be a while. But now the Rails conference is coming to me! So I couldn’t pass and will be at Aloha on Rails.

I hope to see you there!







Digg! Delicious! Technorati Blinklist Furl Reddit

Announcing ratos: A shell to Decode iPhone Stack Traces

Posted by face on February 06, 2009

I’m pleased to give you ratos, a shell to speed iPhone development by decoding an entire stack trace at once using atos. Of course as it relies on atos, so it only works on a Mac with Xcode installed.


 [301] tako:~>  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos>2009-02-05 10:21:31.107 TheSnapper[751:20b] Stack: (
    808221155,
    806100816,
    808224973,
    807957033,
    807851552,
    25785,
    22599,
    22855,
    807923363,

arm

-[BackViewController doubleSnapAction:] (in TheSnapper) (BackViewController.m:192)
-[BackViewController resetAllSiders] (in TheSnapper) (BackViewController.m:126)
-[BackViewController resetSnap:] (in TheSnapper) (BackViewController.m:138)


When I first learned iPhone development it took me a while to find atos. Exception handling comes natural but Xcode spits out addresses in their stack traces. After much googling I finally found atos. I then immediately found Apple’s docs to integrate atos into an exception handler. Cool….NOT!

Turns out Apple’s Xcode integration relies on /usr/bin/atos at runtime….not possible on my iPhone.

So, I immediately wrote a quick and dirty shell in Ruby that takes a stack trace in from xcode, and prints out any lines that have symbols. Gobbledygook in, nice human readable stack trace out!

After enjoying ratos for the past few months I finally had a chance today to clean it up a little and publish it on github.

To use it, first install it on your path.:
git clone git://github.com/face/ratos.git
sudo cp ratos/bin/ratos /usr/local/bin/.
There are a couple environment variables that can be used to configure ratos. Also, if ratos happens to be installed in a project under the directory bin it will self configure. If your application name and directory name are the same and ratos is installed in a shared location like /usr/local/bin, you only need to set RATOS_APP_PATH:
# csh
setenv RATOS_APP_PATH ~/proj/TheSnapper

# or bash
export RATOS_APP_PATH=~/proj/TheSnapper
If your application name is different than the directory name, you can also set RATOS_APP_NAME. Here are some real world examples of how I start up the ratos shell:
 [303] tako:~>  echo $RATOS_APP_PATH
/Users/face/proj/TheSnapper
 [304] tako:~>  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos>exit
 [305] tako:~>  env RATOS_APP_PATH=~/proj/IttyBooks ratos

App Name:TheSnapper
App Path:~/proj/IttyBooks

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos>exit
 [306] tako:~>  env RATOS_APP_PATH=~/proj/IttyBooksFree RATOS_APP_NAME=IttyBooks ratos

App Name:IttyBooks
App Path:~/proj/IttyBooksFree

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos>exit
And finally, here is an example interaction:
 [307] tako:~>  ratos

App Name:TheSnapper
App Path:/Users/face/proj/TheSnapper

Paste xcode stack trace to stdin, then type 'sim' or 'arm' on a line by itself.
  Type 'exit' or '^D' to quit and 'app' to print the current app.

ratos>2009-02-05 10:21:31.107 TheSnapper[751:20b] Stack: (
    808221155,
    806100816,
    808224973,
    807957033,
    807851552,
    25785,
    22599,
    22855,
    807923363,
    816119156,
    816119004,
    816157144,
    8381,
    8244
)
terminate called after throwing an instance of 'NSException'

arm

-[BackViewController doubleSnapAction:] (in TheSnapper) (BackViewController.m:192)
-[BackViewController resetAllSiders] (in TheSnapper) (BackViewController.m:126)
-[BackViewController resetSnap:] (in TheSnapper) (BackViewController.m:138)
main (in TheSnapper) (main.m:14)
start (in TheSnapper) + 52

ratos>exit

Enjoy!


Digg! Delicious! Technorati Blinklist Furl Reddit

ActivityStreams has been extracted from LegalTorrents and Released

Posted by face on September 23, 2008

Screen shot of activity streams on Legaltorrents.com

We have extracted ActivityStreams from Legaltorrents.com and released it under the BSD license.

This is a new plugin for the Rails Community that provides a customizable framework for cataloging and publishing user activity and social objects. We currently aim to provide support for microformats in HTML, Atom feeds, and compatibility with the open source DISO social networking implementation for activity discovery and consumption.

Here is a quickie for Rails 2.1:

./script/plugin install git://github.com/face/activity_streams.git

It may work on earlier versions of Rails as well. Don’t have git:

./script/plugin install svn://rubyforge.org/var/svn/activitystreams/trunk


For further documentation here is the rdoc and the AcitivityStreams Home Page, or just show me the code.


Digg! Delicious! Technorati Blinklist Furl Reddit

Rake task to transfer a Rails database, say from MySQL to Postgres and back again

Posted by face on August 31, 2008


development:
  adapter: mysql
  database: legaltorrents_development
  username: fred
  password: password
  socket: /tmp/mysql.sock

production:
  adapter: postgresql
  database: legaltorrents_production
  username: fred
  password: password
  host: localhost


Thanks to Ruby on Rails, transferring and converting database from one database platform to another only takes a few lines of code. There are rake tasks for dumping to YAML and back. However the existing YAML scripts I found had issues with some of our data and then failed for blobs. This script will only work with a “rails style” database. By “rails style” I mean any database where every table has a unique key named “id”.

A special thanks to Matson Systems, Inc. for having me write this script for LegalTorrents and then contribute it to all under a BSD license.


Be sure to read the warnings in script. Here is a complete example converting a production postgresql database into a development mysql database. Let’s start with config/database.yml found to the left. Now both schemas must be identical. For this example let’s ensure both schemas are at the same migration:
1
2
rake db:migrate
env RAILS_ENV=production rake db:migrate
Ok, let’s get the rake task and run it. Running the rake task may take a long time.
1
2
3
4
5
cd lib/tasks
wget 'http://github.com/face/rails_db_convert_using_adapters/tree/master%2Fconvert.rake?raw=true' -O convert.rake

# and run it
rake db:convert:prod2dev
You should now have a copy of the production data in the development database.


Update Oct 1, 2008:Fixed a bug today for Rails 2.1.1. Also got rid of the hash of data that was a relic from an early version of the script that used a single model object.

Here is the full code to convert.rake:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# Convert/transfer data from production => development.    This facilitates
# a conversion one database adapter type to another (say postgres -> mysql )
#
# WARNING 1: this script deletes all development data and replaces it with
#                     production data
#
# WARNING 2: This script assumes it is the only user updating either database.
#                     Database integrity could be corrupted if other users where 
#                     writing to the databases.
#
# Usage:  rake db:convert:prod2dev
#
# It assumes the development database has a schema identical to the production 
# database, but will delete any data before importing the production data
#
# A couple of the outer loops evolved from 
#    http://snippets.dzone.com/posts/show/3393
#
# For further instructions see 
#    http://myutil.com/2008/8/31/rake-task-transfer-rails-database-mysql-to-postgres
#
# The master repository for this script is at github:
#    http://github.com/face/rails_db_convert_using_adapters/tree/master
#
#
# Author: Rama McIntosh
#         Matson Systems, Inc.
#         http://www.matsonsystems.com
#
# This rake task is released under this BSD license:
#
# Copyright (c) 2008, Matson Systems, Inc. All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in the
#   documentation and/or other materials provided with the distribution.
# * Neither the name of Matson Systems, Inc. nor the names of its
#   contributors may be used to endorse or promote products derived
#   from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

# PAGE_SIZE is the number of rows updated in a single transaction.
# This facilitates tables where the number of rows exceeds the systems
# memory
PAGE_SIZE=10000

namespace :db do
  namespace :convert do    
    desc 'Convert/import production data to development.   DANGER Deletes all data in the development database.   Assumes both schemas are already migrated.'
    task :prod2dev => :environment do

      # We need unique classes so ActiveRecord can hash different connections
      # We do not want to use the real Model classes because any business
      # rules will likely get in the way of a database transfer
      class ProductionModelClass < ActiveRecord::Base
      end
      class DevelopmentModelClass < ActiveRecord::Base
      end

      skip_tables = ["schema_info", "schema_migrations"]
      ActiveRecord::Base.establish_connection(:production)
      (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|

        ProductionModelClass.set_table_name(table_name)
        DevelopmentModelClass.set_table_name(table_name)
        DevelopmentModelClass.establish_connection(:development)
        DevelopmentModelClass.reset_column_information
        ProductionModelClass.reset_column_information
        DevelopmentModelClass.record_timestamps = false

        # Page through the data in case the table is too large to fit in RAM
        offset = count = 0;
        print "Converting #{table_name}..."; STDOUT.flush
        # First, delete any old dev data
        DevelopmentModelClass.delete_all
        while ((models = ProductionModelClass.find(:all, 
            :offset=>offset, :limit=>PAGE_SIZE)).size > 0)

          count += models.size
          offset += PAGE_SIZE

          # Now, write out the prod data to the dev db
          DevelopmentModelClass.transaction do
            models.each do |model|
              new_model = DevelopmentModelClass.new(model.attributes)
              new_model.id = model.id
              new_model.save(false)
            end
          end
        end
        print "#{count} records converted\n"
      end
    end
  end
end

Digg! Delicious! Technorati Blinklist Furl Reddit

Conditionally caching actions when logged in for Rails 2.1 and 2.0

Posted by face on August 31, 2008

Screen shot of Legaltorrents.com

As some of you know I’ve been working full time for Matson Systems, Inc. building out LegalTorrents. I must apologize I have been neglecting parts of my blog. Fortunately, I’ve been swamped building out cool features for LegalTorrents and Matson wants to contribute back. After this caching article look for a rake task to convert a Rails app from one database platform to another, then a plugin for generating Activity Streams.

As a new community, we have to support tens of thousands of registered users. Yet on any given news day we need to support hundreds of thousands of non registered users.


This can be done using action caching and very modest hardware requirements. Given huge hardware resources, using memcached would solve the issue. However, meeting initial demands can be done using action caching with very modest hardware requirements. We use the built-in rails action caching to disk with a TTL hack from cron. We don’t want our logged-in users subjected to a TTL, as their changes should be instantaneous. We simply don’t cache actions for users who are logged in, and provide cached pages for everyone else. As the number of registered users grows… then we’ll use memcached.


Let’s begin with conditional caching in Rails 2.1 (if 2.0, see below). Conditional action caching is a new feature of the Rails 2.1 API. First off, pre Rails 2.1 the default was disk. In rails 2.1, the default is RAM. Not going to work on limited resources:


# Put this in RAILS_ROOT/config/initializers/something.rb
ActionController::Base.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
Ok, the application controller is a great place to decide if we want to cache:

class ApplicationController < ActionController::Base
  # ...
  protected
  # of course logged_in? needs to be defined...restful_authentication is what I recommend.
  def do_caching?
    !logged_in? && flash.empty?
  end
Now we can use the new Rails 2.1 :if feature to conditionally cache actions:

class TorrentsController < ApplicationController
  # ...
  caches_action :show , :if => Proc.new { |controller|
                          controller.send(:do_caching?) }

The final piece of the puzzle is a TTL. We use find to remove files older than 10 minutes, giving us a 10 minute TTL:

# This cron entry that runs every 10 minutes and removes any files older than 10 minutes named '*.cache'
3,13,23,33,43,53 * * * * find /home/ltdeploy/legaltorrents/tmp/cache -mmin +10 -name '*.cache' -exec rm -f {} \;
And that is it. For those of you not familiar with caches action here is a more complex example for a page that integrates the will_paginate plugin using :cache_path:

class CategoriesController < ApplicationController

  caches_action :show, 
    :if => Proc.new { |controller| controller.send(:do_caching?) }, 
    :cache_path => Proc.new { |c|
      c.params[:page] ?
      "#{c.request.host}.#{c.request.port}/#{c.send(:category_path,c.params[:id])}/page/#{c.params[:page]}" :
      "#{c.request.host}.#{c.request.port}/#{c.send(:category_path,c.params[:id])}/page/1"
    }

End of Story for Rails 2.1



Now, Rails 2.0 doesn’t have :if in caches_action. To work around this we used a simple monkey patch:


class ApplicationController < ActionController::Base
  # ...
  protected
  # Overrides Rails core to do action_cache when not logged in...Only works in Rails 2.0 and maybe earlier
  def perform_caching
    @@perform_caching && !logged_in? && flash.empty?
   end
Then we cache as normal:

class TorrentsController < ApplicationController
  # ...
  caches_action :show


Digg! Delicious! Technorati Blinklist Furl Reddit

Yahoo OpenID has extra security constaints

Posted by face on March 05, 2008

OpenID logo

I have a feeling this will help some of y’all if you are getting the following error:

Sorry! Something is not quite right with the request we received from the website you are trying to use. Please try again in a few minutes. If this error persists, please contact the site administrator for the website you are trying to use. If you are the site administrator, click here to contact us.

I get this error if I try to login on my development environment because localhost:3000 just won’t cut it for Yahoo’s OpenID security policy. If I run from a production URL on port 80, say http://myutil.com/ then signin works (though I haven’t gotten Simple Registration Attribute Exchange working with Yahoo).

From the Yahoo OpenID Developers FAQ:
Yahoo! Security Policies Yahoo! will only support Relying Parties running on webservers with real hostnames (IP addresses are not supported) running on standard ports (Port 80 for HTTP and Port 443 for HTTPS).

Hope this saves ya some time!


Digg! Delicious! Technorati Blinklist Furl Reddit

OpenBSD port of Sphinx

Posted by face on February 28, 2008

Sphinx Free open-source SQL full-text search engine

Update July 16th, 2008: Sphinx sphinx-0.9.8 has been released and this port has been updated.

Here is a OpenBSD port of Sphinx, Free open-source SQL full-text search engine. Sphinx is a wonderfully fast and memory efficient deep text search engine. I have found integrates nicely with Ruby and Ruby-On-Rails.

I hope at some point to get this port committed to the OpenBSD CVS repository. In the meantime this will be the ports home. Till it hits the OpenBSDs repository, it will live in my SVN repository here.

You can download a snapshot of the source code for the port here: sphinx.tgz. So far this port has been tested with MySQL and Postgresql on OpenBSD 4.2 and OpenBSD 4.3-betaOpenBSD-4.4-beta on the i386 platform with the Ultrasphinx Ruby-On-Rails plugin.


Instructions to build the port

If your ports tree is not already prepped, please begin by prepping your ports tree.

The port will build much faster if you install the prerequisites via binaries:

sudo su
export PKG_PATH="ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.3/packages/i386"
# or, setenv PKG_PATH "ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.3/packages/i386"
pkg_add libiconv mysql-server mysql-client
exit

Now we are ready to build the sphinx port:


cd /usr/ports/textproc
lynx --source "http://myutil.com/ports/4.4/sphinx.tgz" > sphinx.tgz
tar xvfz sphinx.tgz 
cd sphinx
make install  # or make package
There is also a Postgresql flavor. Follow the instructions above, installing Postgresql instead of MySQL and then instead of make install do:

env FLAVOR=pgsql make install

Thanks, and feedback is always welcome!


Digg! Delicious! Technorati Blinklist Furl Reddit

raspell shared library problems on OpenBSD

Posted by face on February 26, 2008


--- extconf.rb.orig     Tue Feb 26 12:03:53 2008
+++ extconf.rb  Tue Feb 26 11:52:16 2008
@@ -1,5 +1,7 @@
 require "mkmf"
 
+$LIBS += " -lstdc++ -laspell"
+
 have_header("ruby.h")
 have_header("aspell.h")
 have_library("aspell")



I recently installed the raspell gem on my development box as part of an evaluation of ultrasphinx.

Unfortunately, the native extension to raspell doesn’t link in the dynamic libraries it uses. A fix is provided below.

Note, using the raspell with ultrasphinx also caused a ruby core dump, this time in an assertion from the configuration for aspell. OpenBSD uses aspell-0.50.5 and after upgrading aspell to 0.60.5, raspell started working fine.

Here is the output from the dynamic library problem:



** Starting Rails with development environment...
ruby:/usr/local/lib/ruby/gems/1.8/gems/raspell-1.1/lib/raspell.so: undefined symbol 'new_aspell_config'
lazy binding failed!
/home/face/urevz/vendor/plugins/ultrasphinx/lib/ultrasphinx/spell.rb:33: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-openbsd4.2]

A little poking around and I noticed the native library, raspell.so, doesn’t link in libaspell!

A quick fix is to add the libs to extconf.rb and rebuild the library:

  1. cd /usr/local/lib/ruby/gems/1.8/gems/raspell-1.1/ext
  2. edit extconf.rb and add the line $LIBS = ” -lstdc+ -laspell”
  3. sudo make clean
  4. sudo make
  5. sudo cp raspell.so ../lib/.

Digg! Delicious! Technorati Blinklist Furl Reddit

Current Ruby and Ruby-Gem binaries for the current release of OpenBSD

Posted by face on February 12, 2008

Ruby-Forge Header

Here is how to install i386 binaries (please choose an OpenBSD mirror near you…and please buy a t-shirt):


sudo su

#for ksh/bash
export PKG_PATH="ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386"

#or, for tcsh: setenv PKG_PATH=ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386

# Now for Ruby
pkg_add "http://rubyforge.org/frs/download.php/32289/ruby-1.8.6.111.tgz"

# Optional, but Recommend for Rails
pkg_add "http://rubyforge.org/frs/download.php/32290/ruby-gems-1.0.1.tgz"
pkg_add "http://rubyforge.org/frs/download.php/32291/ruby-iconv-1.8.6.111.tgz"

# Now you could install rails if you wanted:
gem install rails

Rubyforge doesn’t allow you to have the same filename, even if it is in a different sub-package and release. Therefore, amd64 and sparc64 binaries are distributed directly from MyUtil.com.

For AMD64 (which runs in IA64 of course):

sudo su
export PKG_PATH="http://myutil.com/ports/4.2/amd64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/amd64/"

# or, setenv PKG_PATH "http://myutil.com/ports/4.2/amd64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/amd64/"

pkg_add ruby-1.8.6.111 ruby-iconv-1.8.6.111 ruby-gems-1.0.1

# Perhaps Ruby-On-Rails:
gem install rails
For sparc64:

sudo su
export PKG_PATH="http://myutil.com/ports/4.2/sparc64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/sparc64/"

# or, setenv PKG_PATH "http://myutil.com/ports/4.2/sparc64/:ftp://ftp3.usa.openbsd.org/pub/OpenBSD/4.2/packages/sparc64/"

pkg_add ruby-1.8.6.111 ruby-iconv-1.8.6.111 ruby-gems-1.0.1

# Maybe Rails?
gem install rails

Thanks, I find these useful and I hope you do too. I now do all my development from a OpenBSD (patched) Desktop and have made these binaries as secure as possible. All binaries are produced behind pf firewalls.

I have a old Mac Mini I can install macppc and produce binaries…if there is a demand.

Puffy swimming

Digg! Delicious! Technorati Blinklist Furl Reddit

The official OpenBSD Ruby 1.8.6-111 ports have been checked into CVS

Posted by face on December 31, 2007

Thanks to Bernd Ahlers, the official OpenBSD ruby 1.8.6-111 ports are now in the OpenBSD CVS Repository.

I have updated my post and associated binaries Ruby 1.8.6p110 on OpenBSD 4.2 to use the official 111 port instead of mine.


Digg! Delicious! Technorati Blinklist Furl Reddit

rubygems-1.0.1 on OpenBSD

Posted by face on December 23, 2007

I started a real update to the port but was unable to complete it quickly. I have more pressing coding tasks and can’t spend the time now to complete the port.

My short term solution is to just use ruby gems to update itself (assuming you already have gem installed, if not see below).

sudo gem update --system

Then, if you want to, update some installed gems (like rails -> 2.0.2)

sudo gem update rails

I updated my systems which run my ruby-1.8.6p110 port. However it should work with the stock ruby and gem which you can install via OpenBSD ports:

sudo su
# setenv PKG_PATH "ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
export  PKG_PATH="ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
pkg_add ruby ruby-gems ruby-iconv

gem update --system

If anyone has a pointer to a completed native port, please let me know.


Digg! Delicious! Technorati Blinklist Furl Reddit

Ruby 1.8.6-111 on OpenBSD 4.2 (and Ruby-On-Rails)

Posted by face on November 04, 2007

Update: December 31, 2007: Official OpenBSD 1.8.6 patch level 111 ports have been checked into CVS. This post and the associated binaries have been updated to use the official port. My unofficial port has been discarded.

This article describes building a ruby port from source. If you want the binaries produced by this article, I have released them via this Rubyforge project.

If your ports tree is not already prepped, please begin by prepping your ports tree.

There is a message that you may run out of memory without modifying login.conf. My login.conf was already modified. My login is a member of the staff group:
staff:\
        :datasize-cur=1024M:\
        :datasize-max=infinity:\
        :maxproc-max=256:\
        :maxproc-cur=128:\
        :ignorenologin:\
        :requirehome@:\
        :tc=default:

We will be using the official OpenBSD port from CVS.

We will start by installing the prerequisites as binaries because if you have a fast internet connection, it is faster than building the ports from src:
sudo su
setenv PKG_PATH "ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
# or export PKG_PATH="ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386" 
pkg_add libiconv gdbm tk-8.4.7p1
exit

Now lets update the ruby port from CVS HEAD and build it. I did this on December 31, 2007 and the snapshot of the source code to the port can be found here: ruby.tgz

export CVSROOT=anoncvs@anoncvs3.usa.openbsd.org:/cvs   # pls choose a mirror near you
# setenv CVSROOT anoncvs@anoncvs3.usa.openbsd.org:/cvs
cd :/usr/ports/lang/ruby
cvs up -rHEAD .
make package
Now we can install it:
sudo su
setenv PKG_PATH './:ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386'
# or:  export PKG_PATH='./:ftp://ftp2.usa.openbsd.org/pub/OpenBSD/4.2/packages/i386'
cd /usr/packages/i386/all
pkg_add ruby-1.8.6.111 
# Or, of you already have ruby installed, try:  pkg_add -r ruby-1.8.6.111
And for a bonus, lets install Ruby-On-Rails:
pkg_add ruby-gems ruby-iconv-1.8.6.111  mysql-server mysql-client

# Update gems to version 1.0.1, apparently needed for rails 2.0.2 but will break things like ruby-openid-1.1.4
gem update --system

gem install rails
# For Rails 1.2.6
# gem install -v 1.2.6 rails

# Now let's optimize ruby for mysql
gem install mysql

# finally, mongrel rocks
gem install mongrel --include-dependencies
gem install mongrel_cluster

If this is a new MySQL install, don’t forget to follow the instructions in /usr/local/share/doc/mysql/README.OpenBSD.

Enjoy!


Digg! Delicious! Technorati Blinklist Furl Reddit