Command-not-found, multiple versions, and confusion


#1

There is a tool, ripgrep, with binary name rg.

$ rg

Command 'rg' not found, but can be installed with:

sudo snap install rg       # version 0.8.1, or
sudo snap install ripgrep  # version 0.10.0

See 'snap info <snapname>' for additional versions.

Obviously I would want the newest version, so:

$ snap install ripgrep --classic # we need --classic, apparently, don't know why
ripgrep 0.10.0 from Chris MacNaughton (icey) installed
$ rg --help
Command 'rg' not found, but can be installed with:
sudo snap install rg       # version 0.8.1, or
sudo snap install ripgrep  # version 0.10.0
See 'snap info <snapname>' for additional versions.
08:59 ~ $ ripgrep --help
Command 'ripgrep' not found, did you mean:
  command 'zipgrep' from deb unzip
  command 'sipgrep' from deb sipgrep
Try: sudo apt install <deb name>
08:59 ~ $ snap run ripgrep
error: cannot find app "ripgrep" in "ripgrep"
$ snap run rg
error: cannot find current revision for snap rg: readlink /snap/rg/current: no such file or directory
$ ripgrep.rg
The following required arguments were not provided:
...

So, this is, in my opinion, a fairly terrible experience, so I thought I’d give some feedback about that in the hope that someone can think about it. None of the individual parts here are wrong, but they’re all fitting together in a way that makes the whole experience confusing and unpleasant and less credible, which is a problem.

Command-not-found recommends installing the ripgrep snap to get the rg command, but then doesn’t give me the rg command. (This seems to have been asked about already and then decided not to.) And there are multiple versions of ripgrep in the store, at different versions, and the one with the “canonical” binary name isn’t the most recent version. I was pretty baffled by all this, and I’m more knowledgeable than most users about snaps; I don’t think most people would have known to run it as ripgrep.rg, for example. So the experience here is: I try to run a command, command-not-found tells me to install something to get it, I install that thing, and I still don’t have that command. I don’t know whether this is a bug in command-not-found (don’t recommend things that don’t actually provide the command I typed), the snap ecosystem overall (there are multiple things which all provide the same command), or what. But it’s not a pleasant experience. As I say, nobody is individually doing anything wrong here, but the combined effect of all this is confusing and will likely make people less confident in snaps overall.


#2

As we can see from the snap-declaration - the alias that has been configured expects the ripgrep snap to provide a ripgrep binary, which it doesn’t.

This meta information is what’s used to populate the store’s idea of which commands are in which snap, and I believe it to be correct, albeit a contract that the publisher has broken by not producing a snap which fits the shape that the alias expects.

To work around this on your own system, you can run $ snap alias ripgrep.rg rg

The publisher of the snap is @icey - perhaps he can upload a new version?


#3

This seems like something that could (and should) be caught at build time, no?


#4

ripgrep (the snap) has never shipped a binary with the name ripgrep, so I’m not sure why the alias was created that way? I’m happy to publish a new version of the snap (should anyways, as I haven’t in a while) but it seems weird that the name is mixed up like this.


#5

I think because in the original request you didn’t specify, and we didn’t think to ask.

@jdstrand can we fix it?


#7

I failed to look at the link correctly, had a different one from this post in the next tab


#8

I have fixed the alias.

@icey no need to change the snap if you want to keep the command in there as rg, existing users will get the new alias automatically connected on a background refresh, or snap refresh ripgrep if you’re impatient


#9

I did just upgrade the snap (it was a bit old), thanks for updating the alias @sparkiegeek!