How do I run this: "/usr/share/qutebrowser/scripts/dictcli.py install en-US"

I am trying to install the dictionary for qutebrowser, and the instructions say to do this:

$ /usr/share/qutebrowser/scripts/dictcli.py install en-US

What is the NixOS way to do this? I have 4 different paths to dictcli.py that look like this:

/nix/store/hash-qutebrowser-2.5.2/share/qutebrowser/scripts/dictcli.py

Do I just run dictcli.py in the most recent install of qutebrowser? How do I know which is the momst recent install of qutebrowser?

I imagine you aren’t looking for the most recent, but for the one on your PATH (or in whatever profile/environment is relevant)?

Yes, you are correct, I’m not necessarily looking for the most recent.

But how do I determine which of those store paths is the one currently being used (note that they are not on the PATH)?

Or am I going about this wrong? How else should I execute dictcli.py?

I am not specifically familiar w/ qutebrowser, but if one is on your PATH as reported by type or which, I’d start with that one.

Right. I said that dictcli.py was not on the path. I understand that NixOS, through a bunch of symlinks, puts the appropriate store items on the path, but the .py script I want to run is bundled with qutebrowser and is not on the path. It would normally live in /usr/share, but we don’t have that path. So how do I find it and run it?

Not the script on the path; the one that’s in the same output as the qutebrowser on path (assuming one is).

$ which qutebrowser
/nix/store/kbxmdyyl02p1jf3riv1dv838pdnj05lg-qutebrowser-2.5.2/bin/qutebrowser

$ cd /nix/store/kbxmdyyl02p1jf3riv1dv838pdnj05lg-qutebrowser-2.5.2/share/qutebrowser/scripts/

$ ./dictcli.py

1 Like

Thanks! I am learning bits everyday!

I am using home-manager (I assume you are not), so I get this instead:

$ which qutebrowser
/home/username/.nix-profile/bin/qutebrowser

but I was able to do this:

$ cd /home/username/.nix-profile/share/qutebrowser/scripts/
$ ./dictcli.py install en-CA

however, I get errors:

$ ./dictcli.py install en-CA
Traceback (most recent call last):
  File "/nix/store/2765jng4mw8x19i67f5hfqwc9vl207q4-qutebrowser-2.5.2/share/qutebrowser/scripts/./dictcli.py", line 269, in <module>
    main()
  File "/nix/store/2765jng4mw8x19i67f5hfqwc9vl207q4-qutebrowser-2.5.2/share/qutebrowser/scripts/./dictcli.py", line 252, in main
    languages = available_languages()
  File "/nix/store/2765jng4mw8x19i67f5hfqwc9vl207q4-qutebrowser-2.5.2/share/qutebrowser/scripts/./dictcli.py", line 166, in available_languages
    api_list = language_list_from_api()
  File "/nix/store/2765jng4mw8x19i67f5hfqwc9vl207q4-qutebrowser-2.5.2/share/qutebrowser/scripts/./dictcli.py", line 146, in language_list_from_api
    with urllib.request.urlopen(listurl) as response:
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

Any idea how to resolve this?

I am using home-manager (I assume you are not), so I get this instead:

I do use HM, but not qutebrowser, so I just did nix-shell -p qutebrowser to try it out.

urllib.error.HTTPError: HTTP Error 404: Not Found

Looking for a resource that cannot be found. I suggest having a look at dictcli.py to see what is going on.

1 Like

I found this entry in the NixOS wiki:
https://nixos.wiki/wiki/Qutebrowser
which is quite useful and answers some of the question I had above.
But, following its suggestions, I get the same errors as above. Does anyone have a solution? Has anyone successfully installed a dictionary for qutebrowser?

The script is trying to load the JSON output of this page: / - chromium/deps/hunspell_dictionaries.git - Git at Google, which seems to be broken on Google’s end.

It’s because of renaming branch from master to main.
Page on NixOS wiki with example running it has previous branch name .
Qutebrowser version in nixpkgs (v2.5.2) should have a fix for that:

New URL used:
https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/main/

1 Like

Interesting, but I am running qutebrowser v2.5.2 and am still getting that error.

I meant that as a reply to which seems to be broken on Google’s end.
If your current dictcli.py has:
API_URL = 'https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/main/'
Then most likely that is not the problem, as both urls that (from a quick look) script is using seem to work:
curl 'https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/main/?format=JSON' |less
curl 'https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git/+/main/en-US-10-1.bdic?format=TEXT' |less

1 Like

The dictcli.py in v2.5.2 in nixpkgs still refers to master and not main.

Looked through src for qutebrowser again and I misread date on v2.5.2 release, it was in Jun 22, 2022.
So only v2.5.3 has that fix and qutebrowser in nixpkgs is on v2.5.2

There’s a current PR for updating to v2.5.3:

1 Like

thank u for making me aware of qutebrowser… I use to love uzbl before it was dropped from lack of maintenance.

I couldn’t imagine not using qutebrowser. For me, it checks every box. I love it.

1 Like

I notice that qutebrowser is now available on unstable. I am using stable qutebrowser by specifying it through home manager:

programs.qutebrowser.enable = true;

Is there a way to get homemanager to use the unstable version of qutebrowser? Using programs.qutebrowser.package perhaps?