Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate autocompletion database for awscli2 #101861

wants to merge 1 commit into from


Copy link

@jdelStrother jdelStrother commented Oct 27, 2020

Motivation for this change

Installing awscli2 and trying to use tab-completion fails and prints an error:

  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/bin/.aws_completer-wrapped", line 37, in <module>
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/bin/.aws_completer-wrapped", line 29, in main
    autocomplete(command_line, command_index)
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/", line 61, in autocomplete
    results = completer.autocomplete(command_line, position)
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/", line 42, in autocomplete
    parsed = self._parser.parse(command_line, index)
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/", line 145, in parse
    global_args = self._index.arg_names(lineage=[], command_name='aws')
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/local/", line 104, in arg_names
    results = db.execute(self._ARG_NAME_QUERY,
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/", line 33, in execute
    return self._connection.execute(query, kwargs)
  File "/nix/store/dyvz5p30dl0jv2g6wlb7i0l0pnsa9hpy-awscli2-2.0.54/lib/python3.8/site-packages/awscli/autocomplete/", line 23, in _connection
    self._db_conn = sqlite3.connect(
sqlite3.OperationalError: unable to open database file

As far as I can tell, awscli's official packages come pre-populated with their completion database (awscli/data/ac.index) pre-populated. In this PR, I've run it in postBuild.
You can test the results from the build-directory with env COMP_LINE='aws athena get' result/bin/aws_completer

I'm not a python developer / nix developer / aws developer, so it's entirely possible I've missed something silly, let me know if so.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits
Copy link

@worldofpeace worldofpeace left a comment

Some changes I thought to make.
Also, you commit message doesn't match contribution guidelines

awscli2: generate autocompletion database

pkgs/tools/admin/awscli2/default.nix Outdated Show resolved Hide resolved
pkgs/tools/admin/awscli2/default.nix Outdated Show resolved Hide resolved
pkgs/tools/admin/awscli2/default.nix Outdated Show resolved Hide resolved
Copy link

@dbirks dbirks left a comment

Thank you very much for this. Having working autocomplete is so nice to have. Here's some changes I've made while testing with nixpkgs-review:

pkgs/tools/admin/awscli2/default.nix Outdated Show resolved Hide resolved
@jdelStrother jdelStrother force-pushed the awscli-autocomplete branch from 92257cb to e2efc89 Nov 13, 2020
dbirks approved these changes Nov 13, 2020
Copy link

@teto teto commented Mar 18, 2021

@jdelStrother is this ready ?

Copy link
Contributor Author

@jdelStrother jdelStrother commented Mar 18, 2021

Yes... though it looks like it's been fixed separately in #103718 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants