Ammar's Techno Babble

All kinds of technology related things I learn and jot down.

  • Postgres pg Gem Install Failure

    • 15 Jan 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost
    I ran into a few issues while installing the "pg" gem that is required for communication with the Postgres database.  The error that I was seeing was:

    Can‘t find the ‘libpq-fe.h header
    *** extconf.rb failed ***

    I didn't understanf because I had Postgres installed correctly in the /Library/PostgreSQL directory.  After doing some research I figured it out.  The build architectures between Ruby and Postgres were not matching.

    I ran the following to figure out what the architectures were.

    For Ruby:

    file $(which ruby)

    /Users/ammarmayk/.rvm/rubies/ruby-1.8.7-p330/bin/ruby: Mach-O 64-bit executable x86_64

    For my Postgres 8.4:

    file $(which psql)

    ./psql: Mach-O universal binary with 2 architectures
    ./psql (for architecture ppc):    Mach-O executable ppc
    ./psql (for architecture i386):    Mach-O executable i386

    As you can see Postgres was not build for the x86_64 architecture and that is all I had for my Ruby.  So I decided to upgrade the Postgres to the newest version, 9.0.

    I downloaded the DMG installer from the Postgres site and installed it, I made sure to replace Postgres 8.4 with the new 9.0 in my .profile file.

    I added this to the path /Library/PostgreSQL/9.0/bin.

    Then after this I ran the file command again, this time Postgres showed that it had been built for the x86_64 architecture.

    ammar-yousufs-macbook-pro:~ ammarmayk$ file $(which psql)
    /Library/PostgreSQL/9.0/bin/psql: Mach-O universal binary with 3 architectures
    /Library/PostgreSQL/9.0/bin/psql (for architecture ppc7400):    Mach-O executable ppc
    /Library/PostgreSQL/9.0/bin/psql (for architecture i386):    Mach-O executable i386
    /Library/PostgreSQL/9.0/bin/psql (for architecture x86_64):    Mach-O 64-bit executable x86_64

    Now when I did a "gem install pg" it all went through without any problems.

    Hope that helps anyone having Postgres woes.

    • Tweet
  • RVM and Redline Errors on Snow Leopard

    • 15 Jan 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost

    Today I was installing ruby-1.8.7-p330 on my MacBook Pro for my RVM instance.  I kept getting these weird errors about readline.c, I had no idea what the readline.c was or what it was used for.

    readline.c: In function ‘username_completion_proc_call’:
    readline.c:730: error: ‘username_completion_function’ undeclared (first use in this function)
    readline.c:730: error: (Each undeclared identifier is reported only once
    readline.c:730: error: for each function it appears in.)
    make[1]: *** [readline.o] Error 1
    make: *** [all] Error 1

    After some Googl'in I learned that Readline is a C library that is used for reading in a line of text from a provided file handle and returns a character pointer.  When Ruby was trying to build it was having a conflict with the version of Readlines that were installed on the system, there were  two, one that came with OS X and one that was installed my MacPort.

    OS X has it installed in /usr/lib and MacPorts has it installed in /usr/local/lib.

    We have to use the version that was installed by MacPorts.

    Specify the version of Readline to use when installing ruby-1.8.7-p33 like this:

    rvm install ruby-1.8.7-p330 --with-readline-dir=/usr/local
    Once I specified the location of readline the installed went through successfully.

     

    • Tweet
  • Ruby's Dir Class is Awesome

    • 6 Jan 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost
    I'm working on a new project at work and I needed to require all the model classes in our project for a script, so I did it individually one by one, then my friend Tony showed me a nicer way to include all the model files in one line.  Thanks Tony!

    He used Ruby's Dir class, which allows you to interact with the file system's directories. 

    Dir.glob("#{LIBPATH}/../app/models/*.rb").each { |file| require file }

    So now with this one liner I have successfully required all the models in my project.

    To find more about the Dir class you can check out the Ruby doc.
    http://ruby-doc.org/core/classes/Dir.html
    • Tweet
  • Speeding up Project Search in Textmate

    • 5 Jan 2011
    • 2 Responses
    •  views
    • ack textmate
    • Edit
    • Delete
    • Tags
    • Autopost
    So I've been using Textmate for about three years now, overall I've been pretty happy with it, except for the fact that you can't do split screen and the searching is very very slow.  Well for my second problem I've found a solution, a friend of mine pointed me to the "Ack in Project" bundle that uses ack to speed up the searching in your project.  Here is a version of "Ack in Project", that allows you to search in particular filetypes, https://github.com/kemayo/ack-tmbundle

    To install it:
    cd ~/Library/Application\ Support/TextMate/Bundles
    git clone git://github.com/kemayo/ack-tmbundle.git Ack.tmbundle
    Then to find something in your project just enter (Command+Shift+a)

    Screen_shot_2011-01-05_at_6
    • Tweet
  • About

    I am a web developer living outside of Washington DC. I love to keep learning new, better ways to program. Currently I am working with Ruby on Rails, Android SDK, and iOS4. I also own a site called Shoutreel.com, we're trying to create a new type of video site that makes it easy for people to share video recordings with family and friends.

    11601 Views
  • Archive

    • 2011 (10)
      • March (1)
      • February (2)
      • January (7)
    • 2010 (3)
      • December (3)

    Get Updates

    Subscribe via RSS
    Twitter