Sequence of Angular Router Events

The Angular API documentation page on Router Events lists the events raised by the Angular router, and claims “the events occur in the following sequence”.

What is missing, however, is at what step the components are created and initialized. And it turns out, that the sequence of events is a bit more complicated if you look closer.

If you want to debug the events yourself, you’ll find that you can easily log is the way of

this.router.events.subscribe((event: Event) => {
console.log(event.type + ' ' + event.toString());
}

but if you want to stringify the whole event object, you will end up with a circular reference inside the Angular data structure, thus raising an Exception.

Continue reading

Fixed: Nextcloud Hub 3 (25.0.13) – Your version is up to date

I only rarely check the upgrade status of my Nextcloud installation, and last time I did, I got the information

Version
Nextcloud Hub 3 (25.0.13)
Update
Your version is up to date.

The information sound reassuring, but what worried me was that on Nextcloud’s Changelog page, the current version is shown as 28.0.0, and version 23 was already out of support.

What’s going on here?

Well, the release announcement for Hub 4 mentions that “This release supports the latest PHP 8.2”, but it does not indicate that it would no longer run on PHP 7, which is default for Ubuntu 20.04, or that you are strongly encouraged to upgrade your PHP version to be able to install current and future upgrades.

Checking while writing this post: System Requirements for V 25 are “PHP 7.4 (deprecated), PHP 8”, System Requirements for V 26 state “PHP 8.1”.

As posts on the Nextcloud forum show, I am not the only one to notice this problem.

My wishlist regarding the version check would certainly contain:

  • If the installed version is unsupported, deprecated, obsolete, out-of-use, then please say so.
  • If an upgrade can only be performed if a newer version of some underlying software needs to be installed (PHP 8 instead of PHP 7.4), then please say so.

Anyway, I proceeded with the Ubuntu upgrade:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo do-release-upgrade -c
Checking for a new Ubuntu release
New release '22.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
$ sudo do-release-upgrade

After the upgrade completed, I was on Ubuntu 22.04 and PHP 8.1:

However, the Nextcloud website could not be reached:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

I found that useful error messages can be found in the Apache error.log as configured in the website’s config file, and as result of the php occ command.

A couple of errors were to fix: First, disable the php7.4 module and enable the php8.1 module. (One would think that upgrading PHP through the Ubuntu upgrade would also re-wire the Apache modules accordingly)

$ sudo a2dismod php7.4
Module php7.4 disabled.
$ sudo a2enmod php8.1
Enabling module php8.1.
To activate the new configuration, you need to run:
systemctl restart apache2
$ sudo systemctl restart apache2

The PHP upgrade apparently also did not upgrade the previously installed modules, as php occ tells me:

$ sudo php occ
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/html/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()

Please dear computer let PHP connect to MariaDB:

$ sudo apt-get install php-mysqli
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Note, selecting 'php8.1-mysql' instead of 'php-mysqli'

Please dear Nextcloud, will you run?

$ sudo php occ
An unhandled exception has been thrown:
Error: Call to undefined function simplexml_load_string() in /var/www/html/nextcloud/lib/private/App/InfoParser.php:69

$ sudo apt-get install php-xml

Fixing database access and XML parsing, we reached the next level in the occ text adventure:

$ sudo -u www-data php occ
PHP module zip not installed.
Please ask your server administrator to install the module.
PHP module mbstring not installed.
Please ask your server administrator to install the module.
PHP module GD not installed.
Please ask your server administrator to install the module.
PHP module cURL not installed.
Please ask your server administrator to install the module.

Good!

$ sudo apt-get install php-zip php-mbstring php-gd php-curl

I still got an internal error in the web browser, but no errors in occ check. What could be the problem? Hmmm maybe restart Apache?

$ sudo /etc/init.d/apache2 restart

I had web access to my Nextcloud installation again, and could proceed to update to the most current version.

Getting Anki to run on Ubuntu 22.04

Whatever happened to Anki, which I had installed many major versions of Ubuntu ago, and which I only rarely use – it only started up with an empty screen today.

So I went to the Download Anki page, und downloaded the latest version (2.1.66), both for Qt5 and Qt6 to find a way to make it run again. Advantage: you can then start Anki with a simple ‘./anki‘ from the terminal without installing it.

I followed all the “you might be missing this” instructions for missing libraries, but still no luck with displaying anything but an empty start window (either grey or black, depending on the Qt version).

After going through the AnkiWeb forums, I found two hints that finally produced a functioning Anki window in Qt5:

$ QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" DISABLE_QT5_COMPAT=1 ./anki

After repeatedly verifying the successful application launch, I installed this Qt5 version using ‘./install.sh‘, and used the Menu Editor to set the parameters.

Which of course would not work the way I intended.

So the parameters had to go to a shell script which I created using

$ echo QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" DISABLE_QT5_COMPAT=1 anki > start-anki.sh

and used Menu Editor again to replace the original Command with

/home/Me/Tasks/start-anki.sh

Everything’s good now 🙂

Fixed: Evolution no longer asks “Do you want to recover unfinished messages?”

This bug was really annoying: You type an email in Evolution mailer and send it successfully, and the next time you start up Evolution again, you get that dialog

Do you want to recover unfinished messages?

and you are not sure whether you sent everything you wanted to send, and dare not press the Discard button, and end up with all the emails written since the last time you started the mailer.

Well, it happened again today, and I was more successful in tracking the bug down, and found 2 bug reports on Launchpad

1978260 Evolution not closing emails after sending

1983794 Evolution not deleting autosave files

and a Gitlab Evolution issue 1972.

Fortunately, the bug has been fixed in the meantime, and under Ubuntu 22.04.1 the issue can be fixed by installing the latest version of libcanberra:

$ sudo apt install libcanberra-gtk3-module

which updates the previously installed version

Get:1 http://at.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcanberra-gtk3-module amd64 0.30-10ubuntu1.22.04.1 [11,2 kB]
Fetched 11,2 kB in 0s (59,5 kB/s)
(Reading database … 515766 files and directories currently installed.)
Preparing to unpack …/libcanberra-gtk3-module_0.30-10ubuntu1.22.04.1_amd64.deb
…
Unpacking libcanberra-gtk3-module:amd64 (0.30-10ubuntu1.22.04.1) over (0.30-10ubuntu1) …
Setting up libcanberra-gtk3-module:amd64 (0.30-10ubuntu1.22.04.1) …

Editing the Gnome Applications menu

I have a couple of shell scripts that I run regularly, and currently they reside in a ~/Tasks directory. This means there is always an open window (Terminal or Files) so that I can invoke them easily (after finding this window).

I had this idea that somehow it should be possible to add a Tasks folders to the Applications menu, and call the script from menu items inside Applications, allowing for faster access.

So now I found this answer on AskUbuntu refering to a utility called menulibre, so I quickly installed it using

sudo apt install menulibre

and started it and indeed. it allowed me to add a Tasks folder (called “Directory” in menulibre) and various menu items (called “Launchers”, what would be “shortcuts” in windows) inside it.

Since these are file-based operations, you need to save every single item after editing it – apparently there is no “Save All” mechanism.

Under the hood, the application creates a menulibre-[name].directory file in ~/.local/share/desktop-directories for each directory, and menulibre-[name].desktop files for each item in ~/.gnome/apps and ~./local/share/applications.

The homepage of menulibre is here, and its repository can be found on GitHub.

Storing PostgreSQL databases on mounted volumes

I am not sure whether you can confirm a data directory for PostgreSQL during Ubuntu installation, but anyway, I ended up with the data directory located in the default location.

For some database experiments that I expect to be quite harddisk-consuming, I want to PostgreSQL to store this database on a different volume.

Following the comments on this question on SO and this answer on DBA, I first created a directory for PostgreSQL:

Continue reading

Running TypeScript scripts on Angular code

I needed to check my Angular application for data consistency. Those checks included completeness of internally referenced data, as well as the existence of files referenced by file name in that data.

Since Angular is TypeScript, it would be nice to use TypeScript for those checks, as I can directly reference all types and data declared in the application code using the import mechanism.

(I had previously used gulp for such tasks, but used JavaScript at that time. Apparently, there also exists a way to integrate gulp with TypeScript)

To run a TypeScript from the command line, I installed ts-node as a dev dependency in my Angular application:

npm i -D ts-node

However, running the script using

npx ts-node path-to-script.ts

would raise the error message

(node:1060467) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)

