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


$ 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
  HP ENVY 5000 series [FD1005] (USB) =, 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 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:


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

  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]

File Organizers: Calibre

A long time ago, I had a look at Calibre to organize my e-books, but chose not to use it mainly because of one issue: Calibre uses its own directory structure to organize its e-books (library/author/title (id)), and also renames the files accordingly (truncated title - author.extension).

How should I ever find a book again, I thought, if the tool ignores my structure of sorting files? After all, I already created some kind of order on my file system, so that I should know where my books are.

Well, in the course of cleaning up a soon-to-be shut-down machine, I noticed that my e-book collection instead was really a huge mess, spread over several machines, discs, and directories, full of duplicates and copies – recognizable by file name or file size.

So, let’s throw it all on Calibre.

The nice thing about Calibre is that it stores its metadata not in the e-books, but in a local SQLite database and a metadata.opf OPF file for every book.

Also, using tags to organize books is more flexible and powerful as compared to the tree-like directory hierarchy of traditional file systems.

Still, I wanted to keep the original filename of any catalogued e-book, so I added the GetFileName plugin which automatically adds the original filename in a separate user-defined column.

To keep track of all the books I always wanted to read, and those I have already read, I installed the Reading List plugin.

Since Calibre warns you if you want to import a book already imported, and I always ignore those warnings, a lot of duplicates are going to end up in my e-book library. That’s where the Find Duplicates plugin is going to be helpful in the future.

Until then, a generic [todo] tag adorns all my Calibre books until the metadata is cleaned up.

Though still early in my book-cataloguing adventure, I already stumble across problems I still need to figure out.

  • How do you handle different spellings of an author’s name (plain name, with middle initial, with middle name) or pseudonyms?
  • How do you import HTML books spread over several pages?
  • How do you handle e-books split into chapter-wise PDFs?

Not all updates can be installed

If you run Ubuntu, you’ll notice that every now and then the Software Updater will provide you with a notification

Updated software is available for this computer. Do you want to install it now?

Except, when it does not, and instead displays a dialog

Software Updater: Not all updates can be installed

with a set of rather unintuitive buttons.

What is most disturbing is the list of possible causes, when it’s just a piece of software that checked all kinds of error conditions and should know what went wrong, and should be able to detail the error condition that prevents it from resuming its task, rather than the lazy “An error occurred”.

So I started to track the message down, and found:

  • Software Updater is a Python/GTK application residing in /usr/bin/update-manager
  • The application imports code from the UpdateManager package under /usr/lib/python3/dist-packages/UpdateManager
  • There, the MyCache class in Core/ checks for various error conditions, and presents above dialog if something went wrong

It should be easy to adapt the code to display those error conditions. After a bit of trial and error, my version of the MyCache class displayed what kept the Software Updater from updating:

$ ./
would delete nodejs-doc
that's all

After removing the listed package

$ sudo apt-get remove nodejs-doc

Software Updater displayed its usual window of updatable software components.

The script is available in my Python repository.

Fixing Error NU1202: Package Microsoft.EntityFrameworkCore.Tools 6.0.1 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2)

Migrating an AspNetCore web and database application from version 2.2 to current .Net 6, I came across an occasional build error:

error NU1202: Package Microsoft.EntityFrameworkCore.Tools 6.0.1 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Microsoft.EntityFrameworkCore.Tools 6.0.1 supports: net6.0 (.NETCoreApp,Version=v6.0) 

The error went away by unchecking the Option “Allow NuGet to download missing packages” under “Nuget Package Manager”, so I did not bother any longer.

Unfortunately, the error returned as soon as I ran an Azure Build Task on the project. The task failed with a simple message

##[error]Packages failed to restore

without any indication what exactly failed, what was to be restored, and, especially, why.

Going through the log file, I found that nuget tried to restore packages for .Net 6 (good), but also für .NetCore 2.2 (bad):

2022-04-06T13:59:20.3799748Z          Restoring packages for .NETCoreApp,Version=v6.0...
2022-04-06T13:59:20.4022386Z          Resolving conflicts for .NETCoreApp,Version=v2.2...
2022-04-06T13:59:20.4605261Z          Resolving conflicts for net6.0-windows7.0...
2022-04-06T13:59:20.5840720Z          Checking compatibility of packages on .NETCoreApp,Version=v2.2.
2022-04-06T13:59:20.5886337Z          Checking compatibility for[6.0.1, ) 1.0.0 with .NETCoreApp,Version=v2.2.
2022-04-06T13:59:20.6014642Z          Checking compatibility for Microsoft.EntityFrameworkCore.Tools 6.0.1 with .NETCoreApp,Version=v2.2.
2022-04-06T13:59:20.6016218Z      1>D:\DevOpsAgents\some\path\Project.Data.csproj : error NU1202: Package Microsoft.EntityFrameworkCore.Tools 6.0.1 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Microsoft.EntityFrameworkCore.Tools 6.0.1 supports: net6.0 (.NETCoreApp,Version=v6.0) 

