Friday 11 October 2013

RubyMine GitLab Integration

I setup the community version of GitLab so I can have locally controlled projects.
Since I use RubyMine as my IDE, the integration with both github and gitlab was a bit convoluted.

First I couldn't get ssh to work, so I used http (since it was on my home network) to get the push/pull working.
(There are links to pages explaining how to fix that at the end of this post)

One you have GitLab running, you can create a project.
After doing that, you get to see a page with boxes telling you how to connect using git from the command line.

One thing to note is that there are two commands to set your `` and ``.
The key is that they use `--global` which is problematic.

So. Let's say you have created a project called `test`. Do this:

cd [your projects folder]
mkdir test
cd test
git init
git config --local "YOUR_NAME"
git config --local "YOUR_GITLAB_ACCOUNT_EMAIL"
git remote add origin [HTTP_URL_PROVIDED_BY_GITLAB]
git add
git commit -m 'Initial'
git push -u origin master

You can have 'port' and 'groups' so the url could look like this:


Ok. What about task management integration?

Fiddly, but doable.

First, you have to use the GitLab API.
And for that you need your private key AND know the project number.

When you issue a curl request you get back JSON:

curl http://gitlab.local:8080/api/v3/projects/3/issues?private_token=YOUR_API_TOKEN
        "id": 4,
        "project_id": 3,
        "title": "Some task",
        "description": "Some description",
        "labels": ["Enhancement"],
        "milestone": null,
        "assignee": {
            "id": 4,
            "username": "bill",
            "email": "",
            "name": "Bill Bloggs",
            "state": "active",
            "created_at": "2013-10-10T22:59:26Z"
        "author": {
            "id": 4,
            "username": "bill",
            "email": "",
            "name": "Bill Bloggs",
            "state": "active",
            "created_at": "2013-10-10T22:59:26Z"
        "state": "opened",
        "updated_at": "2013-10-11T01:07:50Z",
        "created_at": "2013-10-11T01:07:19Z"
        "id": 3,
        "project_id": 3,
        "title": "Another task",
        "description": "Another description",
        "labels": ["Bug"],
        "milestone": null,
        "assignee": {
            "id": 5,
            "username": "bill",
            "email": "",
            "name": "Bill Bloggs",
            "state": "active",
            "created_at": "2013-10-10T23:00:19Z"
        "author": {
            "id": 4,
            "username": "bill",
            "email": "",
            "name": "Bill Bloggs",
            "state": "active",
            "created_at": "2013-10-10T22:59:26Z"
        "state": "opened",
        "updated_at": "2013-10-11T01:07:59Z",
        "created_at": "2013-10-11T01:06:54Z"

So how to get RubyMine to use this?

1. Open preferences -> tasks
2. Change 'Changelist name format' to {project}-#{number} {summary}

Under Servers, add a 'generic' server

In the general tab:

1. Change the server URL to http://YOUR_SERVER/YOUR_REPO_WITHOUT_DOT_GIT
2. Insert your username and password
3. Click 'Use HTTP Authentication'

Go to the gitlab server and under your account settings, there is an input box with your private key.

Copy it.

In the additional tab:

1. Add the URL: http://YOUR_SERVER/api/v3/projects/PROJECT_NUMBER/issues?private_token=YOUR_PRIVATE_KEY
2. Check the 'JSON' option
3. In the Task pattern insert: "id":({id}.?+),.+?,"title":"({summary}.+?)"

Hit test.

You should see 'Connection is successful'.

From now on you should be able to use the tasks drop down.

FYI When creating tasks in gitlab, there is an irritating anti-feature for assigning labels.
You have to type them in.
The set I use is:

New Feature
Quick Fix
No Fix

I still need to figure out how to have GitLab return the project name ala TestProject-#{number} {summary} format.

Off-topic: Go read

Friday 4 October 2013

__rvm_date syntax error: unexpected end of file

When running rspec tests inside RubyMine, you may see something like this:

 sh: __rvm_date: line 1: syntax error: unexpected end of file
 sh: error importing function definition for `__rvm_date'

What worked for me is to shutdown RubyMine and edit the


file and add:


To the end of it.

Apparently there is a bug for it at:

Something to do with loading rvm through shell inside RubyMine.

em::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed


One day you'll see this:

$ bundle install
Fetching gem metadata from
Fetching gem metadata from
Resolving dependencies...

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
An error occurred while installing rake (10.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.

Wait. What?

Worse is when you do a `gem list --remote` you get NOTHING.

WHAT? PHHBBTT! [Brain melts]

The issue is somewhat arcane and is embedded in rvm using openssl.

Let's have a look at the certificates:

$ rvm osx-ssl-certs status all
Certificates for /usr/lib/ssl/cert.pem: Old.
Certificates for /usr/local/etc/openssl/cert.pem: Up to date.
Certificates for /etc/openssl/cert.pem: Old.

Ah. So what worked for me is:

rvm get stable
rvm reload

If you still get 'Old' on the status, do this:

$ rvm osx-ssl-certs update all
Updating certificates for /usr/lib/ssl/cert.pem: Updating certificates in '/usr/lib/ssl/cert.pem'.

and now you'll be able to bundle again.