Ошибка монтирования разделов
WSL при монтировании vhdx файлов сверяет владельца этого файла с текущим пользователем, если пользователь не совпадает будет ошибка "нет доступа".
Если в качестве настроек композера выбрать путь для хранения файлов и дисков, например C:\WSL, то windows создаст этот каталог с владельцем "Администраторы" что приведёт в свою очередь к таким ошибкам:
--- FAIL: TestNewCmdImageUp (2.18s)
--- FAIL: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c (2.00s)
image-up_test.go:32:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/cmd/wsl-compose/cmd/image-up_test.go:32
Error: Received unexpected error:
exit status 0xffffffff. Stdout: Failed to attach disk '\\?\C:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/AttachDisk/MountVhd/HCS/ERROR_SHARING_VIOLATION
. Stderr:
Test: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c
--- FAIL: TestNewCmdImageUp/context_canceled_если_не_запущен_Registry (0.06s)
image-up_test.go:52:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/cmd/wsl-compose/cmd/image-up_test.go:52
Error: Received unexpected error:
exit status 0xffffffff. Stdout: Failed to attach disk '\\?\C:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/AttachDisk/MountVhd/HCS/ERROR_SHARING_VIOLATION
. Stderr:
Test: TestNewCmdImageUp/context_canceled_если_не_запущен_Registry
--- FAIL: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c_-t_0 (0.06s)
image-up_test.go:67: 2025-01-19 15:14:12.1484042 -0800 PST m=+2.340239201
image-up_test.go:72:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/cmd/wsl-compose/cmd/image-up_test.go:72
Error: Received unexpected error:
exit status 0xffffffff. Stdout: Failed to attach disk '\\?\C:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/AttachDisk/MountVhd/HCS/ERROR_SHARING_VIOLATION
. Stderr:
Test: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c_-t_0
--- FAIL: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c_-r (0.06s)
image-up_test.go:92:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/cmd/wsl-compose/cmd/image-up_test.go:92
Error: Received unexpected error:
exit status 0xffffffff. Stdout: Failed to attach disk '\\?\C:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/AttachDisk/MountVhd/HCS/ERROR_SHARING_VIOLATION
. Stderr:
Test: TestNewCmdImageUp/wsl-compose_image-up_nginx:alpine_-c_-r
Если сменить владельца на файлы и папки, то возникает другая ошибка:
--- FAIL: Test_wsl_checkInternalService (0.14s)
--- FAIL: Test_wsl_checkInternalService/Запуск_и_остановка_сервиса_docker_Registry (0.14s)
check_internal_service_test.go:91:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/internal/wsl/check_internal_service_test.go:91
Error: Received unexpected error:
open D:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx: The system cannot find the path specified.
Test: Test_wsl_checkInternalService/Запуск_и_остановка_сервиса_docker_Registry
--- FAIL: Test_wsl_checkInternalService/Запуск_и_остановка_сервиса_Docker (0.00s)
check_internal_service_test.go:130:
Error Trace: C:/GitLab-Runner/builds/t3_s9iqJR/0/wsl/wsl-compose/internal/wsl/check_internal_service_test.go:130
Error: Received unexpected error:
open D:\WSL\Distributions\wsl-compose-volumes\_internal.vhdx: The system cannot find the path specified.
Test: Test_wsl_checkInternalService/Запуск_и_остановка_сервиса_Docker
FAIL
-
Для начала можно разобраться и решить проблему с правами -
Затем рассмотреть возможность переноса команды монтирования в wsl-service через gRPC вызов