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

[BUG] Tab completion and --file option results in "y" #9941

Closed
tmknight opened this issue Oct 22, 2022 · 17 comments
Closed

[BUG] Tab completion and --file option results in "y" #9941

tmknight opened this issue Oct 22, 2022 · 17 comments
Assignees
Labels

Comments

@tmknight
Copy link

tmknight commented Oct 22, 2022

Description

When performing tab completion on --file , the result is the character "y". Regardless of how many leading characters are input before tab; the end result is "y" replaces all prior input.

Steps To Reproduce

Ubuntu 22.04.1, fully updated
Docker-CE repository

RUN: docker compose --file /mnt/start-of-path [tab]
RESULT: docker compose --file y

The expected result is the completion of the line relative to the objects in the path that match the preceding characters.

Compose Version

Docker Compose version v2.12.2

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.12.2)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 6
  Running: 6
  Paused: 0
  Stopped: 0
 Images: 6
 Server Version: 20.10.21
 Storage Driver: zfs
  Zpool: rpool
  Zpool Health: ONLINE
  Parent Dataset: rpool/ROOT/ubuntu_549uxf/var/lib
  Space Used By Parent: 3004538880
  Space Available: 199805337600
  Parent Quota: no
  Compression: lz4
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.0-56-generic
 Operating System: Ubuntu 22.04.1 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.653GiB
 Name: tmk-svr-01
 ID: OVLQ:BHCM:EYES:2XNJ:IBFZ:ANTP:GEPH:Y5M7:FDET:EB5P:NOQB:G6VX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: true

Anything else?

Started with compose
Live Restore Enabled: true



### Anything else?

Started with compose 2.11.2 when tab/command completion was introduced.  Persists through 2.12.2
@tmknight tmknight changed the title Tab completion and --file attribute results in "y" [BUG] Tab completion and --file attribute results in "y" Oct 22, 2022
@tmknight tmknight changed the title [BUG] Tab completion and --file attribute results in "y" [BUG] Tab completion and --file option results in "y" Oct 22, 2022
@tmknight tmknight changed the title [BUG] Tab completion and --file option results in "y" [BUG] Tab completion and --file option results in "y" Oct 22, 2022
@ndeloof
Copy link
Contributor

ndeloof commented Dec 13, 2022

@tmknight
Copy link
Author

Interesting, possibly distribution or terminal specific. I'm experiencing this on Ubuntu 22.04 LTS via SSH. Will try another distribution/terminal as comparison.

@moono
Copy link

moono commented Dec 23, 2022

Same here,

$ docker compose -f TAB results just y

  • os: ubuntu 18.04
  • docker compose version: v2.12.2

I use windows 11 to access (ssh) that ubuntu machine via windows terminal && cmder

both terminal has same symptoms

@bofhdk
Copy link

bofhdk commented Jan 1, 2023

Same here. However, creating an alias (alias docker-compose="docker compose") seems to "fix" this.

  • os: Debian GNU/Linux 11 (bullseye)
  • Docker Compose version v2.14.1

@tmknight
Copy link
Author

tmknight commented Jan 5, 2023

Verified also reproduceable on Fedora 37 Server Edition; so in addition to Ubuntu and Debian, Fedora demonstrates the issue.

Example: Fedora 37: https://asciinema.org/a/AA9sc6zRlfzFJd9b77fuXhgNE

@ndeloof, please describe your environment that you cannot reproduce? Can you spin up an Ubuntu VM and try for us?

@ferrarimarco
Copy link

Hi! Same here on Debian 11, bash 5.1.4, Docker Compose version v2.14.1

@ndeloof
Copy link
Contributor

ndeloof commented Jan 23, 2023

I can reproduce this error using a multipass Ubuntu VM, investigating

@ndeloof ndeloof self-assigned this Jan 23, 2023
@ndeloof
Copy link
Contributor

ndeloof commented Jan 23, 2023

completion for -f lists the supported file extensions that shell should filter:

/usr/libexec/docker/cli-plugins/docker-compose __complete -f ""
yaml
yml
:8
Completion ended with directive: ShellCompDirectiveFilterFileExt

Seems this is misunderstood by the bash-completion package which offers first common character y. Confirmed by a second [tab]:

$ docker compose -f y[tab tab]
yaml  yml   

@ndeloof
Copy link
Contributor

ndeloof commented Jan 24, 2023

ok, I eventually understood what's wrong here:
the bash_completion script being installed by default is not aligned with completion support by compose CLI-plugin, relying on cobra completion v2. This script could be produced by docker completion bash command:

$ docker completion
docker: 'completion' is not a docker command.
See 'docker --help'

the root cause is that docker CLI with cobra completion support hasn't been released yet. See docker/cli#3429 for details

in the meantime, one option is for you to build the docker CLI from sources, and generate completion script.

@mfloresVicomtech
Copy link

Same problem here on Ubuntu 20.04.5 LTS @ WSL2 on Windows 11. Is there a temporal workaround not involving building the cli from source?

@ndeloof
Copy link
Contributor

ndeloof commented Feb 1, 2023

for your convenience I created a gist with completion script as generated by docker CLI: https://gist.github.com/ndeloof/c70c7a917503a19f4086e5e7b6370567

@ndeloof
Copy link
Contributor

ndeloof commented Feb 1, 2023

I'm closing this issue as "fixed in compose" (waiting for docker/cli release)

@jagerber48
Copy link

I'm closing this issue as "fixed in compose" (waiting for docker/cli release)

Can you help me understand this comment (with me maybe being a bit of a noob)? It seems like the docker compose v2 code is in place, but for this functionality to work with regular docker installation we are waiting on a later release from the larger docker project? Is that right? If so, when will this later release be?

Also, I didn't follow if there was a short/medium term workaround to get auto-completion working for docker compose v2 now.

@ndeloof
Copy link
Contributor

ndeloof commented Mar 22, 2023

completion relies on docker/cli#3429
if you upgrade to Docker CLI 23.01 you will get this feature and command line completion.

@jagerber48
Copy link

completion relies on docker/cli#3429 if you upgrade to Docker CLI 23.01 you will get this feature and command line completion.

I'm not sure exactly how to upgrade to Docker CLI 23.01, but if I type docker version I see Version: 23.0.1, so seems like I may already be on that version. Am I missing something or should I open another issue if I'm still seeing the same behavior as described at the top of this issue?

@jagerber48
Copy link

It seems like the specific problem in this issue (tab completion for -f option results in y) is still present in 23.0.1 even if other tab completion progress has already been made. However, it does looks like a resolution for this issue was just merged in: docker/cli#4136

@jagerber48
Copy link

This issue is now fixed for me with Docker CLI 23.0.4

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

No branches or pull requests

7 participants