Skip to content

Commit f21596f

Browse files
authored
Merge pull request #62 from AkihiroSuda/lima-home
Follow-up to "Implement LIMA_HOME to override ~/.lima location"
2 parents 2de713f + a22f8af commit f21596f

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

cmd/limactl/start.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ func loadOrCreateInstance(clicontext *cli.Context) (*store.Instance, error) {
8282
return nil, err
8383
}
8484

85-
// all socket names should be 6 characters or less
86-
maxSockName := filepath.Join(instDir, "serial.sock")
87-
if len(maxSockName) >= 104 {
88-
return nil, errors.Errorf("Instance name %q too long: %q must be less than 104 characers, but is %d",
85+
// the full path of the socket name can be at most 104 chars.
86+
maxSockName := filepath.Join(instDir, filenames.LongestSock)
87+
if len(maxSockName) > 104 {
88+
return nil, errors.Errorf("instance name %q too long: %q can be at most 104 characers, but is %d",
8989
instName, maxSockName, len(maxSockName))
9090
}
9191
if _, err := os.Stat(instDir); !errors.Is(err, os.ErrNotExist) {

docs/internal.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Internal data structure
22

3-
## Instance directory (`~/.lima/<INSTANCE>`)
3+
## Lima home directory (`${LIMA_HOME}`)
4+
5+
Defaults to `~/.lima`.
6+
7+
Note that we intentionally avoid using `~/Library/Application Support/Lima` on macOS.
8+
9+
We use `~/.lima` so that we can have enough space for the length of the socket path,
10+
which can be only 104 characters on macOS.
11+
12+
### Instance directory (`${LIMA_HOME}/<INSTANCE>`)
413

514
An instance directory contains the following files:
615

@@ -31,9 +40,21 @@ Host agent:
3140
- `ha.stdout.log`: hostagent stdout (JSON lines, see `pkg/hostagent/api.Events`)
3241
- `ha.stderr.log`: hostagent stderr (human-readable messages)
3342

34-
## Cache directory (`~/Library/Caches/lima/download/by-url-sha256/<SHA256_OF_URL>`)
43+
## Lima cache directory (`~/Library/Caches/lima`)
44+
45+
Currently hard-coded to `~/Library/Caches/lima` on macOS.
46+
47+
### Download cache (`~/Library/Caches/lima/download/by-url-sha256/<SHA256_OF_URL>`)
3548

3649
The directory contains the following files:
3750

3851
- `url`: raw url text, without "\n"
3952
- `data`: data
53+
54+
## Environment variables
55+
56+
- `$LIMA_HOME`: The "Lima home directory" (see above).
57+
- Default : `~/.lima`
58+
59+
- `$LIMA_INSTANCE`: `lima ...` is expanded to `limactl shell ${LIMA_INSTANCE} ...`.
60+
- Default : `default`

pkg/store/filenames/filenames.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ const (
1818
HostAgentStdoutLog = "ha.stdout.log"
1919
HostAgentStderrLog = "ha.stderr.log"
2020
)
21+
22+
// LongestSock is the longest socket name.
23+
// On macOS, the full path of the socket can be at most 104 characters.
24+
// See unix(4).
25+
//
26+
// On Linux, the max length is 108.
27+
const LongestSock = SerialSock

0 commit comments

Comments
 (0)