WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.1

Problem

You get the following warning after an update to your system (ie Ubuntu 13.10):

WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.1

Solution

Uninstall your nokogiri versions:

gem uninstall nokogiri

and then run install it again (inside your application if you use bundler) with:

bundle install

rvm “You need to change your terminal emulator preferences to allow login shell.”

Problem

After a new rvm installation in an (k)ubuntu system you get the following error from rvm when trying to switch between rubies:

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

Solution

As the message suggests you can change the setting in your terminal which is fine if you are using the gnome-terminal by going to the link provided:

Please visit https://rvm.io/integration/gnome-terminal/ for a example.

but if you are using Konsole in KDE you need to go to a different link that explains the change in the settings:

Please visit http://rvm.io/integration/konsole/ for a example.

db:migrate or db:schema:load for Rails project with many migations

Problem

You have a rails application with many migrations build over time and you want to recreate the database from start. Should you be using the normal way of running the migrations (db:migrate) or the one that loads the actual schema to the database (db:schema:load).

Solution

According to the book Rails 4 in Action (MEAP v9 page 146) :

The bin/rake db:migrate task runs the migrations and then dumps the structure of the database to a file called db/schema.rb. This structure allows you to restore your database using the bin/rake db:schema:load task if you wish, which is better than running all the migrations on a large project again! NOTE

NOTE: Large projects can have hundreds of migrations, which may not run due to changes in the system over time. It’s best to just use the bin/rake db:schema:load.

Pushing and getting the tags from a remote git repository

Problem

You want to tag your branches in a remote repository and share the tags with other users, but usually the git pull and git push do not update the tags.

Solution

According to the git documentation:

By default, the git push command doesn’t transfer tags to remote
servers. You will have to explicitly push tags to a shared server
after you have created them. This process is just like sharing remote 
branches — you can run git push origin [tagname].

and:

If you have a lot of tags that you want to push up at once, 
you can also use the --tags option to the git push command. 
This will transfer all of your tags to the remote server that 
are not already there.

But when doing either a git pull origin [repo] or git fetch origin [repo] the tag list does not seem to be updated.

In this case try the following:

git pull origin [repo] --tags

And the list should contain all the tags in the remote repository.

rails `require’: cannot load such file — mysql2/mysql2 (LoadError)

Problem

You want to use a different ruby version from the one you have initially installed and build your application with, but when you change it in your rvm installation you get the following error:

..gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such 
file -- mysql2/mysql2 (LoadError)

Solution

To make it work again you will have to uninstall the mysql2 gem and install it again in the new ruby version with the option –platform=ruby.

rvm use ruby-2.0.0-p247
cd my_project
rails s
..... gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load 
such file -- mysql2/mysql2 (LoadError)
gem uninstall mysql2
gem install mysql2 --platform=ruby
rails s
=> Booting WEBrick
....

RVM and RubyGems versions

Problem

You would like to upgrade your rubygems version from 1.8.17 to the latest version 2.0.7 for example.

Solution

You can upgrade to a specific or the latest gem version and relate that to a specific rvm ruby that you have installed.
So if for example you have ruby-1.9.3-p327 and ruby-2.0.0-p247, you can have different gem version (or the same if you want) for each ruby version.

To upgrade to the latest one in the ruby-2.0.0-p247 for example you could do the following:

rvm list
rvm use ruby-1.9.3-p327
gem -version
1.8.17
rvm use ruby-2.0.0-p247
gem --version
1.8.17
gem update --system
gem --version
2.0.7
rvm use ruby-1.9.3-p327
gem --version
1.8.17

Get github to link your commits to your user account if you have more than one git accounts

Problem

You would like to link the commits to a github repository to your github account but you may have different git accounts (ie gitolite etc).
So you would need to specify in the config file which account you want to use.

Solution

There is a help page in github that describes this problem here, but they recommend to change your global settings which is maybe not what you want.
So you could the following to change only the current project settings:

cd ~/my_project
git config --local user.email="your_github_account_email"

Or add the following to your .git/config file inside your local repository:

[user]
  email = user_name@domain.com
  name = Firstname Surname

And to check the settings:

git config --local -l
git config --global -l

Stop github asking your username

Problem
You are working with a git repository but after first cloning the project to your localhost and trying to push changes afterwards, github is asking for you username and password.

Solution
Edit your git configuration and make sure that it uses the git protocol instead of https, so in your ~/project/.git/config file

replace:

remote.origin.url=https://github.com/project_name/repository_name.git

with:

remote.origin.url=git@github.com:project_name/repository_name.git

Integrating BitBucket with PivotalTracker

Problem

You would like to integrate your BitBucket git repository with your Pivotal Tracker issue tracker.

Solution

After creating your bitbucket git repository and pivotal tracker project, do the following.

  • Go to your Pivotal Tracker – Profile and copy your API Token
  • Go to your Bitbucket repository and click on the Administration link (top right corner)
  • From the Repository Details menu on the left select Services
  • From the Service drop down list select Pivotal Tracker
  • Add the Pivotal Tracker API Token that you copied earlier and save

You can now use commits that have a square bracker [#111111] with the pivotal issue ticket and update pivotal when making a commit