TypeError: can't dup NilClass
If you get an error something like below while bundle install
Installing mysql (2.7) with native extensions
TypeError: can't dup NilClass
An error occurred while installing mysql (2.7), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.7'` succeeds before bundling.
First, check your gem's version by executing
$ gem -v
If it's newer then 1.5.x, like 1.6.x or above, that's your problem.
Newer versions of Rubygems doesn't play well with the mysql gem.
So downgrade the gem, and retry gem install mysql -v 2.7
.
You can downgrade the gem by:
$ gem list rubygems-update
*** LOCAL GEMS ***
rubygems-update (1.7.2)
$ sudo gem uninstall -v 1.7.2 rubygems-update # uninstall all the local rubygem-update versions if it's newer then 1.5.x
$ sudo gem install -v 1.5.2 rubygems-update
$ sudo update_rubygems
$ gem -v
1.5.2