Fortunately, this issue was quite easy to resolve thanks to this SO comment, as I only needed to edit tsconfig.json to add the following configuration to the JSON root:

"ts-node": {
  "compilerOptions": {
    "module": "commonjs"
  }
}

Fixing “simple-scan crashed with SIGSEGV”

I have an HP Envy 5030, and printing from Ubuntu (22.04, but also earlier versions) works fine, both via Windows Shared Printer and directly via USB.

Scanning, however, has always been a problem, as Ubuntu’s Document Scanner always crashed with the message

simple-scan crashed with SIGSEGV in _IO_new_fclose()

Scanning from the HP Device Manager also starts Document Scanner, so that’s option, and running hp-uiscan can’t find the scanner (“No device connected”).

Search through online forums, I found mention of XSane, and searching for XSane I found the Ubuntu page on XSane, stating

XSane can also be used from within The GIMP; just click

File > Acquire > XSane

to scan directly into an image.

Let’s give it a try.

According to the Man page of the Sane project, xscanimage will be used as a plug-in for Gimp.

$ xsane
Command 'xsane' not found, but can be installed with:
sudo apt install xsane
$ xscanimage
Command 'xscanimage' not found, but can be installed with:
sudo apt install sane

Installing…

$ sudo apt install xsane
$ sudo apt install sane

