Search code examples
rubyberkshelf

berks refuses to update


I can install berkshelf just fine:

$ gem install berkshelf                                                                     
Successfully installed berkshelf-3.2.0
Parsing documentation for berkshelf-3.2.0
Done installing documentation for berkshelf after 1 seconds
1 gem installed

But it fails to actually affect my berks:

$ berks version
Berkshelf (2.0.18)

Which appears normal:

$ which berks
/home/rubyUser/.rvm/gems/ruby-2.1.4/bin/berks

I'm using ruby 2.1.4 on debian stable (wheezy):

$ rvm list

rvm rubies

   ruby-1.9.3-p550 [ x86_64 ]
=* ruby-2.1.4 [ x86_64 ]

I think my path is correct:

$ echo $PATH
/home/rubyUser/.rvm/gems/ruby-2.1.4/bin:/home/rubyUser/.rvm/gems/ruby-2.1.4@global/bin:/home/rubyUser/.rvm/rubies/ruby-2.1.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/rubyUser/.rvm/bin:/home/rubyUser/.rvm/bin

It's possible that the chefdk is somehow interfering:

$ whereis berks
berks: /usr/bin/berks /usr/bin/X11/berks /opt/chefdk/bin/berk

bUt giving the full path to call berks does not affect the version. Looking at that berks supplied by which reveals that it is a merely calling the gem from elsewhere, how do I hunt down where it is coming from?

$ cat `which berks`
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'berkshelf' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
    version = $1
    ARGV.shift
  end
end

gem 'berkshelf', version
load Gem.bin_path('berkshelf', 'berks', version)

Solution

  • I had an errant Gemfile.lock laying around in the directory I was in. It was locking berkshelf to the 2.0 version.

    An even deeper answer to my problem is getting a proper Rakefile going that properly cleans these sort of things when necessary