I also noticed that the first lines of the log stated

Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
[command]"C:\Program Files\dotnet\dotnet.exe" restore D:\DevOpsAgents\some\path\Project.sln

By that time, I had verified multiple times that the projects do not use any obsolete 2.2 packages anymore. Where does the reference come from?

Then I remembered that I had experienced *some *sort of build errors, as stated above, and tried to run a dotnet restore on my development machine, disabling parallel execution and turning verbosity to full diagnostics:

dotnet restore my.project.sln --disable-parallel -v diag > dotnet-restore.log

The output is huuuge, so I piped it to a file.

Searching the generated log file for netcoreapp2.2, I finally located these lines

17:37:29.274 10:4>_GenerateDotnetCliToolReferenceSpecs: (Target-ID:26)
    TaskParameter:ToolFramework=netcoreapp2.2 (Task-ID: 17)

I found the target _GenerateDotnetCliToolReferenceSpecs in the file C:\Program Files\dotnet\sdk\6.0.101\NuGet.targets, and it sets the DotnetCliToolTargetFramework build variable to a default value if it is not set already. The default value may be, depending on your installation, netcoreapp1.0, netcoreapp2.2, or some other version.

Which part of the project would trigger an action referring to dotnet CLI tools? It’s the EF Core Tools I needed to install for database migrations:

	  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.1"></DotNetCliToolReference>

This project setting causes dotnet to install the referenced tool, but fails to do so because the default tool framework is incompatible.

This observed behavior is documented in this GitHub issue for NuGet:

  • The DotnetCliToolTargetFramework will be interpreted by NuGet restore as the maximum target framework that tools can be restored for
  • When restoring .NET CLI tools, NuGet will first download the package, and inspect it to see what it targets. It will choose the maximum target framework the package explicitly supports that is less than or equal to the DotnetCliToolTargetFramework

This GitHub issue showed me how to set the framework version, so I added to my csproj file the following lines:


and dotnet restore worked without errors.

Disabling Loopback for Logitech G432 on Ubuntu

My old Logitech headset died a number of deaths (headband broken, cushion torn, finally cable broken), so I got myself a G432.

Unfortunately, using it in Teams under Ubuntu, I experienced an irritating loopback. Quickly took to the internets, but AskUbuntu was only of limited help.

For example, one answer suggested to use alsamixer, but that only completely muted the headset, not only the microphone loopback.

Another answer pointed me to a tool called HeadsetControl which allows exactly the control I wanted, and its Readme file even lists the model I have. Hurray.

I followed the instructions to install:

sudo apt-get install build-essential git cmake libhidapi-dev
git clone && cd HeadsetControl
mkdir build && cd build
cmake ..
sudo make install

After installation, I ran

$ headsetcontrol -?
Found Logitech G432/G433!
Supported capabilities:

* sidetone

And tried to set “sidetone” to zero:

headsetcontrol -s 0
Found Logitech G432/G433!
Failed to open requested device.
HID Error: (null)

Apparently, headsetcontrol requires sudo:

sudo headsetcontrol -s 0
Found Logitech G432/G433!

No more loopback!

Wordle cheat script

An article on The Register linked to a GitHub shell script version of Wordle, and what caught my eye was that apparently a Linux installation contains a dictionary of English words in the file /usr/share/dict/words.

If you are stuck in your daily Wordle, you can use this file to figure out solutions:

grep -E '^([a-zA-Z]){5}$' /usr/share/dict/wordscollect all 5-letter words
tr '[a-z]' '[A-Z]'convert words to upper case
grep 'RU...'filter words for matching (green) letters
grep '[E]'filter words for letters in the wrong spot (yellow)
grep -v '[ASD]'exclude known wrong letters (dark grey)

Combine the commands (the last 3 are optional) with the respective letters filled in, separated by the pipe “|”:

$ grep -E '^([a-zA-Z]){5}$' /usr/share/dict/words | tr '[a-z]' '[A-Z]' | grep 'RU.E.' | grep -v '[TASDLMN]'

Angular Google Maps Demo

The Angular Components documentation on its Google Maps component does not contain a working demo. Probably that’s because it would need to incorporate a YOUR_API_KEY value…

So I took the sample code from their and files and stitched together a working (uhm api key) sample on StackBlitz.

I noticed that while my code works find on my local machine, the StackBlitz version will raise an error in the console

Error in src/app/google-maps-demo/google-maps-demo.component.ts (14:11)
Cannot find namespace ‘google’.

This error is caused by the fact that the namespace google.maps is only created if the Google Maps API is loaded successfully.

Which brings me to error handling:

Essentially there are 3 cases that need to be dealt with:

  • Success
  • Invalid API key
  • Invalid URL for the Google Maps API call

In case of an invalid API key, the <google-map> component raises the authFailure event

In case of an invalid URL, there is no script to initialize the google namespace, and you can check whether the objects window["google"] and window["google"]["maps"] exist.

The code is also available as a GitHub repository.