Skip to content

Commit 05ff20d

Browse files
authored
Merge pull request #3347 from arixmkii/win_additional_path
Support setting extra entries for PATH env variable on Windows hosts
2 parents 99108d9 + 0705db1 commit 05ff20d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

cmd/limactl/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ const (
2828
)
2929

3030
func main() {
31+
if runtime.GOOS == "windows" {
32+
extras, hasExtra := os.LookupEnv("_LIMA_WINDOWS_EXTRA_PATH")
33+
if hasExtra && strings.TrimSpace(extras) != "" {
34+
p := os.Getenv("PATH")
35+
err := os.Setenv("PATH", strings.TrimSpace(extras)+string(filepath.ListSeparator)+p)
36+
if err != nil {
37+
logrus.Warning("Can't add extras to PATH, relying entirely on system PATH")
38+
}
39+
}
40+
}
3141
if err := newApp().Execute(); err != nil {
3242
handleExitCoder(err)
3343
logrus.Fatal(err)

pkg/qemu/qemu.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,10 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
606606
if !noFirmware {
607607
var firmware string
608608
firmwareInBios := runtime.GOOS == "windows"
609-
if envVar := os.Getenv("LIMA_QEMU_UEFI_IN_BIOS"); envVar != "" {
610-
b, err := strconv.ParseBool(os.Getenv("LIMA_QEMU_UEFI_IN_BIOS"))
609+
if envVar := os.Getenv("_LIMA_QEMU_UEFI_IN_BIOS"); envVar != "" {
610+
b, err := strconv.ParseBool(os.Getenv("_LIMA_QEMU_UEFI_IN_BIOS"))
611611
if err != nil {
612-
logrus.WithError(err).Warnf("invalid LIMA_QEMU_UEFI_IN_BIOS value %q", envVar)
612+
logrus.WithError(err).Warnf("invalid _LIMA_QEMU_UEFI_IN_BIOS value %q", envVar)
613613
} else {
614614
firmwareInBios = b
615615
}

website/content/en/docs/config/environment-variables.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,27 @@ This page documents the environment variables used in Lima.
6767
export LIMA_USERNET_RESOLVE_IP_ADDRESS_TIMEOUT=5
6868
```
6969

70-
### `LIMA_QEMU_UEFI_IN_BIOS`
70+
### `_LIMA_QEMU_UEFI_IN_BIOS`
7171

7272
- **Description**: Commands QEMU to load x86_64 UEFI images using `-bios` instead of `pflash` drives.
7373
- **Default**: `false` on Unix like hosts and `true` on Windows hosts
7474
- **Usage**:
7575
```sh
76-
export LIMA_QEMU_UEFI_IN_BIOS=true
76+
export _LIMA_QEMU_UEFI_IN_BIOS=true
7777
```
7878
- **Note**: It is expected that this variable will be set to `false` by default in future
7979
when QEMU supports `pflash` UEFI for accelerated guests on Windows.
80+
81+
### `_LIMA_WINDOWS_EXTRA_PATH`
82+
83+
- **Description**: Additional directories which will be added to PATH by `limactl.exe` process to search for tools.
84+
It is useful, when there is a need to prevent collisions between binaries available in active shell and ones
85+
used by `limactl.exe` - injecting them only for the running process w/o altering PATH observed by user shell.
86+
Is is Windows specific and does nothing for other platforms.
87+
- **Default**: unset
88+
- **Usage**:
89+
```bat
90+
set _LIMA_WINDOWS_EXTRA_PATH=C:\Program Files\Git\usr\bin
91+
```
92+
- **Note**: It is an experimental setting and has no guarantees being ever promoted to stable. It may be removed
93+
or changed at any stage of project development.

0 commit comments

Comments
 (0)