0

Initial Problem

I was using yaml_db in a Rails project, but it seems the default branch has some issues with boolean records. Now I know that there's a branch on github that has a fixed version.

I changed my Gemfile so that this branch will be installed instead of the default yaml_db,

gem 'yaml_db', :git => "https://github.com/robsharp/yaml_db.git"

I run bundle install and it shows:

Using yaml_db (0.2.0) from https://github.com/robsharp/yaml_db.git (at master).

Your bundle is complete! It was installed into /Users/user/.rvm/gems/ruby-1.9.2-p0

Fine. Now the fixed file in the Git repository should have this line in lib/serialization_helper.rb:

record[column] = convert_boolean(record[column])

Yet, when I look at my local file, which is .rvm/gems/ruby-1.9.2-p0/bundler/gems/yaml_db-ca178cfb59cf/lib/serialization_helper.rb, it still shows the unpatched old line:

record[column] = (record[column] == 't' or record[column] == '1')

Fine, seems as my local file isn't changed.


Gem not being installed correctly

Running gem list won't show me yaml_db at all. I removed the Gem lockfile and installed the bundle again, still there is no yaml_db in my Gem listing. Running gem install yaml_db of course only installs the broken version.


Manual Install

I now try to manually install from the Git source.

git clone https://github.com/robsharp/yaml_db.git
cd yaml_db
git checkout -b fix_boolean_checks_to_support_oracle

Still, the serialization_helper.rb file is not updated correctly. I just manually changed it and built the Gem. Everything works fine now.

My new question: Why won't it check out the correct file?

Community
  • 1
  • 1
slhck
  • 36,575
  • 28
  • 148
  • 201

1 Answers1

1

If you run gem list yaml_db and see multiple versions in parenthesis, define the version you need in your Gemfile like so

gem 'yaml_db', '~> 0.2.0', :git => "https://github.com/robsharp/yaml_db.git"

I had a similar problem and found out that the Gemfile.lock file stored my old and not–updated version and used that for my project.

polarblau
  • 17,649
  • 7
  • 63
  • 84
  • Listing showed me `*** LOCAL GEMS ***` and nothing else. I deleted the lockfile and ran `bundle install` again. No luck. Seems like it isn't even installed. – slhck Jan 20 '11 at 12:40
  • Yep, sure does. I sometimes forget to switch the ruby version before installing a Gem when using RVM. Maybe you've installed it somewhere else by accident? – polarblau Jan 20 '11 at 12:42
  • I've never had problems with adding other Gems to my Gemfile and installing them. I use 1.9.2-p0 as default on the system. When I search for the `serialization_helper.rb` file, there's only one (the one that I'm referring to in the question) – slhck Jan 20 '11 at 12:46
  • Have you tried to leave the source away (given that you have added the source to your gem sources — gem sources -a http://gems.github.com )  and to run the install again? Does the gem show up if you just use gem list to show all your installed gems? – polarblau Jan 20 '11 at 13:00
  • Hm... I've tried both with and without the source. There's no yaml_db in `gem list` at all. – slhck Jan 20 '11 at 13:11
  • Hmm… install using `gem install` maybe? – polarblau Jan 20 '11 at 13:13
  • `gem install yaml_db` works, of course, but this is the buggy version. Can I specify that I want to install from the Git branch I mentioned above? – slhck Jan 20 '11 at 13:32
  • I guess you could use `gem install --source https://github.com/robsharp/yaml_db.git` or follow the instructions here http://stackoverflow.com/questions/2577346/how-to-install-gem-from-github-source and build the gem yourself. – polarblau Jan 20 '11 at 13:39
  • Thank you! I was able to build it, but I had to patch the file myself since it didn't check out the correct file. Can you spot the problem? (I edited the original question) – slhck Jan 20 '11 at 13:57
  • Ah, so the fix was in a different branch? I guess it always installs from master… – polarblau Jan 20 '11 at 14:04
  • Obviously it didn't use the correct branch, yes. Thank you so much for your patience. – slhck Jan 20 '11 at 14:08