Trying to download the latest version of pandoc in circleci build script - pandoc

I'm trying to do a conversion of my README from markdown to reStructuredText
using pandoc so I can build an egg which can be deployed to pypi. Unfortunately the version of pandoc that circleci is uing (1.17.2) is having an issue with how I have some tables structured. It looks like like if I use the latest version of pandoc (2.9.1.1) everything will work fine but I can't seem to get circleci to download the latest version.
So far I've tried using the following within my .circleci/config.yml:
steps:
- run: sudo apt-get update && sudo apt-get install -y pandoc
And I get the following output:
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:3 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:4 http://deb.debian.org/debian stretch-backports InRelease [91.8 kB]
Hit:5 http://deb.debian.org/debian stretch Release
Fetched 277 kB in 0s (624 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
liblua5.1-0 libluajit-5.1-2 libluajit-5.1-common pandoc-data
Suggested packages:
texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc
texlive-latex-extra wkhtmltopdf
The following NEW packages will be installed:
liblua5.1-0 libluajit-5.1-2 libluajit-5.1-common pandoc pandoc-data
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 9724 kB of archives.
After this operation, 72.6 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b2 [111 kB]
Get:2 http://deb.debian.org/debian stretch/main amd64 libluajit-5.1-common all 2.0.4+dfsg-1 [36.6 kB]
Get:3 http://deb.debian.org/debian stretch/main amd64 libluajit-5.1-2 amd64 2.0.4+dfsg-1+b1 [207 kB]
Get:4 http://deb.debian.org/debian stretch/main amd64 pandoc-data all 1.17.2~dfsg-3 [265 kB]
Get:5 http://deb.debian.org/debian stretch/main amd64 pandoc amd64 1.17.2~dfsg-3 [9104 kB]
Fetched 9724 kB in 0s (80.5 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package liblua5.1-0:amd64.
(Reading database ... 42585 files and directories currently installed.)
Preparing to unpack .../liblua5.1-0_5.1.5-8.1+b2_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Selecting previously unselected package libluajit-5.1-common.
Preparing to unpack .../libluajit-5.1-common_2.0.4+dfsg-1_all.deb ...
Unpacking libluajit-5.1-common (2.0.4+dfsg-1) ...
Selecting previously unselected package libluajit-5.1-2:amd64.
Preparing to unpack .../libluajit-5.1-2_2.0.4+dfsg-1+b1_amd64.deb ...
Unpacking libluajit-5.1-2:amd64 (2.0.4+dfsg-1+b1) ...
Selecting previously unselected package pandoc-data.
Preparing to unpack .../pandoc-data_1.17.2~dfsg-3_all.deb ...
Unpacking pandoc-data (1.17.2~dfsg-3) ...
Selecting previously unselected package pandoc.
Preparing to unpack .../pandoc_1.17.2~dfsg-3_amd64.deb ...
Unpacking pandoc (1.17.2~dfsg-3) ...
Setting up libluajit-5.1-common (2.0.4+dfsg-1) ...
Setting up pandoc-data (1.17.2~dfsg-3) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up libluajit-5.1-2:amd64 (2.0.4+dfsg-1+b1) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Setting up pandoc (1.17.2~dfsg-3) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Here is the information on what os is being used in my build:
> cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
I would love to try and get the latest version 2.9.1.1

You could use this code, which we also use with pandoc/lua-filter to always use the latest pandoc version:
RELEASES_URL='https://github.com/jgm/pandoc/releases'
# the 'latest' URL redirects to the name of the latest tag.
export PANDOCVERSION=$(curl -I "$RELEASES_URL/latest" | sed -ne 's#Location:.*tag/\(.*\)$#\1#p' | tr -d "\n\r")
# Show pandoc version in logs
echo $PANDOCVERSION
# downloads and extract
wget $RELEASES_URL/download/$PANDOCVERSION/pandoc-$PANDOCVERSION-linux-amd64.tar.gz
tar xvzf pandoc-$PANDOCVERSION-linux-amd64.tar.gz
# add executable to PATH
export PATH=$HOME/pandoc-$PANDOCVERSION/bin:$PATH

Related

Getting "git: command not found" in a Docker container that has git installed

I'm running the following in a Docker container (in a Gitlab CI/CD pipeline) with the python:3 image. I installed git using the following command:
apt-get update
apt-get install -y git
Based on the output, this wasn't even necessary because git was already installed. Unfortunately, I got the following output that states that the "git" command was not found even though the "git" command was used earlier in the script. Does anyone have any idea what's going on here?
$ apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [109 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
Fetched 8494 kB in 1s (6639 kB/s)
Reading package lists...
$ apt-get install -y git
Reading package lists...
Building dependency tree...
Reading state information...
git is already the newest version (1:2.30.2-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
$ git --version
git version 2.30.2
$ git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"
$ git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"
$ regex="^report\/[^\/]*\/([^\/]*)\/(.*)"
$ [[ $CI_COMMIT_BRANCH =~ $regex ]]
$ CUSTOMER="${BASH_REMATCH[1]}"
$ PATH="${BASH_REMATCH[2]}"
$ RELPATH=$(.ci/scripts/find_relative.py "${CI_PROJECT_PATH}" "${PATH}")
$ git submodule add ${RELPATH} ${CUSTOMER}
/scripts-530-146123/step_script: line 151: git: command not found
ERROR: Job failed: command terminated with exit code 1
In this line:
PATH="${BASH_REMATCH[2]}"
you alter the PATH variable. I suspect it no longer has /usr/bin (or wherever git is) in the new path.

Problems with the installation of VirtualBox on Ubuntu 20.04.1 LTS

just so you know I'm pretty new at Linux.
I just made the jump from Ubuntu 19.10 to Ubuntu 20.04.1 LTS because I thought there wouldn't be a problem with VirtualBox.
When the upgrade was finished I noticed VirtualBox was gone, I tried to install it following the instruction on the official website and other sites.
I don't know what you guys exactly need to help me solve the problem so here's some informations :
Here's what appears when I do sudo apt update :
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:4 http://download.virtualbox.org/virtualbox/debian focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [169 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [412 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [93,5 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [724 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [399 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [180 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [11,4 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/restricted i386 Packages [13,4 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [110 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [16,5 kB]
Fetched 2 352 kB in 1s (2 345 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.
Now sudo apt install virtualbox virtualbox-ext-pack :
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package virtualbox is a virtual package provided by:
virtualbox-6.1 6.1.16-140961~Ubuntu~eoan
virtualbox-6.0 6.0.24-139119~Ubuntu~eoan
You should explicitly select one to install.
Package virtualbox-ext-pack is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'virtualbox' has no installation candidate
E: Package 'virtualbox-ext-pack' has no installation candidate
Or when I do sudo apt install virtualbox-6.0 :
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
virtualbox-6.0 : Depends: libqt5printsupport5 (>= 5.0.2) but it is not installable
Depends: python (< 2.8) but it is not installable
Depends: python (>= 2.7) but it is not installable
Depends: python:any (>= 2.6.6-7~)
Recommends: libsdl-ttf2.0-0 but it is not installable
Recommends: gcc but it is not going to be installed
Recommends: make but it is not going to be installed or
build-essential but it is not going to be installed or
dpkg-dev but it is not going to be installed
Recommends: binutils but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I did
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
and
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | \
sudo tee -a /etc/apt/sources.list.d/virtualbox.list
without any problems.
I hope everyone is having a good day :)
#Just Download a debian file:
https://download.virtualbox.org/virtualbox/6.1.16/virtualbox-6.1_6.1.16-140961~Ubuntu~eoan_amd64.deb
And install with :
sudo dpkg -i virtualbox-6.1_6.1.16-140961~Ubuntu~eoan_amd64.deb
#If get's Any error
sudo apt install -f
Just add a repository to your system to download the package virtualbox needs:
deb http://deb.debian.org/debian buster main contrib non-free
And then reinstall with the command:
sudo apt install virtualbox-6.1
It worked with me.
I solved it in the following way
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian bionic contrib"
sudo apt-get update
If when doing apt-get update it appears:
N: Skipping acquire of configured file 'contrib/binary-i386/Packages'
as repository 'http://download.virtualbox.org/virtualbox/debian bionic
InRelease' doesn't support architecture 'i386'
then:
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list
continue:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install libpng16-16 libqt5core5a libqt5printsupport5 libqt5widgets5 libqt5x11extras5
sudo apt-get install virtualbox-6.0 -y

How to install version specified Ruby using apt

I tried to install Ruby with version specified 2.5.1 (the version is just example), and tried following script, but I got an error as follows. Is it possible to install Ruby with a version using apt installing so I can deal with Ruby version dependency issue?
$ sudo apt update ; sudo apt install ruby-full=2.5.1
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://ppa.launchpad.net/kelleyk/emacs/ubuntu bionic InRelease
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:6 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:7 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:8 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Hit:9 http://ppa.launchpad.net/teejee2008/timeshift/ubuntu bionic InRelease
Fetched 64.4 kB in 2s (41.9 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
40 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '2.5.1' for 'ruby-full' was not found
You can install rbenv which is a Ruby Environment and then you can install the version of Ruby you want over it.
Refer to this answer.
The specific version of ruby you want to install has to be a package available in your Ubuntu distro's package repository. A quick way to check this is using apt list | grep ruby-full or apt list | grep ruby.
If you don't find the version you're looking for, you can add a repository and download it from there. Brightbox is a widely used repository maintaining several ruby version packages. Their installation docs should help you.
Note: I still recommend that you use a ruby version manager like rbenv or rvm.

Upgrading python version on Bash on Ubuntu on Windows?

so I'm currently trying to upgrade the python version in the bash on ubuntu on windows subsystem. However from my understanding it is not easy to update python from the command line. Lastly, "where" exactly is my unix subsystem? For example, is there something like a unix portion on my file system, where I can just drag files into? Thanks
It is an older question, however I had to do the same thing today (use python3.6 on my windows 10 laptop).
Press Windows + R (to open the run command dialog)
Type: bash + press Enter
You will get a new windows bash prompt window.
Type first lsb_release -a to check that you run the latest bash/ubuntu environment on your Windows Machine (might be ubuntu 14.04, while 16.04 is the current one).
raz#HOSTNAME:~/myPlayground$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
If you are running an older version upgrade by running do-release-upgrade
raz#HOSTNAME:~/myPlayground$ sudo do-release-upgrade
[sudo] password for raz:
Checking for a new Ubuntu release
No new release found.
Add the PPA custom repository (the standard apt repos have only 3.5 for now)
raz#HOSTNAME:~/myPlayground$ sudo add-apt-repository ppa:jonathonf/python-3.6
A plain backport of *just* Python 3.6. System extensions/Python libraries may or may not work.
Don't remove Python 3.5 from your system - it will break.
More info: https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmp5vq72la1/secring.gpg' created
gpg: keyring `/tmp/tmp5vq72la1/pubring.gpg' created
gpg: requesting key F06FC659 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp5vq72la1/trustdb.gpg: trustdb created
gpg: key F06FC659: public key "Launchpad PPA for J Fernyhough" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
Update the apt information:
raz#HOSTNAME:~/myPlayground$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial InRelease [18.0 kB]
Get:4 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages [4,760 B]
Get:5 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en [2,128 B]
Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Fetched 241 kB in 10s (22.2 kB/s)
Reading package lists... Done
Finally install python3.6:
raz#HOSTNAME:~/myPlayground$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython3.6-minimal libpython3.6-stdlib python3.6-minimal
Suggested packages:
python3.6-venv python3.6-doc binfmt-support
The following NEW packages will be installed:
libpython3.6-minimal libpython3.6-stdlib python3.6 python3.6-minimal
0 upgraded, 4 newly installed, 0 to remove and 3 not upgraded.
Need to get 4,505 kB of archives.
After this operation, 23.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 libpython3.6-minimal amd64 3.6.5-5~16.04.york1 [574 kB]
Get:2 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 python3.6-minimal amd64 3.6.5-5~16.04.york1 [1,712 kB]
Get:3 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 libpython3.6-stdlib amd64 3.6.5-5~16.04.york1 [1,989 kB]
Get:4 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 python3.6 amd64 3.6.5-5~16.04.york1 [230 kB]
Fetched 4,505 kB in 4s (979 kB/s)
Selecting previously unselected package libpython3.6-minimal:amd64.
(Reading database ... 31944 files and directories currently installed.)
Preparing to unpack .../libpython3.6-minimal_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking libpython3.6-minimal:amd64 (3.6.5-5~16.04.york1) ...
Selecting previously unselected package python3.6-minimal.
Preparing to unpack .../python3.6-minimal_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking python3.6-minimal (3.6.5-5~16.04.york1) ...
Selecting previously unselected package libpython3.6-stdlib:amd64.
Preparing to unpack .../libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking libpython3.6-stdlib:amd64 (3.6.5-5~16.04.york1) ...
Selecting previously unselected package python3.6.
Preparing to unpack .../python3.6_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking python3.6 (3.6.5-5~16.04.york1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up libpython3.6-minimal:amd64 (3.6.5-5~16.04.york1) ...
Setting up python3.6-minimal (3.6.5-5~16.04.york1) ...
Setting up libpython3.6-stdlib:amd64 (3.6.5-5~16.04.york1) ...
Setting up python3.6 (3.6.5-5~16.04.york1) ...
raz#HOSTNAME:~/myPlayground$
Check your python versions:
raz#HOSTNAME:~/myPlayground$ python -V
Python 2.7.12
raz#HOSTNAME:~/myPlayground$ python3 -V
Python 3.5.2
raz#HOSTNAME:~/myPlayground$ python3.6 -V
Python 3.6.5
You can search your 'Start Menu' for 'Bash' and get the app that will open a command prompt from within Ubuntu Linux (not Unix).
AFAIK you cannot drag and drop into this from Explorer.exe but you may be able to run a Linux file app that can do this with X11 installed.
Finally, from Bash on Ubuntu command line app, you can run 'sudo apt-get install python3' to get latest for Ubuntu.

getting command not found when middleman is called

Hi I have installed ruby in my ubuntu 16.04 and successfully installed, and also installed middleman to check my project its worked properly, when I reconnect to middleman I got error middleman: command not found I am not getting what the mistake is. when I try to re initialise it, it asks to install ruby. please help someone to know the exact error.
urujada#gurujada-To-be-filled-by-O-E-M:~$ cd sunil
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ atom .
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ middleman
middleman: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ middleman
middleman: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ middleman init
middleman: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ cd Home
bash: cd: Home: No such file or directory
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ cd..
cd..: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/sunil$ cd ..
gurujada#gurujada-To-be-filled-by-O-E-M:~$ cd Home
bash: cd: Home: No such file or directory
gurujada#gurujada-To-be-filled-by-O-E-M:~$ mkdir example
gurujada#gurujada-To-be-filled-by-O-E-M:~$ cd example
gurujada#gurujada-To-be-filled-by-O-E-M:~/example$ middleman init
middleman: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/example$ cd ..
gurujada#gurujada-To-be-filled-by-O-E-M:~$ gem install middleman
The program 'gem' is currently not installed. You can install it by typing:
sudo apt install ruby
gurujada#gurujada-To-be-filled-by-O-E-M:~$ sudo apt install ruby
[sudo] password for gurujada:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
fonts-lato javascript-common libjs-jquery libruby2.3 rake ruby-did-you-mean
ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3
rubygems-integration
Suggested packages:
apache2 | lighttpd | httpd ri ruby-dev bundler
The following NEW packages will be installed:
fonts-lato javascript-common libjs-jquery libruby2.3 rake ruby
ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
ruby-test-unit ruby2.3 rubygems-integration
0 upgraded, 13 newly installed, 0 to remove and 11 not upgraded.
Need to get 6,042 kB of archives.
After this operation, 27.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 fonts-lato all 2.0-1 [2,693 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 javascript-common all 11 [6,066 B]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libjs-jquery all 1.11.3+dfsg-4 [161 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 rubygems-integration all 1.10 [4,966 B]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby-did-you-mean all 1.0.0-2 [8,390 B]
Get:6 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby-minitest all 5.8.4-2 [36.6 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby-net-telnet all 0.1.1-2 [12.6 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby-power-assert all 0.2.7-1 [7,668 B]
Get:9 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby-test-unit all 3.1.7-2 [60.3 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libruby2.3 amd64 2.3.1-2~16.04 [2,957 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 ruby2.3 amd64 2.3.1-2~16.04 [40.9 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ruby all 1:2.3.0+1 [5,530 B]
Get:13 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 rake all 10.5.0-2 [48.2 kB]
Fetched 6,042 kB in 25s (239 kB/s)
Selecting previously unselected package fonts-lato.
(Reading database ... 211722 files and directories currently installed.)
Preparing to unpack .../fonts-lato_2.0-1_all.deb ...
Unpacking fonts-lato (2.0-1) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../javascript-common_11_all.deb ...
Unpacking javascript-common (11) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../libjs-jquery_1.11.3+dfsg-4_all.deb ...
Unpacking libjs-jquery (1.11.3+dfsg-4) ...
Selecting previously unselected package rubygems-integration.
Preparing to unpack .../rubygems-integration_1.10_all.deb ...
Unpacking rubygems-integration (1.10) ...
Selecting previously unselected package ruby-did-you-mean.
Preparing to unpack .../ruby-did-you-mean_1.0.0-2_all.deb ...
Unpacking ruby-did-you-mean (1.0.0-2) ...
Selecting previously unselected package ruby-minitest.
Preparing to unpack .../ruby-minitest_5.8.4-2_all.deb ...
Unpacking ruby-minitest (5.8.4-2) ...
Selecting previously unselected package ruby-net-telnet.
Preparing to unpack .../ruby-net-telnet_0.1.1-2_all.deb ...
Unpacking ruby-net-telnet (0.1.1-2) ...
Selecting previously unselected package ruby-power-assert.
Preparing to unpack .../ruby-power-assert_0.2.7-1_all.deb ...
Unpacking ruby-power-assert (0.2.7-1) ...
Selecting previously unselected package ruby-test-unit.
Preparing to unpack .../ruby-test-unit_3.1.7-2_all.deb ...
Unpacking ruby-test-unit (3.1.7-2) ...
Selecting previously unselected package libruby2.3:amd64.
Preparing to unpack .../libruby2.3_2.3.1-2~16.04_amd64.deb ...
Unpacking libruby2.3:amd64 (2.3.1-2~16.04) ...
Selecting previously unselected package ruby2.3.
Preparing to unpack .../ruby2.3_2.3.1-2~16.04_amd64.deb ...
Unpacking ruby2.3 (2.3.1-2~16.04) ...
Selecting previously unselected package ruby.
Preparing to unpack .../ruby_1%3a2.3.0+1_all.deb ...
Unpacking ruby (1:2.3.0+1) ...
Selecting previously unselected package rake.
Preparing to unpack .../archives/rake_10.5.0-2_all.deb ...
Unpacking rake (10.5.0-2) ...
Processing triggers for fontconfig (2.11.94-0ubuntu1.1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up fonts-lato (2.0-1) ...
Setting up javascript-common (11) ...
Setting up libjs-jquery (1.11.3+dfsg-4) ...
Setting up rubygems-integration (1.10) ...
Setting up ruby-did-you-mean (1.0.0-2) ...
Setting up ruby-minitest (5.8.4-2) ...
Setting up ruby-net-telnet (0.1.1-2) ...
Setting up ruby-power-assert (0.2.7-1) ...
Setting up ruby-test-unit (3.1.7-2) ...
Setting up libruby2.3:amd64 (2.3.1-2~16.04) ...
Setting up ruby2.3 (2.3.1-2~16.04) ...
Setting up ruby (1:2.3.0+1) ...
Setting up rake (10.5.0-2) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
gurujada#gurujada-To-be-filled-by-O-E-M:~$ gem install middleman
Fetching: bundler-1.12.5.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
gurujada#gurujada-To-be-filled-by-O-E-M:~$ cd example
gurujada#gurujada-To-be-filled-by-O-E-M:~/example$ middleman init
middleman: command not found
gurujada#gurujada-To-be-filled-by-O-E-M:~/example$ cd ..
gurujada#gurujada-To-be-filled-by-O-E-M:~$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
gurujada#gurujada-To-be-filled-by-O-E-M:~$ whereis ruby
ruby: /usr/bin/ruby /usr/bin/ruby2.3 /usr/lib/ruby /usr/share/man/man1/ruby.1.gz
gurujada#gurujada-To-be-filled-by-O-E-M:~$
From your log:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
Middleman was not successfully installed because your user can't write to the directory it should be installed in.
You have two easy options:
run sudo gem install middleman
run sudo gem install bundler, and then in your project directory, create a Gemfile with the following content:
source "https://rubygems.org"
gem "middleman", "~> 4.1"
and run bundle install in the project directory.
You should really do option 2 so you can keep multiple version of gems installed.
You could also not use the system Ruby and install one yourself with RVM or rbenv, but that is a little more work.

Resources