Skip to content

Instantly share code, notes, and snippets.

@AntelopeSalad
Last active January 2, 2016 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntelopeSalad/8289702 to your computer and use it in GitHub Desktop.
Save AntelopeSalad/8289702 to your computer and use it in GitHub Desktop.
pg gem error
[12:22] <AntelopeSalad> coderanger: i found potentially a severe issue with poise-ruby
[12:22] <AntelopeSalad> well not me, someone who actually knows what he's doing haha
[12:22] <@coderanger> Do tell :)
[12:22] * bluenemo (~bluenemo@unaffiliated/bluenemo) Quit (Remote host closed the connection)
[12:22] <AntelopeSalad> i had issues getting the rails pg gem to work since it uses native c extensions
[12:23] <AntelopeSalad> but the logs seem to track back to it being an issue with how ruby was installed
[12:23] <AntelopeSalad> https://gist.github.com/AntelopeSalad/8285590#file-mkmf-log
[12:23] <AntelopeSalad> there's the mkmf log and the error that also happened when trying to install the gem
[12:23] * scottmuc (~Adium@41-132-90-243.dsl.mweb.co.za) Quit (Quit: Leaving.)
[12:23] <workmad3> coderanger: hehe :) that would be me as AntelopeSalad is cross-posting questions between channels ;)
[12:23] * Phoop (sid20507@gateway/web/irccloud.com/x-utzmhagtxguftutm) has joined #chef
[12:24] <AntelopeSalad> yeah, workmad3 was helping me debug the problem in the rails channel
[12:24] <workmad3> coderanger: and yeah, his logs show issues with openssl symbols when the gem install does its test link against libpq
[12:25] <workmad3> coderanger: as libssl-dev is installed, and openssl version shows a 1.0.1 version, my best guess is that there's an incompatibility with the version the omnibus packaged ruby was built against compared to the version installed
[12:25] <AntelopeSalad> the env is: postgres 9.3.2 , openssl 1.0.1 , ubuntu-server 12.04 32 bit , installed ruby through poise-ruby and i'm using https://github.com/phlipper/chef-postgresql to handle the libpq deps
[12:25] <workmad3> (as it was openssl 1.0.1, not openssl 1.0.1e)
[12:26] <@coderanger> Ahh yeah
[12:26] <@coderanger> check https://github.com/hw-cookbooks/postgresql/blob/master/recipes/ruby.rb#L66-L80
[12:26] <@coderanger> Probably need the same hack
[12:26] <workmad3> oh yeah, I'd forgotten about that one with chef omnibus...
[12:26] <@coderanger> workmad3: And there is no diff between what was built and what is used, its all just in the same folder :)
[12:27] * troyready (~troyready@108-218-176-38.lightspeed.irvnca.sbcglobal.net) has joined #chef
[12:27] <@coderanger> Just need to force it to not use the system lib
[12:27] <workmad3> coderanger: ah, that would make sense :)
[12:27] <AntelopeSalad> so does this mean another 112 versions of ruby to compile for you?
[12:27] <AntelopeSalad> or should i upgrade to a newer openssl?
[12:28] * wateronsand (~Adium@rrcs-173-196-138-66.west.biz.rr.com) has joined #chef
[12:28] * walker_ (walker@nat/rackspace/x-joaovnsxiycmmang) has joined #chef
[12:28] <workmad3> AntelopeSalad: no, it means you need to copy that code to hack around some path issues into your cookbook :)
[12:28] <@coderanger> AntelopeSalad: No, nothing I can do about it from the ruby side, its an issue with the pg gem
[12:28] <masterkorp> guys how do I simulate data bags with test-kitchen ?
[12:28] <AntelopeSalad> tbh i just want to spend the next 8 hours getting capistrano to deploy to the server and then migrate all of the cap stuff to chef deploy
[12:28] <AntelopeSalad> workmad3: so installing ruby with rbenv will not fix it?
[12:29] <AntelopeSalad> (as a temporary solution)
[12:29] <workmad3> AntelopeSalad: it is an openssl version issue... the poise-ruby stuff has a version embedded and installed with it
[12:29] <workmad3> AntelopeSalad: but the gem installation is picking up the system version, not the embedded version
[12:29] <workmad3> AntelopeSalad: ergo, kaboom
[12:29] * mattsmit_ (~mattsmith@62.254.236.250) has joined #chef
[12:29] * scottmuc (~Adium@41-132-90-243.dsl.mweb.co.za) has joined #chef
[12:29] <AntelopeSalad> ok, so i should upgrade openssl?
[12:29] * splittingfield (~m@66.171.190.186) has joined #chef
[12:29] <workmad3> AntelopeSalad: no
[12:30] <workmad3> AntelopeSalad: you can either not use an omnibus install (so you could use rbenv fine) or you could use the workaround that's in the chef postgres cookbook that coderanger just linked to
[12:30] <AntelopeSalad> i'd much rather use poise-ruby, but how would i implement this workaround?
[12:31] <@coderanger> Or you can figure out the issue in lg's extconf and submit a patch
[12:31] <workmad3> AntelopeSalad: you pretty much copy-paste it (that's what I did in my postgres resource :) )
[12:31] * mattsmit_ (~mattsmith@62.254.236.250) Quit (Remote host closed the connection)
[12:31] <@coderanger> AntelopeSalad: Just copy pasta that chunk of code into a recipe without the first line that checks for chef ruby
[12:31] * spulec (~spulec@207.86.141.10) has joined #chef
[12:31] <workmad3> AntelopeSalad: https://github.com/hw-cookbooks/postgresql/blob/master/recipes/ruby.rb#L56-120 <-- onwards
[12:31] <AntelopeSalad> just copy lines 67-80 before where i include_recipe postgres?
[12:31] * mattsmit_ (~mattsmith@62.254.236.250) has joined #chef
[12:31] <workmad3> oh yeah, drop line 58
[12:32] <@coderanger> and change anywhere using RbConfig.ruby
[12:32] <AntelopeSalad> so 56-120 , drop it in before the inclusion of the postgres recipe and manually delete line 58?
[12:32] <@coderanger> to be /opt/whatever/bin/ruby
[12:32] * mattsmith (~mattsmith@80.1.94.250) Quit (Ping timeout: 246 seconds)
[12:33] <workmad3> AntelopeSalad: well, where is the pg gem being installed?
[12:33] * failshell (~failshell@lpr157.lapresse.ca) has joined #chef
[12:33] <workmad3> AntelopeSalad: because that's the place you need to alter
[12:33] <AntelopeSalad> i'm getting syntax errors copy/pasting what you mentioned workmad3
[12:34] <workmad3> coderanger: I suppose what you could do is provide a poise__gem resource, and provide that workaround in there for pg :)
[12:34] <@coderanger> workmad3: I'll get there, eventually :-)
[12:35] <workmad3> start with just the poise_gem resource I guess? :)
[12:35] * Upayavira (~Adium@apache/committer/upayavira) has joined #chef
[12:35] <AntelopeSalad> workmad3: the pg gem is being installed to bundler's --deployment path
[12:35] * pabst^_ is now known as pabst^
[12:35] * pabst^ (~pabst^@thor.phillipbroberts.com) Quit (Changing host)
[12:35] * pabst^ (~pabst^@unaffiliated/pabst/x-4490925) has joined #chef
[12:35] * garrypolley (~garryp@159.140.254.100) Quit (Remote host closed the connection)
[12:35] <AntelopeSalad> i'm using bundle install with --deployment , i guess this packs it locally to my app
[12:35] * objectiveous (~objective@216.129.126.169) Quit (Quit: objectiveous)
[12:35] <workmad3> AntelopeSalad: right... that's gonna be tricky...
[12:36] <AntelopeSalad> i needed to do that because...
[12:36] <AntelopeSalad> i couldn't write to the system path of where i installed ruby
[12:36] * mattsmit_ (~mattsmith@62.254.236.250) Quit (Ping timeout: 246 seconds)
[12:36] * garrypolley (~garryp@159.140.254.100) has joined #chef
[12:36] <AntelopeSalad> bundler/capistrano kept crying because of permission errors
[12:37] * objectiveous (~objective@216.129.126.169) has joined #chef
[12:37] <AntelopeSalad> i'm completely content with installing it to the system path because i only plan to have 1 app per server
[12:37] <@coderanger> basically everything is broken forever
[12:37] <AntelopeSalad> not sure how to solve writing outside tho
[12:37] <AntelopeSalad> i'm still not sure where this chunk needs to be pasted tho
[12:38] <AntelopeSalad> syntax errors left and right, and when i fix them then i have a code block that might not make sense
[12:38] <AntelopeSalad> or should i just say screw it and use the opscode postgres cookbook then settle with version 9.1?
[12:38] <workmad3> AntelopeSalad: what you'd need to do is basically catch if your bundle install raised an error. If it did, assume it's from pg and alter the pg installation based off that workaround
[12:38] * mahmoudimus (~mahmoudim@50-0-128-62.dsl.dynamic.sonic.net) has joined #chef
[12:38] <AntelopeSalad> because that is what this cookbook is right?
[12:39] <workmad3> AntelopeSalad: that wouldn't help in this case
[12:39] <workmad3> AntelopeSalad: the issue is to do with how the pg gem tries to link to openssl conflicting with how an omnibus ruby provides its own embedded openssl...
[12:39] * nicgrayson (~nicgrayso@69.170.149.10) Quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
[12:39] <AntelopeSalad> right but the github code linked before is from the postgres cookbook correct? the opscode one
[12:40] <AntelopeSalad> https://github.com/hw-cookbooks/postgresql/blob/master/recipes/ruby.rb#L56-120
[12:40] <workmad3> AntelopeSalad: yes, that's the workaround to get the pg gem installed into the omnibus ruby that chef provides in order to make the gem available to the chef run
[12:41] * garrypolley (~garryp@159.140.254.100) Quit (Ping timeout: 260 seconds)
[12:41] * iamchrisf (~iamchrisf@rrcs-24-30-228-170.nyc.biz.rr.com) Quit (Quit: iamchrisf)
[12:41] * troyready (~troyready@108-218-176-38.lightspeed.irvnca.sbcglobal.net) Quit (Ping timeout: 264 seconds)
[12:41] <AntelopeSalad> oh, so it has nothing to do with my rails app needing the pg gem too?
[12:41] * thedodd (~Anthony@rrcs-67-78-97-126.sw.biz.rr.com) Quit (Quit: Leaving)
[12:41] * msmoyer (~smoyer@pgw.medplus.com) has joined #chef
[12:41] * freezey (~freezey@rrcs-72-43-115-186.nyc.biz.rr.com) has joined #chef
[12:41] <workmad3> AntelopeSalad: in your case, you're using an omnibus install of ruby for your rails app
[12:42] <AntelopeSalad> yeah and the bundle install is happening from outside of chef, so how can chef recover from a gem install error if chef didn't invoke it?
[12:42] <workmad3> oh, your bundle install isn't part of the chef run?
[12:42] * jhulten (~jhulten@64.124.61.215) has joined #chef
[12:42] <workmad3> yeah, that makes it even harder :)
[12:42] <AntelopeSalad> no, i'm deploying the app with capistrano
[12:42] <AntelopeSalad> with the bundler/cap plugin
[12:42] <@coderanger> So lets rewind
[12:43] <@coderanger> Another way would be to fork the code of the pg gem
[12:43] <@coderanger> apply that patch
[12:43] <AntelopeSalad> i planned to move to a full chef deploy once i got it working with cap because i'm comfortable with cap already
[12:43] <masterkorp> no ideas ?
[12:43] <@coderanger> and tell bundler to install from your fork
[12:43] * mahmoudimus (~mahmoudim@50-0-128-62.dsl.dynamic.sonic.net) Quit (Ping timeout: 246 seconds)
[12:43] <workmad3> AntelopeSalad: alternative 3 would be to get your deployment migrated to chef using rbenv or rvm
[12:43] <@coderanger> masterkorp: You should be able to just use them
[12:43] <@coderanger> masterkorp: Set your bag path correctly in the kitchen.yml
[12:43] <AntelopeSalad> workmad3: i could use rbenv instead of poise-ruby but then testing sucks
[12:43] <workmad3> AntelopeSalad: and once you've got a working deployment, you switch to using poise-ruby and figure out the hack inside the confines of chef
[12:44] <AntelopeSalad> it takes 20min for ruby to compile
[12:44] <workmad3> AntelopeSalad: try rvm then
[12:44] <@coderanger> workmad3: This is a replacement for rbenv, because using rbenv or rvm in production should env
[12:44] <@coderanger> er, end
[12:44] * avishai (~avishai@212.179.223.188) has joined #chef
[12:44] <@coderanger> because its a terrible solution
[12:44] * iamchrisf (~iamchrisf@rrcs-24-30-228-170.nyc.biz.rr.com) has joined #chef
[12:44] <AntelopeSalad> coderanger: then you need to make poise-ruby somehow fix pg
[12:44] <masterkorp> coderanger: hmm, can you give examples ?
[12:44] <AntelopeSalad> because expecting a random rails dev to fork the pm gem is craziness
[12:44] <workmad3> coderanger: I agree, but I'm talking migration here :)
[12:44] <@coderanger> AntelopeSalad: No, I just need to submit a patch to the pg gem
[12:45] <@coderanger> Or someone does, doesn't need to be me
[12:45] <workmad3> coderanger: with the end goal of getting AntelopeSalad migrated to using chef for deployments with poise-ruby but with an intermediate step of using rvm in order to get the deployment migrated
[12:45] <AntelopeSalad> until the pg gem gets fixed, what's the best course of action that i can take that still lets me use poise-ruby?
[12:45] <AntelopeSalad> or is that not possible atm
[12:46] * iamchrisf (~iamchrisf@rrcs-24-30-228-170.nyc.biz.rr.com) Quit (Client Quit)
[12:46] <AntelopeSalad> i don't mind pasting 5000 lines of junk in my recipe if it'll go away eventually, i just want to get my stuff working :D
[12:46] * garrypolley (~garryp@159.140.254.100) has joined #chef
[12:46] * bubu (~bubu@97e2bde0.skybroadband.com) has joined #chef
[12:46] <@coderanger> masterkorp: Should be something like provisioner:\n data_bags_path: ./test/data_bags
[12:46] * svparijs_afk is now known as svparijs
[12:46] <workmad3> AntelopeSalad: unfortunately, you need to understand more of what's going on, I believe
[12:46] <AntelopeSalad> workmad3: i'll take that as, not possible then? heh
[12:46] <@coderanger> AntelopeSalad: You would have to adapt the fix from chef to cap, which is both beyond my knowledge of cap
[12:46] <@coderanger> and too long to deal with this morning
[12:46] <AntelopeSalad> yeah forget that
[12:47] <AntelopeSalad> let's say i move to chef for deployment
[12:47] <AntelopeSalad> then what?
[12:47] * mrpinksss (~mrpinksss@217.9.109.218) Quit (Ping timeout: 260 seconds)
[12:47] <AntelopeSalad> because i'm going to do that anyways
[12:47] <AntelopeSalad> i'll just remove cap from the picture right now if it lets me keep using poise-ruby
[12:47] <@coderanger> Include that fix and make it install in the correct folder via setting GEM_HOME
[12:47] <workmad3> ^^
[12:53] <AntelopeSalad> if rvm isn't compiling it from source and poise-ruby isn't coming it from source then how is rvm's version good and poise ruby's version is bad?
[12:53] <AntelopeSalad> *compiling
[12:53] * bmcorser (uid18416@gateway/web/irccloud.com/x-alpqhxafoqamtvvm) Quit (Quit: Connection closed for inactivity)
[12:54] <workmad3> AntelopeSalad: the poise version uses omnibus and provides an embedded version of openssl that it was compiled against
[12:54] <AntelopeSalad> workmad3: are you using this? https://github.com/fnichol/chef-rvm
[12:54] <workmad3> AntelopeSalad: an rvm pre-compiled version was precompiled against the system openssl
[12:54] <workmad3> AntelopeSalad: if there isn't a pre-compiled rvm version for your platform, it'll also then compile from source against system openssl
[12:54] <AntelopeSalad> then how does that translate to a pg gem error and not a poise-ruby error?
[12:54] <workmad3> AntelopeSalad: that's what I used in the past
[12:55] * emcfins (~emcfins@69.38.250.88) has joined #chef
[12:55] <workmad3> AntelopeSalad: because the way pg links to openssl for some reason bypasses the RbConfig settings about which openssl it was compiled against
[12:55] * PierreO (~Adium@bl14-64-21.dsl.telepac.pt) Quit (Quit: Leaving.)
[12:55] <AntelopeSalad> ah
[12:55] <AntelopeSalad> and those few lines you wrote is basically what you would write in the ticket?
[12:56] <AntelopeSalad> do you want to open it, or should we let code do it?
[12:56] * hasues (~hasues@108-236-232-243.lightspeed.knvltn.sbcglobal.net) Quit (Quit: Leaving.)
[12:56] * michaelpjohnson (~michaelpj@cpe-76-183-159-151.tx.res.rr.com) has joined #chef
[12:57] * Nick__ (~nick@c-50-184-152-28.hsd1.ca.comcast.net) Quit (Ping timeout: 265 seconds)
[12:57] * solvip (~solvip@194-144-212-19.du.xdsl.is) Quit (Quit: Lost terminal)
[12:57] <AntelopeSalad> i'm also really surprised his bug isn't been found yet, i thought the basecamp guys used chef too
[12:57] <workmad3> AntelopeSalad: I'd probably want to investigate what pg is doing in more detail before I wrote a ticket
[12:57] * celhead (~jrsmith@cpe-67-241-20-7.twcny.res.rr.com) Quit (Read error: Connection reset by peer)
[12:58] * solvip (~solvip@194-144-212-19.du.xdsl.is) has joined #chef
[12:58] <AntelopeSalad> you would think they have experimented with installing ruby in various ways outside of rvm
[12:58] * Blackavar (~blackavr@173-160-211-174-Washington.hfc.comcastbusiness.net) Quit (Ping timeout: 245 seconds)
[12:58] <workmad3> AntelopeSalad: however, there wouldn't be anything wrong with you opening a ticket on pg saying you had issues installing pg with poise-ruby and providing your log file, IMO ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment