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

haskellPackages.optparse-applicative: Fix for compgen error #100515

Conversation

@roberth
Copy link
Member

@roberth roberth commented Oct 14, 2020

Motivation for this change

Fix optparse-applicative's call to bash when running in a nix-shell. Although nix-shell invokes bashInteractive, it has a non-interactive bash on PATH most of the time, because that's what stdenv uses. optparse-applicative can get a better bash via $SHELL, fixing the error:

[nix-shell]$ mycommand --file <TAB>bash: compgen: command not found
bash: compgen: command not found
bash: compgen: command not found
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 CONTRIBUTING.md.
@cdepillabout
Copy link
Member

@cdepillabout cdepillabout commented Oct 15, 2020

@roberth Thanks for fixing this. I think I've run into this in the past and not realized what was happening.

Would you be able to rebase this on the haskell-updates branch? Also, do you have a specific command in mind that I'd be able to test this with? I imagine I'd just have to do something like nix-shell -p haskellPackages.some-command and then try the bash completion?

@roberth
Copy link
Member Author

@roberth roberth commented Oct 15, 2020

I discovered this while working on the new Hercules CI CLI which is isn't packaged yet.
It turns out that not so many commands use bashCompleter, which is the offending function. For example, stack implements its own path completion.
I did find atsfmt which is packaged but doesn't have

PATH=$(nix-build --expr 'let pkgs = import ./. {}; in pkgs.haskell.lib.generateOptparseApplicativeCompletion "atsfmt" pkgs.haskellPackages.ats-format')/bin:$PATH
PATH=$(nix-build '<nixpkgs>' -A bash)/bin:$PATH
source <(atsfmt --bash-completion-script $(which atsfmt))

I now realize that I didn't have to call generateOptparseApplicativeCompletion because that only affects nix-env -i and environment.systemPackages etc. Oh well.

@roberth
Copy link
Member Author

@roberth roberth commented Oct 15, 2020

Rebased in #100563

@cdepillabout
Copy link
Member

@cdepillabout cdepillabout commented Nov 1, 2020

@roberth I guess you fixed this in #100563, so I am going to go ahead and close this PR. Please feel free to reopen it if this is a mistake.

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

Successfully merging this pull request may close these issues.

None yet

2 participants