Working on GitLab wikis locally (it borrows GitHub's tech stack entirely) which means installing Ruby

TLDR: Just don’t use Ruby. Find something that wasn’t forged in the pits of hell to waste everyone’s time.

Or for just the installation steps that work, in the order that makes them work the first time, here, i’m feeling really generous today:

sudo apt-get install -y libicu-dev libreadline-dev zlib1g-dev
rbenv install 2.5.1
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
rbenv global 2.5.1
gem install gollum

Yeah that looks simple but only because i figured it out for you. You’re welcome. Now enjoy your weekend.

“Ruuuuuuuby … can fail!”

In a million ways.

Searching for the error brought me to an old answer referencing an even older article about deciding which damn Ruby version manager you should choose. I was not up for this level of emotional or intellectual investment just to follow a simple installation command so i could preview wikis locally and work on them more quickly without waiting on network lag.

OK well does Gollom’s own documentation give anything more opinionated or helpful about how to install ruby so i can install it?

Nope. OK, i’ll pick rbenv as the ruby version manager that looks both simple yet still actively maintained at a significant level (editor’s note: although maybe this is where i went wrong, maybe [Postmodern’s Ruby Install] has only a few recent commits because it’s perfect and just works).

Gave it everything the damn thing wanted.

After it’s autoinstaller the ‘doctor’ check (curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash) still kept saying everything was OK except shims weren’t and to add

Finally, i could do a one-line command and the result:

rbenv install 2.5.1
Downloading ruby-2.5.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
Installing ruby-2.5.1...

and it heated up my computer for a while doing that. And then…

BUILD FAILED (Ubuntu 18.04 using ruby-build 20180618-9-g00490d3)

Inspect or clean up the working tree at /tmp/ruby-build.20180804132152.17560
Results logged to /tmp/ruby-build.20180804132152.17560.log

Last 10 log lines:
installing capi-docs:               /home/mlncn/.rbenv/versions/2.5.1/share/doc/ruby
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev zlib1g-dev` to fetch missing dependencies.

Configure options used:
  --prefix=/home/mlncn/.rbenv/versions/2.5.1
  LDFLAGS=-L/home/mlncn/.rbenv/versions/2.5.1/lib
  CPPFLAGS=-I/home/mlncn/.rbenv/versions/2.5.1/include

Fine, i’ll do that.

sudo apt-get install -y libreadline-dev zlib1g-dev
rbenv install 2.5.1

No faster this time, but finally:

Installed ruby-2.5.1 to /home/mlncn/.rbenv/versions/2.5.1

Mission accomplished. Oh, wait, i did all this to install Gollum. Let’s give that another try:

gem install gollum
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.5.0 directory.

…. i thought the point of these ruby managers was not to need sudo for the gems.

Even after a source ~/.bashrc

And i definitely have the required stuff at the end of my .bashrc:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Let’s find that documentation that i closed in a rare moment of thinking i had actually finished with something:

You don’t need sudo to install gems. Typically, the Ruby versions will be installed and writeable by your user. No extra privileges are required to install gems.

What the hell; it’s even using .rbenv’s gem:

which gem
/home/mlncn/.rbenv/shims/gem

So what is with the problem?

The germ of an answer started to come in this long thread, and the solution is crystallized in this comment.

$ rbenv versions
* system (set by /home/mlncn/.rbenv/version)
  2.5.1
$ rbenv global 2.5.1
$ rbenv versions
  system
* 2.5.1 (set by /home/mlncn/.rbenv/version)

Can’t fail now!

$ gem install gollum
Fetching: charlock_holmes-0.7.6.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing gollum:
	ERROR: Failed to build gem native extension.

    current directory: /home/mlncn/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
/home/mlncn/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180804-19715-1k9bsd7.rb extconf.rb
checking for -licui18n... no
checking for -licui18n... no


***************************************************************************************
*********** icu required (brew install icu4c or apt-get install libicu-dev) ***********
***************************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/home/mlncn/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
	--with-icu-dir
	--without-icu-dir
	--with-icu-include
	--without-icu-include=${icu-dir}/include
	--with-icu-lib
	--without-icu-lib=${icu-dir}/lib
	--with-icui18nlib
	--without-icui18nlib
	--with-icui18nlib
	--without-icui18nlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/mlncn/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/charlock_holmes-0.7.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/mlncn/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6 for inspection.
Results logged to /home/mlncn/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/charlock_holmes-0.7.6/gem_make.out

OK. On to the next problem. Just need to install 57.5 MB more of dependencies for Gollom to work, good lord.

$ sudo apt-get install libicu-dev
[sudo] password for mlncn:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gir1.2-harfbuzz-0.0 icu-devtools libglib2.0-dev libglib2.0-dev-bin
  libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libicu-le-hb-dev
  libicu-le-hb0 libiculx60 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5
Suggested packages:
  libglib2.0-doc libgraphite2-utils icu-doc
The following NEW packages will be installed:
  gir1.2-harfbuzz-0.0 icu-devtools libglib2.0-dev libglib2.0-dev-bin
  libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libicu-dev
  libicu-le-hb-dev libicu-le-hb0 libiculx60 libpcre16-3 libpcre3-dev
  libpcre32-3 libpcrecpp0v5
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.8 MB of archives.
After this operation, 57.4 MB of additional disk space will be used.

Let’s give it one more try…

$ gem install gollum
Building native extensions. This could take a while...
Successfully installed charlock_holmes-0.7.6
Fetching: posix-spawn-0.3.13.gem (100%)
Building native extensions. This could take a while...
Successfully installed posix-spawn-0.3.13
Fetching: mime-types-data-3.2016.0521.gem (100%)
Successfully installed mime-types-data-3.2016.0521
Fetching: mime-types-3.1.gem (100%)
Successfully installed mime-types-3.1
Fetching: diff-lcs-1.3.gem (100%)
Successfully installed diff-lcs-1.3
Fetching: gitlab-grit-2.8.2.gem (100%)
Successfully installed gitlab-grit-2.8.2
Fetching: gollum-grit_adapter-1.0.1.gem (100%)
Successfully installed gollum-grit_adapter-1.0.1
Fetching: rouge-2.2.1.gem (100%)
Successfully installed rouge-2.2.1
Fetching: mini_portile2-2.3.0.gem (100%)
Successfully installed mini_portile2-2.3.0
Fetching: nokogiri-1.8.4.gem (100%)
Building native extensions. This could take a while...
Successfully installed nokogiri-1.8.4
Fetching: stringex-2.8.4.gem (100%)
Successfully installed stringex-2.8.4
Fetching: sanitize-2.1.0.gem (100%)
Successfully installed sanitize-2.1.0
Fetching: github-markup-1.7.0.gem (100%)
Successfully installed github-markup-1.7.0
Fetching: gemojione-3.3.0.gem (100%)
Successfully installed gemojione-3.3.0
Fetching: gollum-lib-4.2.7.gem (100%)
Successfully installed gollum-lib-4.2.7
Fetching: kramdown-1.9.0.gem (100%)
Successfully installed kramdown-1.9.0
Fetching: rack-1.6.10.gem (100%)
Successfully installed rack-1.6.10
Fetching: tilt-2.0.8.gem (100%)
Successfully installed tilt-2.0.8
Fetching: rack-protection-1.5.5.gem (100%)
Successfully installed rack-protection-1.5.5
Fetching: sinatra-1.4.8.gem (100%)
Successfully installed sinatra-1.4.8
Fetching: mustache-0.99.8.gem (100%)
Successfully installed mustache-0.99.8
Fetching: useragent-0.16.10.gem (100%)
Successfully installed useragent-0.16.10
Fetching: gollum-4.1.2.gem (100%)
Successfully installed gollum-4.1.2
Parsing documentation for charlock_holmes-0.7.6
Installing ri documentation for charlock_holmes-0.7.6
Parsing documentation for posix-spawn-0.3.13
Installing ri documentation for posix-spawn-0.3.13
Parsing documentation for mime-types-data-3.2016.0521
Installing ri documentation for mime-types-data-3.2016.0521
Parsing documentation for mime-types-3.1
Installing ri documentation for mime-types-3.1
Parsing documentation for diff-lcs-1.3
Couldn't find file to include 'Contributing.rdoc' from README.rdoc
Couldn't find file to include 'License.rdoc' from README.rdoc
Installing ri documentation for diff-lcs-1.3
Parsing documentation for gitlab-grit-2.8.2
Installing ri documentation for gitlab-grit-2.8.2
Parsing documentation for gollum-grit_adapter-1.0.1
Installing ri documentation for gollum-grit_adapter-1.0.1
Parsing documentation for rouge-2.2.1
Installing ri documentation for rouge-2.2.1
Parsing documentation for mini_portile2-2.3.0
Installing ri documentation for mini_portile2-2.3.0
Parsing documentation for nokogiri-1.8.4
Installing ri documentation for nokogiri-1.8.4
Parsing documentation for stringex-2.8.4
Installing ri documentation for stringex-2.8.4
Parsing documentation for sanitize-2.1.0
Installing ri documentation for sanitize-2.1.0
Parsing documentation for github-markup-1.7.0
Installing ri documentation for github-markup-1.7.0
Parsing documentation for gemojione-3.3.0
Installing ri documentation for gemojione-3.3.0
Parsing documentation for gollum-lib-4.2.7
Installing ri documentation for gollum-lib-4.2.7
Parsing documentation for kramdown-1.9.0
Installing ri documentation for kramdown-1.9.0
Parsing documentation for rack-1.6.10
Installing ri documentation for rack-1.6.10
Parsing documentation for tilt-2.0.8
Installing ri documentation for tilt-2.0.8
Parsing documentation for rack-protection-1.5.5
Installing ri documentation for rack-protection-1.5.5
Parsing documentation for sinatra-1.4.8
Installing ri documentation for sinatra-1.4.8
Parsing documentation for mustache-0.99.8
Installing ri documentation for mustache-0.99.8
Parsing documentation for useragent-0.16.10
Installing ri documentation for useragent-0.16.10
Parsing documentation for gollum-4.1.2
Installing ri documentation for gollum-4.1.2
Done installing documentation for charlock_holmes, posix-spawn, mime-types-data, mime-types, diff-lcs, gitlab-grit, gollum-grit_adapter, rouge, mini_portile2, nokogiri, stringex, sanitize, github-markup, gemojione, gollum-lib, kramdown, rack, tilt, rack-protection, sinatra, mustache, useragent, gollum after 486 seconds
23 gems installed

(It hung on installing ri documentation for sinatra for a half hour, but it did finish successfully!)

OK well if this is working i’ll go crazy installing gems:

$ gem install github-markdown
Fetching: github-markdown-0.6.9.gem (100%)
Building native extensions. This could take a while...
Successfully installed github-markdown-0.6.9
Parsing documentation for github-markdown-0.6.9
Installing ri documentation for github-markdown-0.6.9
Done installing documentation for github-markdown after 0 seconds
1 gem installed

That’s recommended by GitLab. But i note that GitLab wikis also support AsciiDoc, which is awesome, so i’ll also install support for that (mentioned on Gollom’s page, though i’m not sure it’s the same exact version supported by GitLab, but presumably it is). Hrm well asciidoc is already listed as available (among many more options than either GitLab or GitHub offers on their site) in my default installation of gollom.

Good day all. May you never have to engage with Ruby at this level.