Introducing Lima to Trellis for Faster Local Development

Sort of yeah. I wrote more about this here: Add VM integration by swalkinshaw · Pull Request #346 · roots/trellis-cli · GitHub

Is this able to handle multiple sites yet? I hit this error and cannot figure out how to pass an argument? Also, there’s a typo “Please specific a site”.

Error: Multiple sites found in development. Please specific a site

And

Error: too many arguments (expected exactly 0, got 1)

That’s just running trellis vm start? I think I see what’s happening and it’s a bug in this case. The CLI just looks up the main site name to use as the default VM name, but it errors when it finds multiple sites which I’ll have to fix :thinking:

However, the VM automatically supports all sites found in an environment (or it would if you didn’t run into that bug). So once fixed, you won’t have to specific a site.

1 Like

Yep - just running trellis vm start

1 Like

Not compatible with Big Sur?

I tried testing this out straight away when I noticed this post and from what I recall, I received a notice stating Venture is required?

Correct, macOS’ new virtualization framework is Ventura/13.0+

1 Like

Does anyone else see the following? This env worked yesterday just fine…

❯ trellis vm start 
Running command => limactl start example.com
INFO[0000] Using the existing instance "example.com"        
INFO[0005] [hostagent] Starting VZ (hint: to watch the boot progress, see "/Users/username/.lima/example.com/serial.log") 
INFO[0006] SSH Local Port: 49416                        
INFO[0006] [hostagent] new connection from  to          
INFO[0006] [hostagent] Waiting for the essential requirement 1 of 3: "ssh" 
INFO[0006] [hostagent] [VZ] - vm state change: running  
INFO[0009] [hostagent] 2023/03/20 20:51:49 tcpproxy: for incoming conn 127.0.0.1:49419, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: no route to host 
INFO[0019] [hostagent] Waiting for the essential requirement 1 of 3: "ssh" 
INFO[0019] [hostagent] 2023/03/20 20:52:00 tcpproxy: for incoming conn 127.0.0.1:49424, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: connection was refused 
INFO[0030] [hostagent] Waiting for the essential requirement 1 of 3: "ssh" 
INFO[0030] [hostagent] 2023/03/20 20:52:10 tcpproxy: for incoming conn 127.0.0.1:49428, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: connection was refused 
INFO[0040] [hostagent] Waiting for the essential requirement 1 of 3: "ssh" 
INFO[0040] [hostagent] 2023/03/20 20:52:20 tcpproxy: for incoming conn 127.0.0.1:49437, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: connection was refused 
INFO[0050] [hostagent] Waiting for the essential requirement 1 of 3: "ssh" 
INFO[0050] [hostagent] 2023/03/20 20:52:31 tcpproxy: for incoming conn 127.0.0.1:49442, error dialing "192.168.5.15:22": connect tcp 192.168.5.15:22: connection was refused

One other env starts ok, one other has the same problem.

I’ve found vz: Has been stuck in Waiting for the essential requirement 1 of 3: "ssh" on Start lima · Issue #1200 · lima-vm/lima · GitHub but not a solution.

I’ve gotten that occasionally as well. Not sure of a real solution other than rebooting :sweat: Might be helpful to run limactl start --debug example.com and comment on that lima issue with the log output.

Sorry @adleviton I forgot about this, here’s a really brief breakdown of what would be required to add a config option:

  1. A new field in the VmConfig struct: trellis-cli/cli_config.go at 4e07b6e4907de916f4690ae423b13c3932e36fd8 · roots/trellis-cli · GitHub
  2. corresponding field in Lima’s instance Config struct: https://github.com/roots/trellis-cli/blob/4e07b6e4907de916f4690ae423b13c3932e36fd8/pkg/lima/instance.go#L37-L40
  3. pass the CLI config field to the Lima instance config: https://github.com/roots/trellis-cli/blob/4e07b6e4907de916f4690ae423b13c3932e36fd8/pkg/lima/manager.go#LL229C34-L229C34
config := Config{
  Images: images,
  NewField: m.trellis.CliConfig.Vm.NewField,
}
  1. Finally, output the new field in the Lima config template: https://github.com/roots/trellis-cli/blob/4e07b6e4907de916f4690ae423b13c3932e36fd8/pkg/lima/files/config.yml

I’m running on an M2 and the vm start process hangs in various places and doesn’t complete 90% of the time. Sometimes a restart of the machine helps, sometimes it doesn’t. I haven’t been able to find much rhyme or reason as to what the affecting variables are. The virtual machine itself appears to be running (if I run the command again I get the “Your Trellis VM is ready to use!” message), so I assume it’s the provisioning not finishing? The etc/hosts file looks correct, when I ping the url it’s correct, it’s just that the site won’t connect in browser (very long load time followed by a connection error).

For the record when I run the process on my intel macbook everything works fine.

Any idea what the issue could be?

Hi @nikitasol - sorry to be a pain, but could you possibly help me set up wp-cli.yml - I’m a little lost on the ssh path(s), nothing seems to connect properly. Thanks!

It’s hard to say without more specifics on “vm start process hangs in various places”. I’d suggest opening a new thread with specifics and log/terminal output.

Okay cool, I’ll spend some time testing this afternoon and record the failure points (wish I did it at the time). Thanks!

Lima is working fine for me at the moment, though I’ve found that the hot refresh takes a while to come through each time - maybe 3-4 seconds refresh. Is there something I should adjust/clear to speed this up?

Are you referring to Sage/Bud’s dev server and hot reloading? Are you manually refreshing after 3-4 seconds or are you saying that’s how long it takes for the injection to complete after a build is triggered by saving a file?

For me personally, theme builds happen instantly and no longer give me any kind of trouble with delays since there isn’t NFS file syncing issues like with Vagrant.

It would be helpful to make a new topic with more details to troubleshoot that specifically so that this topic can stay more relevant to any Trellis specific issues.

1 Like

While starting Lima: trellis vm start on existing environment, you could get:

WARNING: This project has not been initialized with trellis-cli and may not work as expected.

You may see this warning if you are using trellis-cli on an existing project (previously created without the CLI).
To ensure you have the required dependencies, initialize the project with the following command:

  $ trellis init

If you want to manage dependencies yourself manually, you can ignore this warning.
To disable this automated check, set the 'virtualenv_integration' configuration setting to 'false'.

Ok, I went through the docs: Trellis CLI | Trellis Docs | Roots and created a cli.yml:

# trellis/.trellis/cli.yml

check_for_updates: true
load_plugins: true
open:
  site: "http://exanple.test"
  admin: "http://exanple.test/wp/wp-admin"
virtualenv_integration: false

As well, tried setting ENV variable:
But with no luck, and I continue receiving a Warning message.
All other Trellis CLI commands (outside trellis vm) are working fine without a Warning.

Any ideas about what might be wrong there?

I can reproduce that bug on any command, so I don’t think it’s limited to vm start? I’ll fix it though, thanks for reporting here. This is probably better suited for a GitHub issue though for bugs like this in the future.

Oh, I actually could get the same Warnings while working with vault commands in CLI.
Yep, it’s not limited to vm.
Thanks for confirming!

I could create a GitHub issue for that. But I’m not sure which repo is better for this: trellis or trellis-cli?

I’ve already fixed it Fix virtualenv_integration config setting by swalkinshaw · Pull Request #384 · roots/trellis-cli · GitHub :smile:

It will be in the next release soon

v1.11.0 is out and it contains a lot of improvements and bug fixes related to Lima. Thanks for the feedback everyone.

2 Likes