Jekyll2020-03-30T00:43:21+03:00https://www.askolin.fi/feed.xmlSami Askolin - The Agent of KAAOS.Sami Askolin - The Agent of Kaaos, army of one. Half-man, half-engineer in the realms of software development and entrepreneurship.Sami AskolinVideos moved to PeerTube2020-01-21T00:00:00+02:002020-01-21T00:00:00+02:00https://www.askolin.fi/2020/01/21/peertube<p><em>Long time no updates, but suddenly: PeerTube</em></p>
<p>I’ve finally managed to install a <a href="https://joinpeertube.org/">PeerTube</a>
instance for <a href="https://www.kaaosunlimited.fi">Kaaos Unlimited Oy</a> and begun
uploading my videos
<a href="https://peertube.kaaosunlimited.fi/accounts/askolsam/videos">there</a>.</p>Sami AskolinLong time no updates, but suddenly: PeerTubeChanging the site layout2019-03-22T00:00:00+02:002019-03-22T00:00:00+02:00https://www.askolin.fi/2019/03/22/site-changes<p><em>A short post describing the small changes I have made to the layout of my homepage.</em></p>
<p>I’ve decided to stop using <a href="https://fonts.google.com/">fonts provided by Google</a> and this naturally changes the appearance of my homepage. The main two reasons for making this change are privacy and page loading times.</p>
<p>As I’m in progress of trying to minimize my exposure to Google’s vast advertisement machine anyway, removing the Google Fonts from my site was a logical step to take. While I was at it, I also decided to replace <a href="https://fontawesome.com/v4.7.0/icons/">FontAwesome</a> with <a href="https://forkaweso.me/Fork-Awesome/">ForkAwesome</a>.</p>
<p>Concerning the page load times, I do grant you that my site still loads around 380kB
of CSS- and JavaScript files, mainly due <a href="https://jquery.com/">JQuery</a>, <a href="https://getbootstrap.com/">Bootstrap</a> and ForkAwesome.</p>
<p>Maybe one of these days I will get enough inspiration from <a href="https://brutalistwebdesign.com/">brutalist web design</a> or
<a href="http://motherfuckingwebsite.com/">http://motherfuckingwebsite.com/</a> and overhaul my homepages…</p>Sami AskolinA short post describing the small changes I have made to the layout of my homepage.pyenv and pyenv-virtualenv path issue2018-11-08T00:00:00+02:002018-11-08T00:00:00+02:00https://www.askolin.fi/2018/11/08/pyenv_virtualenv<p><em>When using <a href="https://github.com/pyenv/pyenv">pyenv</a> and it’s
<a href="https://github.com/pyenv/pyenv-virtualenv/">pyenv-virtualenv -plugin</a>, the activated virtualenv does not include
the <code class="highlighter-rouge">/bin</code> -directory of the base python version in the PATH.</em></p>
<h1 id="background">Background</h1>
<h2 id="pyenv">pyenv</h2>
<blockquote>
<p>pyenv lets you easily switch between multiple versions of Python. It’s simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.</p>
</blockquote>
<h2 id="pyenv-virtualenv">pyenv-virtualenv</h2>
<blockquote>
<p>pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like systems.</p>
</blockquote>
<h2 id="python-environment-at-the-time">Python environment at the time</h2>
<ol>
<li><a href="https://github.com/pyenv/pyenv">pyenv</a> installed as defined in the <a href="https://github.com/pyenv/pyenv#basic-github-checkout">Basic github checkout</a></li>
<li><a href="https://github.com/pyenv/pyenv-virtualenv">pyenv-virtualenv</a> installed as <a href="https://github.com/pyenv/pyenv-virtualenv#installing-as-a-pyenv-plugin">defined here</a></li>
<li>
<p>python version 3.6.4 installed</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $ pyenv install 3.6.4
$ pyenv versions
system
3.6.4
</code></pre></div> </div>
</li>
<li>
<p>virtualenv for Ansible created</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $ pyenv virtualenv 3.6.4 ansible
$ pyenv virtualenvs
3.6.4/envs/ansible (created from /home/askolsam/.pyenv/versions/3.6.4)
ansible (created from /home/askolsam/.pyenv/versions/3.6.4)
</code></pre></div> </div>
</li>
<li>
<p>Ansible 2.5.6 installed</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $ pyenv activate ansible
$ pip install ansible==2.5.6
</code></pre></div> </div>
</li>
</ol>
<h1 id="problem">Problem</h1>
<p>I was trying to update an local ansible module from python 2 to 3, but command <code class="highlighter-rouge">2to3</code> just returned
‘command not found’:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $ pyenv activate ansible
$ python --version
Python 3.6.4
$ pyenv which 2to3
pyenv: 2to3: command not found
The '2to3' command exists in these Python versions:
3.6.4
$ pyenv deactivate
$ pyenv global 3.6.4
$ python --version
Python 3.6.4
$ pyenv which 2to3
/home/askolsam/.pyenv/versions/3.6.4/bin/2to3
</code></pre></div></div>
<h1 id="solution">Solution</h1>
<p>Someone else had this same <a href="https://github.com/pyenv/pyenv-virtualenv/issues/16">issue</a> too.
The solution is not to use <code class="highlighter-rouge">pyenv activate</code> but <code class="highlighter-rouge">pyenv global</code> or <code class="highlighter-rouge">pyenv local</code>:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $ pyenv global ansible 3.6.4
$ pyenv version
ansible (set by /home/askolsam/.pyenv/version)
3.6.4 (set by /home/askolsam/.pyenv/version)
</code></pre></div></div>
<h1 id="resources">Resources</h1>
<ul>
<li><a href="https://github.com/pyenv/pyenv">https://github.com/pyenv/pyenv</a></li>
<li><a href="https://github.com/pyenv/pyenv-virtualenv/">https://github.com/pyenv/pyenv-virtualenv/</a></li>
<li><a href="https://github.com/pyenv/pyenv-virtualenv/issues/16">https://github.com/pyenv/pyenv-virtualenv/issues/16</a></li>
</ul>Sami AskolinWhen using pyenv and it’s pyenv-virtualenv -plugin, the activated virtualenv does not include the /bin -directory of the base python version in the PATH.Fedora 28 and bash shell: ‘command not found’ seems to hang2018-10-16T00:00:00+03:002018-10-16T00:00:00+03:00https://www.askolin.fi/2018/10/16/fedora_28_bash_command_not_found_issue<p><em>When using <a href="https://www.gnu.org/software/bash/">bash shell</a>, a <code class="highlighter-rouge">command_not_found_handle</code> is run if the command can’t
be found. On my Fedora 28 this caused issues.</em></p>
<h1 id="background">Background</h1>
<p>I have several linux workstations on my disposal, one of them runs <a href="https://getfedora.org/">Fedora 28</a>.</p>
<h1 id="what">What</h1>
<p>I recently noticed that if I mistyped a command in a terminal, I would get the usual ‘command not found’ message, but
the prompt would not return until I hit CTRL+c:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[askolsam@workstation ~]$ lsl
bash: lsl: command not found
^C
</code></pre></div></div>
<h1 id="how">How</h1>
<p><a href="https://www.gnu.org/software/bash/">Bash</a> tries to run <code class="highlighter-rouge">command_not_found_handle</code> function whenever it cannot find
the command to run. In more detail, as explained in the <a href="https://tiswww.case.edu/php/chet/bash/bashref.html#Command-Search-and-Execution">bash documentation</a> (emphasis mine):</p>
<blockquote>
<p>After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.</p>
<ol>
<li>If the command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, that function is invoked as described in <a href="https://tiswww.case.edu/php/chet/bash/bashref.html#Shell-Functions">Shell Functions</a>.</li>
<li>If the name does not match a function, the shell searches for it in the list of shell builtins. If a match is found, that builtin is invoked.</li>
<li>If the name is neither a shell function nor a builtin, and contains no slashes, Bash searches each element of $PATH for a directory containing an executable file by that name. Bash uses a hash table to remember the full pathnames of executable files to avoid multiple PATH searches (see the description of hash in <a href="https://tiswww.case.edu/php/chet/bash/bashref.html#Bourne-Shell-Builtins">Bourne Shell Builtins</a>). A full search of the directories in $PATH is performed only if the command is not found in the hash table. <strong>If the search is unsuccessful, the shell searches for a defined shell function named <code class="highlighter-rouge">command_not_found_handle</code>. If that function exists, it is invoked with the original command and the original command’s arguments as its arguments, and the function’s exit status becomes the exit status of the shell.</strong> If that function is not defined, the shell prints an error message and returns an exit status of 127.</li>
<li>If the search is successful, or if the command name contains one or more slashes, the shell executes the named program in a separate execution environment. Argument 0 is set to the name given, and the remaining arguments to the command are set to the arguments supplied, if any.</li>
<li>If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script and the shell executes it as described in <a href="https://tiswww.case.edu/php/chet/bash/bashref.html#Shell-Scripts">Shell Scripts</a>.</li>
<li>If the command was not begun asynchronously, the shell waits for the command to complete and collects its exit status.</li>
</ol>
</blockquote>
<p>Well. The <code class="highlighter-rouge">command_not_found_handle</code> is defined in <code class="highlighter-rouge">/etc/profile.d/PackageKit.sh</code> and it basically runs <code class="highlighter-rouge">/usr/libexec/pk-command-not-found</code>. And for some reason <code class="highlighter-rouge">pk-command-not-found</code> doesn’t want to return.</p>
<h1 id="why">Why</h1>
<ul>
<li><a href="https://linux.die.net/man/1/strace"><code class="highlighter-rouge">strace</code></a> did not give me any straight answers</li>
<li>Someone else in the
<a href="https://unix.stackexchange.com/questions/25681/why-a-long-delay-after-command-not-found">StackExchange</a> had this same issue.</li>
</ul>
<p>Lo and behold, I didn’t have the <em>PackageKit-command-not-found</em> package installed:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[askolsam@workstation ~]$ sudo yum list installed | grep -i PackageKit
PackageKit.x86_64 1.1.10-1.fc28 @updates
PackageKit-command-not-found.x86_64 1.1.10-1.fc28 @updates
PackageKit-glib.x86_64 1.1.10-1.fc28 @updates
PackageKit-gstreamer-plugin.x86_64 1.1.10-1.fc28 @updates
PackageKit-gtk3-module.x86_64 1.1.10-1.fc28 @updates
[askolsam@workstation ~]$ yum search command-not-found
Last metadata expiration check: 1 day, 3:40:53 ago on Mon 15 Oct 2018 10:46:57 EEST.
========================================= Name Matched: command-not-found ==========================================
PackageKit-command-not-found.x86_64 : Ask the user to install command line programs automatically
</code></pre></div></div>
<p>And at this point I just decided to run <code class="highlighter-rouge">unset command_not_found_handle</code> and <del>resume whatever I was originally doing</del>
write a blog post about this issue.</p>
<h1 id="resources">Resources</h1>
<ul>
<li><a href="https://www.gnu.org/software/bash/">https://www.gnu.org/software/bash/</a></li>
<li><a href="https://tiswww.case.edu/php/chet/bash/bashref.html#Command-Search-and-Execution">https://tiswww.case.edu/php/chet/bash/bashref.html#Command-Search-and-Execution</a></li>
<li><a href="https://unix.stackexchange.com/questions/25681/why-a-long-delay-after-command-not-found">https://unix.stackexchange.com/questions/25681/why-a-long-delay-after-command-not-found</a></li>
</ul>Sami AskolinWhen using bash shell, a command_not_found_handle is run if the command can’t be found. On my Fedora 28 this caused issues.A nifty script to pause/unpause X11 applications2018-09-21T00:00:00+03:002018-09-21T00:00:00+03:00https://www.askolin.fi/2018/09/21/pausing_x_applications<p><em>When browsing <a href="https://news.ycombinator.com/item?id=18022540">hacker news</a> I stumbled on a nice <a href="https://github.com/vermaden/scripts/blob/master/desktop-pause.sh">little script</a> for pausing X11 applications.</em></p>
<p>Why would I want to pause applications? Well, my use-case is the same as the examples given in the original <a href="https://vermaden.wordpress.com/2018/09/19/freebsd-desktop-part-16-configuration-pause-any-application/">blog-post</a> (emphasis mine):</p>
<blockquote>
<p>Lets say you have Firefox started with many tabs open (50+) and you know that it drains battery life from your laptop. You can close it but when You will need information from any of those tabs, then You will have to start Firefox again (even more battery usage) and load all needed tabs (battery …). The alternative is to pause all Firefox processes when You do not use them. This will freeze all its processes and subprocesses and <strong>it will not use any CPU (or battery) power.</strong> When you will need it, then you will unpause it without the need to load all tabs again.</p>
</blockquote>
<h1 id="installation">Installation</h1>
<p>My install log on a <a href="http://www.thinkwiki.org/wiki/Category:W530">Lenovo Thinkpad W530</a> workstation, running a <a href="https://wiki.debian.org/DebianStretch">Debian Stretch (9)</a>.</p>
<ol>
<li>The installation directory is <code class="highlighter-rouge">~/bin</code></li>
<li>Download (and check) <a href="https://github.com/vermaden/scripts/blob/master/desktop-pause.sh">the script from github</a>: <code class="highlighter-rouge">$ wget https://raw.githubusercontent.com/vermaden/scripts/master/desktop-pause.sh</code></li>
<li><code class="highlighter-rouge">$ chmod +x ~/bin/desktop-pause.sh</code></li>
<li>Install dependencies: <code class="highlighter-rouge">$ sudo apt install x11-utils xdotool zenity xbindkeys</code></li>
<li>Create a default configuration for xbindkeys: <code class="highlighter-rouge">$ xbindkeys --defaults > ~/.xbindkeysrc</code></li>
<li>Edit the <code class="highlighter-rouge">~/.xbindkeysrc</code>, add the following lines:
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # [Pause] FOR ACTIVE WINDOW (Fn+P on W530)
"~/bin/desktop-pause.sh -a"
Mod2 + Pause
</code></pre></div> </div>
</li>
<li>Add <code class="highlighter-rouge">xbindkeys</code> to <code class="highlighter-rouge">~/.xinitrc</code></li>
</ol>
<h1 id="future-improvements">Future improvements</h1>
<p>The script tries to write stats on a nonexistent file/directory. This would be an easy fix, but as the error message is being hidden when run via <code class="highlighter-rouge">xbindkey</code>-bind, I’m not going to do anything about it.</p>
<h1 id="resources">Resources</h1>
<ul>
<li><a href="https://vermaden.wordpress.com/2018/09/19/freebsd-desktop-part-16-configuration-pause-any-application/">https://vermaden.wordpress.com/2018/09/19/freebsd-desktop-part-16-configuration-pause-any-application/</a></li>
<li><a href="https://github.com/vermaden/scripts/">https://github.com/vermaden/scripts/</a></li>
</ul>Sami AskolinWhen browsing hacker news I stumbled on a nice little script for pausing X11 applications.GRUB, why didn’t you update?2018-05-14T00:00:00+03:002018-05-14T00:00:00+03:00https://www.askolin.fi/2018/05/14/rhel6-kernel-updated-grub-not<p><em>A RHEL6 server kernel got updated but GRUB entries were not, causing an older kernel to be loaded on boot.</em></p>
<h1 id="background">Background</h1>
<p>Our hosting provider’s SLA include installing official updates* to our RHEL6 servers. As we do use some 3rd party
repositories, we constantly monitor for available updates.</p>
<p>* <em>excluding any software from 3rd party repositories</em></p>
<p>Most of the time we react faster to available updates than our hosting provider and tend to install even the official updates ourselves.</p>
<p>Last thursday our hosting provider installed a new kernel version 2.6.32-696.28.1.el6.x86_64. I mention this as I do
not know what RHEL-specific infrastructure software they use when installing updates. Common people like us just use <code class="highlighter-rouge">yum update</code> from the command line…</p>
<h1 id="what">What</h1>
<p>Today I wanted to get rid of <a href="https://www.icinga.com/">icinga’s</a> notifications about server(s) requiring a reboot due
updated kernel.</p>
<p>I did the usual routine for every server:</p>
<ul>
<li>Remove server from the load balancer pool</li>
<li>Run <code class="highlighter-rouge">yum update</code> to install other (possible) updates</li>
<li>Reboot the server</li>
<li>Restore server to the load balancer pool</li>
</ul>
<p>and felt good about myself as this was one task off from my TODO list for today.</p>
<p>Until I noticed that icinga still complains about the kernel.</p>
<h1 id="how">How</h1>
<p>Simple.</p>
<p>There are three kernels installed in <code class="highlighter-rouge">/boot</code>:</p>
<ul>
<li>2.6.32-696.20.1</li>
<li>2.6.32-696.23.1</li>
<li>2.6.32-696.28.1</li>
</ul>
<p>The <code class="highlighter-rouge">/boot/grub/grub.conf</code> only contains references to the first two, excluding the 2.6.32-696.28.1.</p>
<h1 id="why">Why?</h1>
<p>I have no idea.</p>
<p>I’m <strong>not</strong> going to manually regenerate the <code class="highlighter-rouge">grub.conf</code>, instead I’m just going to wait for the next kernel update to
see if things will fix themselves out.</p>
<p>I might change my mind though, who knows.</p>
<h1 id="update-2018-05-29">Update 2018-05-29</h1>
<p>Probably this has something to do with <a href="https://access.redhat.com/solutions/3163151">this issue</a>.
Unfortunately I cannot access the full post.</p>
<p>I could work around the issue by running</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo yum reinstall kernel-2.6.32-696.30.1.el6.x86_64
</code></pre></div></div>
<p>(Yes, our service provider seems to have installed yet another kernel version through satellite).</p>
<p>I hope that RedHat fixes the actual issue soon.</p>Sami AskolinA RHEL6 server kernel got updated but GRUB entries were not, causing an older kernel to be loaded on boot.Hanging ‘check_yum’ plugin for nagios/icinga starves your target host2018-04-05T00:00:00+03:002018-04-05T00:00:00+03:00https://www.askolin.fi/2018/04/05/icinga_check_yum_hangs<p><em><a href="https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_yum/details">‘check_yum’</a>
<a href="https://exchange.nagios.org/directory/Plugins/">nagios-plugin</a> can starve your target host if the process is
interrupted and the lock file is never cleared.</em></p>
<h1 id="mystery-of-hanging-processes">Mystery of hanging processes</h1>
<p>At <a href="http://www.kaaosunlimited.fi">Kaaos Unlimited Oy</a>, we run
<a href="https://www.icinga.com/docs/icinga1/latest/en/">icinga 1.x</a> to monitor our hosts.
Last week I noticed that ‘check for updates’ -check constantly failed/timed out on one of our hosts. In addition, the host in
question started to show signs of performance degradation and the
<a href="https://en.wikipedia.org/wiki/Load_(computing)#Unix-style_load_calculation">loads</a> were indeed slowly going up.
It got so bad, that even trying to login via SSH into the host became impossible.</p>
<p>Rebooting the server (forcefully) was successfull and for a while things seemed to run ok, except the icinga still
timed out on ‘check for updates’. Fast forward couple of hours and I finally had some time to investigate.</p>
<h1 id="investigation">Investigation</h1>
<p>Not really knowing where to start, I ran <code class="highlighter-rouge">ps -aux</code> which immediately showed me that there were several ‘check_yum’
processes running. I knew this shouldn’t be the case. BTW, I had always imagined that icinga/nagios plugins running on
the target host would eventually timeout themselves. You always learn…</p>
<p>I killed the dangling processes with <code class="highlighter-rouge">sudo pkill -9 yum</code> and then tried running the check manually
<code class="highlighter-rouge">sudo -u nagios check_yum</code>.</p>
<p>Nothing. No output, the command just hanged there. But <code class="highlighter-rouge">CTRL+c</code> worked without issues and I was back on the command
line.</p>
<p>Back in the C/C++ days I had stumbled into a nice little tool called <a href="https://linux.die.net/man/1/strace">strace</a>.
Being as lazy as I am, I decided to try that tool out, before trying to go through all
<a href="https://en.wikipedia.org/wiki/Yum_(software)">yum</a> related logs.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo -su nagios
$ strace check_yum
...
poll([{fd=5, events=POLLIN|POLLPRI}], 1, -1) = 1 ([{fd=5, revents=POLLIN}])
read(5, "Existing lock /var/tmp/yum-nagio"..., 4096) = 332
poll([{fd=5, events=POLLIN|POLLPRI}], 1, -1) = 1 ([{fd=5, revents=POLLIN}])
read(5, "Another app is currently holding"..., 4096) = 236
</code></pre></div></div>
<p>And the last 4 lines kept repeating.</p>
<p>Well that was surprisingly easy! A lock-file (among <a href="https://unix.stackexchange.com/questions/92257/yum-user-temp-files-var-tmp-yum-fills-up-with-repo-data/92268">other things</a>)
was in the directory <code class="highlighter-rouge">/var/tmp/yum-nagios-2pv9qy/x86_64/7</code>.</p>
<p>Now, I speculate that at some stage ‘check_yum’ process had been killed before it could remove the lock-file, causing
the subsequent ‘check_yum’ commands to hang forever.</p>
<h1 id="solution">Solution</h1>
<p><code class="highlighter-rouge">$ sudo rm -Rf /var/tmp/yum-nagios-2pv9qy</code></p>Sami Askolin‘check_yum’ nagios-plugin can starve your target host if the process is interrupted and the lock file is never cleared.The difficulty of walking and chewing bubblegum at the same time2018-03-30T00:00:00+03:002018-03-30T00:00:00+03:00https://www.askolin.fi/2018/03/30/mindmap-atom<p><em>Try <a href="https://atom.io/packages/markdown-mindmap">markdown-mindmap</a> as an <a href="https://atom.io">atom-editor</a> package to
visualize mind maps written in <a href="https://en.wikipedia.org/wiki/Markdown">markdown</a>.</em></p>
<h1 id="taking-notes">Taking notes</h1>
<p>Taking notes in meetings is something I really struggle, especially if I try to participate in the conversation
at the same time.</p>
<p>I’ve mitigated this issue in two ways:</p>
<h2 id="delegation">Delegation</h2>
<p>My preferred way is to delegate the task of creating notes to someone else.</p>
<p><img src="https://www.askolin.fi/assets/img/no-shit.gif" alt="" /></p>
<p>I’ve been able to pull this off (using my divine powers as a <a href="http://www.kaaosunlimited.fi/#people">small-time CEO</a>),
but I really cannot expect this option to be always available. This also tends to make me annoyed by my own
incompetence.</p>
<p>So, the only way to make myself feel better is to suck it up and try to improve.</p>
<h2 id="mind-maps">Mind maps</h2>
<p>Writing <a href="https://en.wikipedia.org/wiki/Mind_map">mind maps</a> is a nice way to take notes.
The concept and execution is simple enough to work, even if I’m totally unable to multitask.</p>
<p><em>I suppose I don’t need to feel bad about that after reading
<a href="https://theness.com/neurologicablog/index.php/multitasking-can-you-walk-and-chew-gum-at-the-same-time/">this article</a>.</em></p>
<p>Anyway, I’ve always relied on some software for creating the mind maps. For starters, my handwriting is horrible and
with software you get the freedom of reorganizing and restructuring the mind map (later) as you please.</p>
<p>First I used <a href="http://freemind.sourceforge.net/wiki/index.php/Main_Page">FreeMind</a>. It got the job done, but it had some
graphical glitches when running on <a href="https://linuxmint.com/download_lmde.php">Linux Mint Debian Edition</a>.</p>
<p>I re-installed my workstation around Christmas 2017, switched to <a href="https://wiki.debian.org/DebianStretch">Debian Stretch</a>
and decided to give <a href="http://www.insilmaril.de/vym/">VYM</a> a try.
It felt leaner than FreeMind, had no glitches and also got the job done.</p>
<p>But I wasn’t quite satisfied.</p>
<h1 id="markdown-to-the-rescue">Markdown to the rescue</h1>
<p>Browsing the <a href="https://news.ycombinator.com">Hacker News</a> I stumbled into
<a href="https://tobloef.com/text2mindmap/">text2mindmap</a>. As I nowadays write most of my notes in
<a href="https://en.wikipedia.org/wiki/Markdown">Markdown</a> anyway, I was intriqued.</p>
<p>However, I wanted a tool which could be run on my local workstation and without a network connection.</p>
<p>Couple of minutes in Google and I found <a href="https://atom.io/packages/markdown-mindmap">markdown-mindmap</a>.</p>Sami AskolinTry markdown-mindmap as an atom-editor package to visualize mind maps written in markdown.A journal of installing Jekyll2018-03-25T00:00:00+02:002018-03-25T00:00:00+02:00https://www.askolin.fi/2018/03/25/jekyll<p><em>Creating a website using git, markdown and <a href="https://jekyllrb.com/">Jekyll</a> in 3 hours.</em></p>
<p>I want to create content as static pages, but writing pure HTML would be too tedious.
<a href="https://jekyllrb.com/">Jekyll</a> caught my eye once, as the project was mentioned in
<a href="https://news.ycombinator.com/">Hacker News</a>.</p>
<p>I searched for similar projects (and found several), but nevertheless decided to try Jekyll out.</p>
<p><strong>Result</strong></p>
<p>I was able to install Jekyll and create a base blog skeleton in 3 hours.</p>
<h1 id="dependencies">Dependencies</h1>
<p><em>These dependencies are purely due my personal preferences.</em></p>
<h2 id="ruby-version-manager-rvm"><a href="https://rvm.io/">Ruby Version Manager (RVM)</a></h2>
<h3 id="why">Why?</h3>
<p>I want to use similar workflow as I have with Python <a href="https://github.com/pyenv/pyenv">(pyenv)</a> and Node.js <a href="https://github.com/creationix/nvm">(nvm)</a>.</p>
<p>This means the ability to install multiple ruby versions and gems depending on the project I’m working on without
polluting the global system.</p>
<h3 id="installation">Installation</h3>
<p>I followed the steps as in explained in <a href="https://rvm.io/">https://rvm.io/</a></p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ gpg --keyserver hkp://keys.gnupg.net --recv-keys \
409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ curl -sSL https://get.rvm.io | bash -s stable
</code></pre></div></div>
<p>Installation automatically updated the <code class="highlighter-rouge">~/.bashrc</code> and <code class="highlighter-rouge">~/.profile</code> files.</p>
<p>I checked the results and everything looked OK, except I wondered why the <code class="highlighter-rouge">$HOME/.rvm/scripts/rvm</code> was <a href="https://bash.cyberciti.biz/guide/Source_command">sourced</a> only in <code class="highlighter-rouge">~/.profile</code> but PATH was updated in both files.</p>
<p>I closed the current terminal and opened a new one; the changes to PATH environment variable came to effect and I
could run <code class="highlighter-rouge">rvm</code> in the command line.</p>
<h2 id="ruby-v241">Ruby v2.4.1</h2>
<h3 id="why-1">Why?</h3>
<p>Well, Jekyll is written in Ruby.</p>
<p>My knowledge and experience on using Ruby is limited; therefore I’m not really familiar with the different Ruby
versions and implementations.</p>
<p>So I checked what was available:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby[-9.1.13.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.84]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1[.3.0]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
</code></pre></div></div>
<p>Those results led me to do some googling and I learned that Ruby MRI seems to be the ‘reference implementation’,
so let’s roll with that.</p>
<p>Then I checked <a href="https://www.ruby-lang.org/en/downloads/releases/">https://www.ruby-lang.org/en/downloads/releases/</a> to learn more about the different MRI versions. Well,
nothing indicated why I shouldn’t install the latest available version in RVM, so I chose 2.4.1.</p>
<h3 id="installation-1">Installation</h3>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ rvm install 2.4.1
Searching for binary rubies, this might take some time.
No binary rubies available for: debian/9/x86_64/ruby-2.4.1.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for debian.
Installing requirements for debian.
Updating system
askolsam password required for 'apt-get --quiet --yes update':
...
</code></pre></div></div>
<p>At this stage I entered my password and let RVM do it’s thing. Few minutes later the process finished successfully.</p>
<p>I tried to test the installed Ruby:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ rvm use ruby-2.4.1
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
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 an example.
</code></pre></div></div>
<p>Ok, this is clearly a symptom of the file <code class="highlighter-rouge">$HOME/.rvm/scripts/rvm</code> not being <a href="https://bash.cyberciti.biz/guide/Source_command">sourced</a>, just like I wondered in the RVM installation phase.</p>
<p>For testing purposes I just manually sourced the file:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ source $HOME/.rvm/scripts/rvm
</code></pre></div></div>
<p>and tried again:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ rvm use ruby-2.4.1
Using /home/askolsam/.rvm/gems/ruby-2.4.1
$ which ruby
/home/askolsam/.rvm/rubies/ruby-2.4.1/bin/ruby
</code></pre></div></div>
<p>Installation succesful.</p>
<h4 id="update-2018-06-24">Update 2018-06-24</h4>
<p>I should/could have read the
<a href="https://rvm.io/integration/gnome-terminal/">URL mentioned in the error message above</a>.</p>
<h2 id="create-a-rvm-project-files-to-my-git-repo">Create a RVM project files to my git repo</h2>
<p>I just followed the <a href="https://rvm.io/rvm/best-practices">RVM best practices guide</a>.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~src/webpages
$ rvm use ruby-2.4.1
$ rvm gemset create jekyll
ruby-2.4.1 - #gemset created /home/askolsam/.rvm/gems/ruby-2.4.1@jekyll
ruby-2.4.1 - #generating jekyll wrappers........
$ rvm --ruby-version use 2.4.1@jekyll
</code></pre></div></div>
<p>Test that settings are applied:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~
$ rvm use system
Now using system ruby.
$ which ruby
/usr/bin/ruby
$ rvm gemset list
gemsets for system (found in /home/askolsam/.rvm/gems/system)
=> (default)
*
$ cd ~src/webpages
$ which ruby
/home/askolsam/.rvm/rubies/ruby-2.4.1/bin/ruby
$ rvm gemset list
gemsets for ruby-2.4.1 (found in /home/askolsam/.rvm/gems/ruby-2.4.1)
(default)
global
=> jekyll
</code></pre></div></div>
<p>Looks ok.</p>
<h1 id="installing-jekyll">Installing Jekyll</h1>
<p>As instructed in <a href="https://jekyllrb.com/docs/quickstart/">Jekyll quick-start guide</a>, I ran:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~src/webpages
$ gem install jekyll
Fetching: public_suffix-3.0.2.gem (100%)
Successfully installed public_suffix-3.0.2
Fetching: addressable-2.5.2.gem (100%)
Successfully installed addressable-2.5.2
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: http_parser.rb-0.6.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.6.0
Fetching: eventmachine-1.2.5.gem (100%)
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.5
Fetching: em-websocket-0.5.1.gem (100%)
Successfully installed em-websocket-0.5.1
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.5.gem (100%)
Successfully installed i18n-0.9.5
Fetching: rb-fsevent-0.10.3.gem (100%)
Successfully installed rb-fsevent-0.10.3
Fetching: ffi-1.9.23.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.9.23
Fetching: rb-inotify-0.9.10.gem (100%)
Successfully installed rb-inotify-0.9.10
Fetching: sass-listen-4.0.0.gem (100%)
Successfully installed sass-listen-4.0.0
Fetching: sass-3.5.6.gem (100%)
Successfully installed sass-3.5.6
Fetching: jekyll-sass-converter-1.5.2.gem (100%)
Successfully installed jekyll-sass-converter-1.5.2
Fetching: ruby_dep-1.5.0.gem (100%)
Successfully installed ruby_dep-1.5.0
Fetching: listen-3.1.5.gem (100%)
Successfully installed listen-3.1.5
Fetching: jekyll-watch-2.0.0.gem (100%)
Successfully installed jekyll-watch-2.0.0
Fetching: kramdown-1.16.2.gem (100%)
Successfully installed kramdown-1.16.2
Fetching: liquid-4.0.0.gem (100%)
Successfully installed liquid-4.0.0
Fetching: mercenary-0.3.6.gem (100%)
Successfully installed mercenary-0.3.6
Fetching: forwardable-extended-2.6.0.gem (100%)
Successfully installed forwardable-extended-2.6.0
Fetching: pathutil-0.16.1.gem (100%)
Successfully installed pathutil-0.16.1
Fetching: rouge-3.1.1.gem (100%)
Successfully installed rouge-3.1.1
Fetching: safe_yaml-1.0.4.gem (100%)
Successfully installed safe_yaml-1.0.4
Fetching: jekyll-3.7.3.gem (100%)
Successfully installed jekyll-3.7.3
Parsing documentation for public_suffix-3.0.2
Installing ri documentation for public_suffix-3.0.2
Parsing documentation for addressable-2.5.2
Installing ri documentation for addressable-2.5.2
Parsing documentation for colorator-1.1.0
Installing ri documentation for colorator-1.1.0
Parsing documentation for http_parser.rb-0.6.0
Installing ri documentation for http_parser.rb-0.6.0
Parsing documentation for eventmachine-1.2.5
Installing ri documentation for eventmachine-1.2.5
Parsing documentation for em-websocket-0.5.1
Installing ri documentation for em-websocket-0.5.1
Parsing documentation for concurrent-ruby-1.0.5
Installing ri documentation for concurrent-ruby-1.0.5
Parsing documentation for i18n-0.9.5
Installing ri documentation for i18n-0.9.5
Parsing documentation for rb-fsevent-0.10.3
Installing ri documentation for rb-fsevent-0.10.3
Parsing documentation for ffi-1.9.23
Installing ri documentation for ffi-1.9.23
Parsing documentation for rb-inotify-0.9.10
Installing ri documentation for rb-inotify-0.9.10
Parsing documentation for sass-listen-4.0.0
Installing ri documentation for sass-listen-4.0.0
Parsing documentation for sass-3.5.6
Installing ri documentation for sass-3.5.6
Parsing documentation for jekyll-sass-converter-1.5.2
Installing ri documentation for jekyll-sass-converter-1.5.2
Parsing documentation for ruby_dep-1.5.0
Installing ri documentation for ruby_dep-1.5.0
Parsing documentation for listen-3.1.5
Installing ri documentation for listen-3.1.5
Parsing documentation for jekyll-watch-2.0.0
Installing ri documentation for jekyll-watch-2.0.0
Parsing documentation for kramdown-1.16.2
Installing ri documentation for kramdown-1.16.2
Parsing documentation for liquid-4.0.0
Installing ri documentation for liquid-4.0.0
Parsing documentation for mercenary-0.3.6
Installing ri documentation for mercenary-0.3.6
Parsing documentation for forwardable-extended-2.6.0
Installing ri documentation for forwardable-extended-2.6.0
Parsing documentation for pathutil-0.16.1
Installing ri documentation for pathutil-0.16.1
Parsing documentation for rouge-3.1.1
Installing ri documentation for rouge-3.1.1
Parsing documentation for safe_yaml-1.0.4
Installing ri documentation for safe_yaml-1.0.4
Parsing documentation for jekyll-3.7.3
Installing ri documentation for jekyll-3.7.3
Done installing documentation for public_suffix, addressable, colorator, http_parser.rb,
eventmachine, em-websocket, concurrent-ruby, i18n, rb-fsevent, ffi, rb-inotify, sass-listen,
sass, jekyll-sass-converter, ruby_dep, listen, jekyll-watch, kramdown, liquid, mercenary,
forwardable-extended, pathutil, rouge, safe_yaml, jekyll after 33 seconds
25 gems installed
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
Done installing documentation for bundler after 4 seconds
1 gem installed
</code></pre></div></div>
<p>“Everything went better than expected”.</p>
<h1 id="creating-the-blog-skeleton">Creating the blog skeleton</h1>
<p>As instructed in <a href="https://jekyllrb.com/docs/quickstart/">Jekyll quick-start guide</a>, I ran:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~src/webpages
$ jekyll new blog
Running bundle install in /home/askolsam/src/webpages/blog...
Bundler: The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Bundler: Fetching gem metadata from https://rubygems.org/...........
Bundler: Fetching gem metadata from https://rubygems.org/.
Bundler: Resolving dependencies...
Bundler: Using public_suffix 3.0.2
Bundler: Using addressable 2.5.2
Bundler: Using bundler 1.16.1
Bundler: Using colorator 1.1.0
Bundler: Using concurrent-ruby 1.0.5
Bundler: Using eventmachine 1.2.5
Bundler: Using http_parser.rb 0.6.0
Bundler: Using em-websocket 0.5.1
Bundler: Using ffi 1.9.23
Bundler: Using forwardable-extended 2.6.0
Bundler: Using i18n 0.9.5
Bundler: Using rb-fsevent 0.10.3
Bundler: Using rb-inotify 0.9.10
Bundler: Using sass-listen 4.0.0
Bundler: Using sass 3.5.6
Bundler: Using jekyll-sass-converter 1.5.2
Bundler: Using ruby_dep 1.5.0
Bundler: Using listen 3.1.5
Bundler: Using jekyll-watch 2.0.0
Bundler: Using kramdown 1.16.2
Bundler: Using liquid 4.0.0
Bundler: Using mercenary 0.3.6
Bundler: Using pathutil 0.16.1
Bundler: Using rouge 3.1.1
Bundler: Using safe_yaml 1.0.4
Bundler: Using jekyll 3.7.3
Bundler: Fetching jekyll-feed 0.9.3
Bundler: Installing jekyll-feed 0.9.3
Bundler: Fetching jekyll-seo-tag 2.4.0
Bundler: Installing jekyll-seo-tag 2.4.0
Bundler: Fetching minima 2.4.0
Bundler: Installing minima 2.4.0
Bundler: Bundle complete! 4 Gemfile dependencies, 29 gems now installed.
Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.
New jekyll site installed in /home/askolsam/src/webpages/blog.
</code></pre></div></div>
<h1 id="previewing-the-blog">Previewing the blog</h1>
<p>As instructed in <a href="https://jekyllrb.com/docs/quickstart/">Jekyll quick-start guide</a>, I ran:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cd ~/src/webpages/blog
$ bundler exec jekyll serve
configuration file: /home/askolsam/src/webpages/blog/_config.yml
Source: /home/askolsam/src/webpages/blog
Destination: /home/askolsam/src/webpages/blog/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.368 seconds.
Auto-regeneration: enabled for /home/askolsam/src/webpages/blog'
Server address: http://127.0.0.1:4000/blog/
Server running... press ctrl-c to stop.
</code></pre></div></div>
<p>I opened http://127.0.0.1:4000/blog/ with my browser and very minimalistic example content was visible.</p>
<p>Mission accomplished.</p>Sami AskolinCreating a website using git, markdown and Jekyll in 3 hours.