Could not run rails console in gitlab due to missing readline

Yesterday, I was trying to open the rails console of my gitlab server (gitlab v6.9.2, Ubuntu 12.04) to reset the admin password by the following command:

$ cd /home/git/gitlab
$ sudo -u git -H bundle exec rails console production

But it raised this error:

...
`require': no such file to load -- readline (LoadError)
...

After a while, I fixed it by (DO NOT MODIFY THE GEMFILE):

1. Install readline dev packages:

$ sudo apt-get install libreadline-dev

2. Recompile or upgrade ruby to v2.1:

Note: The use of Ruby version managers such as RVM, rbenv or chruby with GitLab in production frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby.

Install the required packages to compile ruby:

$ sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake libkrb5-dev

Remove the old Ruby 1.8 if present

$ sudo apt-get remove ruby1.8

Download Ruby and compile it:

$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl -L --progress http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz | tar xz
$ cd ruby-2.1.5
$ ./configure --disable-install-rdoc
$ make
$ sudo make install

Install the Bundler Gem:

$ sudo gem install bundler --no-ri --no-rdoc

(I also had to restore the Gemfile and Gemfile.lock (because I's messing with them while trying to fix this problem) by downloading from gitlab repository.)

3. Re-install the gems:

$ cd /home/git/gitlab
$ sudo -u git -H bundle install --deployment --without development test postgres aws

(I also have to clean the vendor/bundle/ruby/2.1.0/cache/ folder)

4. Restart gitlab:

$ sudo service gitlab restart

5. And I am able to access the rails console:

$ cd /home/git/gitlab
$ sudo -u git -H bundle exec rails console production

Pretty neat!!!!

Comments