and linking the plug-in…

$ ln -s /usr/bin/xscanimage ~/.gimp-2.8/plug-ins/

I find various scanning options in the Gimp’s Plug-In Browser:

From Gimp’s menu, you can now find those connections under File > Create > xscanimage >

I finally managed to scan 1 image, but unfortunately, subsequent scans failed with the dialog message

Failed to open device `….’: Error during device I/O.

Printing still worked, though. Still, the issue bugged me.

I found various mentions of airscan-discover, but couldn’t figure out what it would do, so I ran the tool

$ airscan-discover
[devices]
  HP ENVY 5000 series [FD1005] (USB) = http://127.0.0.1:60000/eSCL/, eSCL

and added the line in the [devices] section of airscan.conf, as described here.

$ sudo nano /etc/sane.d/airscan.conf

Then I started

$ simple-scan "airscan:e0:ENVY 5000"

and it scanned!

And then I started Gimp and selected File > Create > xscanimage > airdrop:... and it scanned!

Ubuntu Jammy casualties: dotnet

Before I upgraded to Ubuntu 22.04 (Jammy), I had dotnet 5 and 6 installed, rather out of interest, than doing any serious programming.

As far as I can remember, I originally had installed the Snap version of dotnet, but had troubles installing any dotnet packages or templates, so I had switched to the “native” version of dotnet, probably using the dotnet-install.sh variant – I’m not sure.

Upgrading to 22.04 seems to have uninstalled dotnet 5, as it is out of support, and weird things happened to the dotnet 6 installation:

Running

dotnet new -i Avalonia.Templates

did not install the expected templates, but rather immediately returned the error message

The application ‘new’ does not exist

Further, the command dotnet --info listed two 6.0 runtimes, but did not know of any previously installed SDKs.

After uninstalling and re-installing and uninstalling the dotnet6 package, the command dotnet was still there, but did not do anything useful.

$ dotnet --list-sdks
A fatal error occurred. The folder [/usr/lib/dotnet/dotnet6-6.0.108/host/fxr] does not exist

This error message got me to dotnet/core Issue 5746 (dealing with .Net Core 3 on CentOS though), where a comment states

This can happen if dotnet-host and dotnet-hostfxr-3.1 are conflicting,

So I queried apt for the list of installed dotnet packages

$ apt list | grep dotnet

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

dotnet-apphost-pack-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-apphost-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-host/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 [upgradable from: 6.0.108-0ubuntu1~22.04.1]
dotnet-hostfxr-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-hostfxr-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-runtime-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-runtime-deps-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-sdk-6.0-source-built-artifacts/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-sdk-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-targeting-pack-5.0/now 5.0.0-1 amd64 [installed,local]
dotnet-targeting-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-templates-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet6/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
libgtk-dotnet3.0-cil-dev/jammy 2.99.3-4build1 amd64
libgtk-dotnet3.0-cil/jammy 2.99.3-4build1 amd64

So I manually uninstalled all remaining dotnet packages

$ sudo apt-get remove dotnet-hostfxr-5.0
$ sudo apt autoremove

until the dotnet command was no longer recognized. From this clean state, I ran

$ sudo apt install dotnet6

and got a brand-new dotnet 6 environment and even a new application.

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.109
 Commit:    58a93139d8

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/dotnet6-6.0.109/sdk/6.0.109/

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: x64
  Commit:       163a63591c

.NET SDKs installed:
  6.0.109 [/usr/lib/dotnet/dotnet6-6.0.109/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.NETCore.App]