Command-not-found in Debian

pic of fortune cookie

I wrote this up years ago, but with the demise of CrunchBang those bits are rotting away. The URL is still good, but my post is mostly gone. I just installed Debian Stretch on my Mom’s old MacBook and the issue is still there, so here it is again.

If you invoke a command that doesn’t exist, most shells will simply tell you so.

$ play
play: command not found

Ubuntu has a utility called command-not-found. If you invoke a command that is not installed, but is available, it will tell you how to install it.

$ play
The program 'play' is currently not installed. You can install it by typing:
sudo apt install play


This command is now available in other Debian systems too, including the latest stable: stretch.

sudo apt install command-not-found
sudo apt update
sudo update-command-not-found

But it doesn’t quite work right, as is.

$ play
The program 'play' is currently not installed. To run 'play'
please ask your administrator to install package 'play'

But I am the administrator! Why doesn’t it think so? It seems that Ubuntu uses different groups than Debian. In particular, command-not-found is looking for membership in group “admin”, but Debian doesn’t use that. We want it to check for membership in group “sudo” instead. We can fix that!

sudoedit /usr/share/command-not-found/CommandNotFound/
# change "admin" to "sudo" on line 93

Most programs transition from Debian to Ubuntu. This one transitioned the other way. I guess the trip isn’t as smooth, since this was years ago and it’s still not fixed (indeed, it’s still line 93). I think this affects at least Debian wheezy, jessie, and stretch. It looks like it’s fixed on github and in Ubuntu (checks for either “admin” or “sudo”), but has not been backported to Debian yet.

Command-not-found in Debian

Free Pascal on Hanselminutes!

Hey, they mentioned Free Pascal on Hanselminutes! Part of a fascinating interview with Ariya Hidayat, the author of PhantomJS among other things.

I used Pascal in my CS-101 class, some thirty-mumble years ago. I’ve often said, I think it’s a really good language for that. For practical reasons, it lost out to C in industry. But for teaching, I think it’s perfect. CS-101 classes eventually replaced Pascal with C++. I think that was a mistake. Not because I think C++ is a bad language, but because I think it’s not as good for the things we want to teach in CS-101. Later, CS-101 classes replaced C++ with Java. I think that was an even bigger mistake. If you took CS-101 in Java, you probably have to go back and learn all sorts of things. In any case, I think it’s misguided to try to use the trendiest language in industry to teach CS-101. We’re not training people to be software engineers, we’re teaching them computer science. It’s the concepts, not the particulars. It’s not important that it be done in the language that currently has a lot of job openings. If we do it right, students will have no trouble switching to another language.

Anyway, on my Xubuntu machine, installing Free Pascal was just a matter of

sudo apt install fp-compiler

And away we go! Here’s “hello world”…

program Hello;
  writeln ('Hello, World!')

We can compile it…

pc hello.p

…and run it

$ ./hello
Hello, World!

As I said, I think Pascal is still perfect for teaching, but I don’t think about it for writing GUIs and such. It was nice to hear that Free Pascal has a few tricks up its sleeve!

Free Pascal on Hanselminutes!