Tag Archives: git

Unicorn and bundler issue

I am using unicorn with a rails3 app that uses bundler and I hit a weird error when trying to start a server:

`rescue in load_spec_files': git://github.com/odorcicd/authlogic.git (at rails3) is not checked out. Please run `bundle install` (Bundler::GitError)

The background to this is that I am starting unicorn_rails as root then dropping privs in the after_fork block, this is the relevant section from my unicorn.conf file:

after_fork do |server, worker|
  # …
  uid, gid = Process.euid, Process.egid
  user, group = 'will', 'will'
  target_uid = Etc.getpwnam(user).uid
  target_gid = Etc.getgrnam(group).gid
  worker.tmp.chown(target_uid, target_gid)

  if uid != target_uid || gid != target_gid
    Process.initgroups(user, target_gid)
    Process::GID.change_privilege(target_gid)
    Process::UID.change_privilege(target_uid)
  end
end

This is basically the same as the GitHub unicorn config.

Back to the problem. It works fine for all the standard rubygems.org gems, but was failing on the dependencies I had specified as ‘:git’ deps, for instance authlogic:

gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'

I checked where these gem/git dependencies were being stored and saw the problem:

[will@server current]$ bundle show activerecord
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0

[will@server current]$ bundle show authlogic
/home/will/.bundler/ruby/1.9.1/authlogic-a087ad0

The :git dependencies were being bundled to a subdirectory of my home dir (the same user that does the deploy, and therefore the initial bundle install. The unicorn_rails process starts as root and has already run Bundler.setup before it forks, so Bundler.setup gets run as root, and the root user has no idea where the :git dependencies are, hence the error.

I solved this by adding a call to Bundler.setup from within the unicorn.conf after_fork block:

after_fork do |server, worker|
  Bundler.setup
  # …
  uid, gid = Process.euid, Process.egid
  user, group = 'will', 'will'
  target_uid = Etc.getpwnam(user).uid
  target_gid = Etc.getgrnam(group).gid
  worker.tmp.chown(target_uid, target_gid)

  if uid != target_uid || gid != target_gid
    Process.initgroups(user, target_gid)
    Process::GID.change_privilege(target_gid)
    Process::UID.change_privilege(target_uid)
  end
end

It seems to work fine, better solutions welcome!

Tagged , ,

Whiny git – getting rid of the ‘You did not specify any refspecs’ error

Newer versions of git will complain if you just do a

git push

in your current branch to push it to a remote:

pleb:funpop will$ git push
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning: 'nothing' : Do not push anything
warning: 'matching' : Push all matching branches (default)
warning: 'tracking' : Push the current branch to whatever it is tracking
warning: 'current' : Push the current branch
Counting objects: 37, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 4.58 KiB, done.
Total 21 (delta 11), reused 0 (delta 0)
To git@github.com:wjessop/Funpop.git
e9ca06a..5507c19 master -> master

You can get rid of this by just doing:

git config --add push.default current

and now git will work like it did before, without the noise.

Tagged

NWRUG 16th July – Source control Stand-off

This month Tekin Suleyman and Ashley Moran will be helping us get started with, and comparing, the Git and Darcs SCM systems.

Sponsorship is kindly provided this month by Liquidbronze, so free pizza will once again be available.

Schedule

  • 6:00pm :: Welcome & Pre-session bar visit.
  • 6:30pm :: How to do things in Git by Tekin Suleyman
  • 6:50pm :: Break
  • 7:00pm :: How to do things in Darcs by Ashley Moran
  • 7:30pm :: Free pizza sponsored by Liquidbronze
  • 8:30pm :: Drinks at the BBC bar afterwards, then somewhere else nearby after that closes at about 21:00.

If you want more information email nwrug@willj.net, call Will on 07939 547 962 or tweet @will_j.

Sign Up

If you would like to attend this event please sign up here.. as the BBC need a list of attendees before the event and I really need to know the numbers so I can order the right amount of food and drink. There’s an Upcoming event page but please use the form above. This month I shall be publicly coating people with squeezy cheesy peas who turn up without signing up. You have been warned.

Location

This meeting is being held at one of our regular venues, the BBC Manchester main building on Oxford Road in central Manchester (Directions). If you get lost call Will on 07939 547 962.

Tagged , ,