Skip to content

Conversation

AkihiroSuda
Copy link
Member

Similar to --mount, but overrides the existing mounts.

e.g.,

limactl start --mount-only "$(pwd)"

This will only make the current directory visible to the VM. The host home directory is not visible (unless pwd is the home).

Similar to `--mount`, but overrides the existing mounts.

e.g.,
```
limactl start --mount-only "$(pwd)"
````

This will only make the current directory visible to the VM.
The host home directory is not visible (unless pwd is the home).

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Sep 3, 2025
@AkihiroSuda AkihiroSuda added the area/cli limactl CLI user experience label Sep 3, 2025
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

Feedback can also be addressed in separate PRs (or just file open issues).

if err != nil {
return "", err
}
expr := `.mounts += ` + mountListExpr + ` | .mounts |= unique_by(.location)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just existing code that is being moved, but the logic is incorrect: the mounts need to be unique by .mountPoint, not by .location. The same location can be mounted to several mount points, and this logic would delete all but one of them.

But the mount point may only be filled in later (defaults to location), so we can't do anything here beyond making sure that the new mount points are defined first, so they will overrride existing mounts (mostly relevant only for the writable property).

I think this would be better (but have not tested it):

Suggested change
expr := `.mounts += ` + mountListExpr + ` | .mounts |= unique_by(.location)`
// mount options take precedence over template settings
expr := fmt.Sprintf(".mounts = %s + .mounts", mountListExpr)

Could also open a new issue to address later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +262 to +271
func(_ *flag.Flag) (string, error) {
incompatibleFlagNames := []string{"mount", "mount-only"}
for _, name := range incompatibleFlagNames {
ss, err := flags.GetStringSlice(name)
if err != nil {
return "", err
}
if len(ss) > 0 {
return "", errors.New("flag `--mount-none` conflicts with `" + name + "`")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be a shared helper function because we have other subcommands that have mutually exclusive options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can add a helper when we have move conflicting options

@AkihiroSuda AkihiroSuda merged commit e963c32 into lima-vm:master Sep 4, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli limactl CLI user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants