nix-community / lorri

Your project’s nix-env [maintainer=@Profpatsch,@nyarly]
Apache License 2.0
638 stars 24 forks source link

lorri breaks tab completion #73

Closed l0b0 closed 1 year ago

l0b0 commented 2 years ago

Describe the bug

To Reproduce Steps to reproduce the behavior on a NixOS system with the lorri daemon running and git and direnv installed:

  1. Enter a basic Nix shell:
    cd "$(mktemp --directory)"
    cat > shell.nix <<EOF
    { pkgs ? import
       (
         fetchTarball {
           name = "21.11";
           url = "https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz";
           sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02";
         })
       { }
    }:
    pkgs.mkShell {
     name = "test";
    }
    EOF
    nix-shell
  2. Verify that commands like git st followed by a Tab auto-suggest "stage stash status".
  3. Enable lorri default configuration:
    exit
    lorri init
    direnv allow
  4. Verify that git st followed by a Tab no longer auto-suggests.

Expected behavior

Git auto-complete should continue working.

Metadata

$ lorri info
error: The following required arguments were not provided:
    --shell-file <nix_file>

USAGE:
    lorri info --shell-file <nix_file>

For more information try --help
$ lorri info --shell-file shell.nix
lorri version: 1.5
GC roots exist, shell_gc_root: /home/victor/.cache/lorri/gc_roots/167ffda1a9ddc154c50c4959bb23edc3/gc_root/shell_gc_root
$ uname -a
Linux whenua 5.10.81 #1-NixOS SMP Sun Nov 21 12:46:37 UTC 2021 x86_64 GNU/Linux

Additional context

Console session with relevant commands and their outputs:

$ cd "$(mktemp --directory)"
$ cat > shell.nix <<EOF
{ pkgs ? import
    (
      fetchTarball {
        name = "21.11";
        url = "https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz";
        sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02";
      })
    { }
}:
pkgs.mkShell {
  name = "test";
}
EOF
$ nix-shell
$ git st
stage    stash    status
$ lorri init
Dec 20 15:59:51.546 INFO file already exists, skipping, message: Make sure shell.nix is of a form that works with nix-shell., path: ./shell.nix
Dec 20 15:59:51.546 INFO wrote file, path: ./.envrc
Dec 20 15:59:51.546 INFO done
direnv: error /tmp/tmp.KtyfnccVGx/.envrc is blocked. Run `direnv allow` to approve its content
$ direnv allow
direnv: loading /tmp/tmp.KtyfnccVGx/.envrc
Dec 20 16:00:04.003 INFO lorri has not completed an evaluation for this project yet, nix_file: /tmp/tmp.KtyfnccVGx/shell.nix
direnv: export +IN_NIX_SHELL
$ lorri info
error: The following required arguments were not provided:
    --shell-file <nix_file>

USAGE:
    lorri info --shell-file <nix_file>

For more information try --help
$ lorri info --shell-file shell.nix
lorri version: 1.5
GC roots exist, shell_gc_root: /home/victor/.cache/lorri/gc_roots/167ffda1a9ddc154c50c4959bb23edc3/gc_root/shell_gc_root
$ uname -a
Linux whenua 5.10.81 #1-NixOS SMP Sun Nov 21 12:46:37 UTC 2021 x86_64 GNU/Linux
exarkun commented 2 years ago

I've observed this as well.

SuperSandro2000 commented 2 years ago

Should be fixed by #61

l0b0 commented 2 years ago

Thank you! Is there a release planned?

l0b0 commented 1 year ago

@SuperSandro2000 Looks like this is still partially broken, at least in latest NixOS 22.05. Actual behaviour:

  1. Start a terminal running Bash
  2. cd some-dir where there's an .envrc containing eval "$(lorri direnv)".
  3. Observe that tab-completing a command like git st no longer suggests answers.

However, if I tab-complete git st before cd some-dir, the completion works. Basically, tab-completion is only broken if I go into a direnv-enabled directory immediately after opening the shell. Running a different command first, such as cd /, does not help. Hope this helps debug the underlying issue.

$ lorri --version
lorri 1.5.0
$ direnv --version
2.31.0

@exarkun Are you also observing this still?

l0b0 commented 1 year ago

It looks like this is fixed in nixpkgs 22.11. Thank you!