The Wayback Machine - https://web.archive.org/web/20251130012538/https://github.com/docker/compose-switch/issues/35
Skip to content

Panic on empty project-directory #35

@grishy

Description

@grishy

Description
Panic in cobra

Steps to reproduce the issue:

  1. docker-compose --project-directory "" ps

Describe the results you received:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/docker/compose-switch/redirect.Convert(0xc0000b8010, 0x4, 0x4, 0x9, 0xc0000c2628, 0x1)
        /home/runner/go/pkg/mod/github.com/docker/compose-switch@v1.0.4/redirect/convert.go:32 +0x8ba
main.main.func1(0xc0000bc780, 0xc0000b8010, 0x4, 0x4, 0x0, 0x0)
        /home/runner/work/compose-v1v2-switch/compose-v1v2-switch/main.go:59 +0x14d
github.com/spf13/cobra.(*Command).execute(0xc0000bc780, 0xc0000b8010, 0x4, 0x4, 0xc0000bc780, 0xc0000b8010)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000bc780, 0xc000096df0, 0x0, 0x160d660)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
        /home/runner/work/compose-v1v2-switch/compose-v1v2-switch/main.go:68 +0x185

Describe the results you expected:
Hmm, error or something like that

Output of docker compose version:

Docker Compose version v2.5.1

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.5.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 20
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.104-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 9.73GiB
 Name: docker-desktop
 ID: UYE6:X3OH:4K6T:V3ZQ:EST7:QJ4X:2JR6:B6SP:ER4V:PI55:QW23:2KLX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions