GitLab installation - undefined method `downcase'

Hey guys,

I get into the following error while i was trying to install GitLab on a Debian 8 machine. I tried to google the issue but had no luck. It is a new installation, no upgrade. It is supposed to run in the local network.

The config file is the default template. The only line changed was:

external_url ‘http://isb.bbs.local:8090

This is the output of “gitlab-ctl reconfigure”:

root@isb:/etc# gitlab-ctl reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.0.0)
  - runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
  * directory[/etc/gitlab] action create (up to date)
  
  ================================================================================
  Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb
  ================================================================================
  
  NoMethodError
  -------------
  undefined method `downcase' for nil:NilClass
  
  Cookbook Trace:
  ---------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:347:in `get_redhatish_platform'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:328:in `platform'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:318:in `platform_family'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:314:in `system_is_rhel7?'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/selinux.rb:18:in `from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:78:in `from_file'
  
  Relevant File Content:
  ----------------------
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:
  
  340:        "not redhat"
  341:      end
  342:    end
  343:  
  344:    # Taken from Ohai
  345:    # https://github.com/chef/ohai/blob/31f6415c853f3070b0399ac2eb09094eb81939d2/lib/ohai/plugins/linux/platform.rb#L23
  346:    def self.get_redhatish_platform(contents)
  347>>     contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
  348:    end
  349:  
  350:    # Taken from Ohai
  351:    # https://github.com/chef/ohai/blob/31f6415c853f3070b0399ac2eb09094eb81939d2/lib/ohai/plugins/linux/platform.rb#L27
  352:    def self.get_redhatish_version(contents)
  353:      contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
  354:    end
  355:  end
  356:  
  
  Platform:
  ---------
  x86_64-linux
  
  
  Running handlers:
  Running handlers complete
  Chef Client failed. 0 resources updated in 01 seconds

Thanks for your help in advance.

It would be a good idea to report your ruby version and your gitlab-ce version, and if you used omnibus or non-omnibus install. I guess that you have a chef error so that’s omnibus. But I don’t know which version you installed.

It almost looks to me like you have a system-ruby that’s too old that’s in your way. Debian is a wonderful operating system that I love deeply that uses absolutely ancient versions of stuff, including its ruby version, git version etc. Omnibus install should have taken care of that wrong version.

If the omnibus install is working perfectly, it should just install, I installed on a clean Debian 8 vm just last week and it worked fine with gitlab-ce 8.12.3 (omnibus) on Debian 8.

Hey Warren,

thank you for your help. Yes, I used the omnibus install (I tried both: the latest and the version before). Actually there wasn’t an error or a warning while installation but I guess you are right. I’ll try that tomorrow when I have access to the server again.

I will keep you current

Timo

Okay. I just checked an older installation of gitlab on a test system. There everything worked fine. I’m not sure how to check wich ruby version gitlab is using.

Ruby version

timo@isb:~$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

Just removed everything and tried it again. Produces:

timo@isb:~$ sudo curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Detected operating system as debian/jessie.
Checking for curl...
Detected curl...
Running apt-get update... done.
Installing debian-archive-keyring which is needed for installing 
apt-transport-https on many Debian systems.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.


timo@isb:~$ sudo apt-get install gitlab-ce
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.       
Statusinformationen werden eingelesen.... Fertig
Die folgenden NEUEN Pakete werden installiert:
  gitlab-ce
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 144 nicht aktualisiert.
Es müssen noch 0 B von 302 MB an Archiven heruntergeladen werden.
Nach dieser Operation werden 811 MB Plattenplatz zusätzlich benutzt.
Vormals nicht ausgewähltes Paket gitlab-ce wird gewählt.
(Lese Datenbank ... 56789 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von .../gitlab-ce_8.12.7-ce.0_amd64.deb ...
Entpacken von gitlab-ce (8.12.7-ce.0) ...
gitlab-ce (8.12.7-ce.0) wird eingerichtet ...

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/

gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://isb.bbs.local
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.

Got the same error:

timo@isb:~$ sudo gitlab-ctl reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - runit (0.14.2)
  - package (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
  * directory[/etc/gitlab] action create (up to date)
  
  ================================================================================
  Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb
  ================================================================================
  
  NoMethodError
  -------------
  undefined method `downcase' for nil:NilClass
  
  Cookbook Trace:
  ---------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:347:in `get_redhatish_platform'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:328:in `platform'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:318:in `platform_family'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:314:in `system_is_rhel7?'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/selinux.rb:18:in `from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:78:in `from_file'
  
  Relevant File Content:
  ----------------------
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb:
  
  340:        "not redhat"
  341:      end
  342:    end
  343:  
  344:    # Taken from Ohai
  345:    # https://github.com/chef/ohai/blob/31f6415c853f3070b0399ac2eb09094eb81939d2/lib/ohai/plugins/linux/platform.rb#L23
  346:    def self.get_redhatish_platform(contents)
  347>>     contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
  348:    end
  349:  
  350:    # Taken from Ohai
  351:    # https://github.com/chef/ohai/blob/31f6415c853f3070b0399ac2eb09094eb81939d2/lib/ohai/plugins/linux/platform.rb#L27
  352:    def self.get_redhatish_version(contents)
  353:      contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
  354:    end
  355:  end
  356:  
  
  Platform:
  ---------
  x86_64-linux
  
  
  Running handlers:
  Running handlers complete
  Chef Client failed. 0 resources updated in 01 seconds

Can I make sure that gitlab is using the right version of ruby?

Okay. I stopped trying it this way. There must be something wrong with this machine. I will use the docker image instead.

However. Thank you for your help and your time.

Regards

Timo

I’m looking at this code and it appears a bit unsafe:

  # Taken from Ohai
  # https://github.com/chef/ohai/blob/31f6415c853f3070b0399ac2eb09094eb81939d2/lib/ohai/plugins/linux/platform.rb#L23
  def self.get_redhatish_platform(contents)
    contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
  end

Maybe you could modify that file /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helper.rb circa line 347
and see if this works around the bug. If it does, a bug should be logged, as this code seems a bit unstable.

I think I would insert an ampersand in that file:

  def self.get_redhatish_platform(contents)
    contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1]&.downcase
  end

Or since you’re not on redhat, to get past this, you could hack your code like this:

def get_redhatish_platform2(contents)
    "nope"
end

I think this is a bug in the chef recipe helpers.rb file, logged bug here:

Thank you.

Bug moved to new project, progress can be observed here:

nice information sharing here…