nRF Command Line Tools fails to install on new Ubuntu 20.04 system

Trying to get the entire set of v2.0.0 software development tools to install on our Ubuntu 20.04.4 LTS x86_64 system for my nRF9160-DK.

Following the [DevAcademy nRF Connect SDK Fundamentals course](https://academy.nordicsemi.com/topic/exercise-1-1/), the very first task in the very first exercise instructs to install the [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools).  The illustration in the course only demonstrates how to click the icon in Windows but not for Ubuntu.  This failed for me when installing the Ubuntu .deb package:

```

$ sudo apt install ./Downloads/nrf-command-line-tools_10.17.0_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'nrf-command-line-tools' instead of './Downloads/nrf-command-line-tools_10.17.0_amd64.deb'
nrf-command-line-tools is already the newest version (10.17.0).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up nrf-command-line-tools (10.17.0) ...
dpkg: error: dpkg database lock is locked by another process
dpkg: error processing package nrf-command-line-tools (--configure):
installed nrf-command-line-tools package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
nrf-command-line-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
$

```

Tried also clicking the .deb file in the graphical file manager with similar result.

I noticed the error mentions the post-installation script, but does not specify the line it failed on.  The `postinst` file contained within the .deb archive is as follows:

```

#!/usr/bin/env bash

echo /opt/nrf-command-line-tools/lib > /etc/ld.so.conf.d/nrftools.conf
echo /opt/nrf-command-line-tools/bin >> /etc/ld.so.conf.d/nrftools.conf

echo /opt/nrf-command-line-tools/lib > /etc/ld.so.conf.d/nrfjprog.conf
echo /opt/nrf-command-line-tools/bin >> /etc/ld.so.conf.d/nrfjprog.conf

ln -sf "/opt/nrf-command-line-tools/bin/nrfjprog" "/usr/local/bin"
ln -sf "/opt/nrf-command-line-tools/bin/mergehex" "/usr/local/bin"

if command -v rpm &> /dev/null
then
rpm --upgrade /opt/nrf-command-line-tools/share/segger/*.rpm
exit
fi
if command -v dpkg &> /dev/null
then
dpkg --install /opt/nrf-command-line-tools/share/segger/*.deb
exit
fi
fi

if command -v rpm &> /dev/null
then
rpm --upgrade /opt/nrf-command-line-tools/share/segger/*.rpm
exit
fi
if command -v dpkg &> /dev/null
then
dpkg --install /opt/nrf-command-line-tools/share/segger/*.deb
exit
fi

```

with a suspicious extra `fi` statement.  Moreover, I could not see a `segger` directory:

```

$ ls -l /opt/nrf-command-line-tools/share/
total 24
-rw-r--r-- 1 root root 5370 Jul 22 16:46 config.toml
drwxr-xr-x 2 root root 4096 Aug 2 16:39 firmware
drwxr-xr-x 2 root root 4096 Aug 2 16:39 NRFCommandLineTools
-rw-r--r-- 1 root root 753 Jul 21 10:03 nrfjprog.ini
-rw-r--r-- 1 root root 3052 Jul 21 10:03 QspiDefault.ini
$

```

So my guess is either the Ubuntu .deb package is simply broken, incomplete, the guide is missing a step or it's failing on the extra `fi` statement.

Not sure though.  Any help to get past this stage would be appreciated.

  • I am getting the exact same issue currently, with the same error message, running Ubuntu 22.04. Thanks for posting  ! That included using the different command `sudo dpkg -i nrf-command-line-tools_10.17.0_amd64.deb` .

    note: if you need help fixing the lock on the dpkg, I've been running `sudo apt-get remove --purge nrf-command-line-tools`. Unsure if this is the best way to do it, but it at least allows me to run dpkg again (if you run into this issue, which I did)

  • Thanks elidonner.  Yes, apt removing did stop it from nagging me about the postinst script.  I went with 20.04 because I ran into a separate issue a few weeks back with installing the toolchain in 22.04.  I did actually get further last time but had to be done manually - I can't remember exactly how it led up but I found myself needing to install [Kitware](https://apt.kitware.com/) as required by the official manual install instructions, and found that Kitware's repository only supports up to Ubuntu 20.04.  Bit obscure, but might be useful to know if you run into that one later.

  • Hello,

    This one seems to be an issue introduced with the new release of command line tool 10.17.0.. Our developers are working on a fix for this issue and would be fixed in a 10.17.2 update which should be available in the next few days. I was informed that you could just ignore the error and it would not pose any problems..

    Best Regards,

    Swathy

  • Same on a debian Bullseye. After extracting the archive (dpkg-deg --raw-extract), deleting the lines after the second "ln -sf" and rebuilding the package (dpkg-deb --build), the package installs. My problem now is in VSCode not finding nrfjprog (which is however under /usr/local/bin) and complaining about shell initialization failure.

    I'll wait 10.17.2 update

  • Thanks all, I ignored the error and continued as SwRa recommended, however have now also run into a problem with VSCode unlike that of V.Besse; instead mine is complaining about shell initialization conflicting with the nRF Connect Terminal profile which is not solved by its recommended troubleshooting page.  I haven't yet ran into any sign of missing `nrfjprog` yet - I can see it in my `/usr/local/bin/nrfjprog` but still early days for VSCode.  So we did get past this by ignoring the original error installing the command line tools so I'll call this issue done for now.  I think I'll try the same trick, ignoring the VSCode error and see if I can just get blinky to run.

    I wonder how much of the VSCode errors we're seeing have something to do with the command line tool post-install error.

    Bottom line: 10.17.0 contains a deb package post-install script error that can be ignored.  The command line tools seem to install but we can't say for sure that any problems that come after are caused by it.

Related