We’ve added experimental support for Lima to Trellis, which allows us to drop VirtualBox/Parallels and Vagrant for faster local dev environments.
Read more on our blog: Introducing Lima to Trellis for Faster Local Development | Roots
We’ve added experimental support for Lima to Trellis, which allows us to drop VirtualBox/Parallels and Vagrant for faster local dev environments.
Read more on our blog: Introducing Lima to Trellis for Faster Local Development | Roots
Testing this right now! If it’s functional and fast, this will easily replace Parallels for my whole team!
We don’t have documentation for this feature yet, but the PR description has all the details including setting up sudoers and how to change the Ubuntu version if necessary: Add VM integration by swalkinshaw · Pull Request #346 · roots/trellis-cli · GitHub
Hi, how can I connect to the database using Sequel Ace? Should I use SSH or socket?
Oh good question. You should use SSH. Here’s what my connection screen looks like:
limactl ls
(but the host is always 127.0.0.1
so you just need to find the port)I’ll have to see how we can improve the trellis db open
command to better work with this.
Basic usage is very straight forward and works without any problem. I have tried moving my last work to the Lima VM and after manually updating (maybe not all were required) development hosts, /etc/hosts (deleting old ones) and wp-cli alias for development (I have used limactl show-ssh --format=cmd INSTANCE to check values, but then I saw that these can also be consulted in the lima inventory file) I have managed to pull down and sync production db.
I am not sure, but I think it would be great to have a couple of additional vm commands to help with initial setup and move to the new virtual machine? Maybe trellis vm init might be good so yml file can be reviewed and updated before initial provision? And maybe trellis vm aliases for rewriting wp-cli.yml with the new values?
Also, thanks for this move to Lima. It’s absolutely much faster and so much less frustrating than with the VirtualBox.
Thanks for testing it so quickly!
Removing conflicting entries in /etc/hosts
and .ssh/config
might be necessary (though vagrant down
might automatically remove those as well).
Did you mean Ansible hosts files like hosts/development
? Lima generates its own inventory file as you saw so there’s no need to remove the existing ones.
For WP-CLI aliases, I’d recommend running trellis alias
which will generate them all for you. Not sure if you had used that before or just manually defined them?
Yes, I thought so, but I changed hosts/development ones manually after I tried running trellis alias and got into error:
[✘] Error generating config
Error creating WP-CLI aliases. Temporary playbook failed to execute:
[WARNING]: Platform darwin on host 192.168.56.5 is using the discovered Python
interpreter at /usr/local/bin/python3.10, but future installation of another
Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-
core/2.13/reference_appendices/interpreter_discovery.html for more information.
The host in error was the one that was the original host ip, so I decided to change it manually to the new value. It had no effect on the trellis alias and it continued throwing the error (though showing the updated ip), so I changed the alias manually. The aliases were generated at first through trellis-cli.
This is working great for local development, but my workflow struggles when I try to use Trellis aliases and ssh commands that work with Parallels and Virtualbox. Things like the Sync Script.
It seems like a some kind of flag containing the “current” or “last-brought-up” development environment (Vagrant or Lima), and a conditional around this line (and whatever the Go equivalent of whoami
is), might get things working together?
Thanks, that’s works!
Thanks, this looks promising!
Should .trellis/lima
be in trellis/.gitignore? The generated files don’t look something to be committed.
I’ve tested with one site. So far, so good. Note that I use neither trellis new
or trellis init
in case that makes a difference. I also changed the LIMA_HOME
env variable so I’m working from an external drive. My site is running and was able to connect with Sequel Ace.
Questions/Comments for now:
vagrant trellis-cert trust
)?$LIMA_HOME/.lima/_config/default.yml
(changing memory, cpus, disk size), but it seems to have no effect, even after deleting and reprovisioning. I can’t figure this out.trellis vm stop
didn’t completely exit back to command line.trellis vm shell
, the following errors appear:bash: line 1: cd: /Volumes/External Drive/My Project/trellis: No such file or directory
bash: line 1: cd: /Users/adam: No such file or directory
I actually haven’t had any issue with Sync Script after manually adjusting wp-cli.yml to correctly establish ssh connection.
What I have noticed is that the port inside Inventroty (ansible_port) is changed each time I start the machine.
And as @adleviton has mentioned, for me most of times if not all trellis vm stop ends on:
INFO[0001] [hostagent] /Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/!code-!hex/vz/v3@v3.0.4/virtualization.go:160 +0xec
FATA[0180] did not receive an event with the "exiting" status
Error stopping VM
Yes it should be ignored. I need to figure out a better strategy for the .trellis
directory since it’s not ideal right now. .trellis/cli.yml
should be committed, but nothing else in there should be. I’ll likely gitignore .trellis
, and offer a new root-level cli.yml
config. Feedback welcome on that.
There’s no automated way to do that yet. I might wait for SSL certificates refactor by swalkinshaw · Pull Request #1310 · roots/trellis · GitHub with https://github.com/roots/trellis-cli/pull/311
The generated Lima config is in .trellis/lima/<name>.yml
but there’s two issues:
Basically, I need to add support to the CLI config file so customizing those VM properties so they’ll be in the generated config. Right now only the defaults are supported as you found. If you want to try contributing that change, it shouldn’t be so hard and I could help out.
I’d recommend posting an issue on https://github.com/lima-vm/lima/issues since that’s coming directly from the vz
package that Lima uses for macOS virtualization.
Reminder: trellis vm
mainly wraps underlying limactl
commands so you can always run those manually too.
Yeah I get that too. Lima assumes those directories are mounted by default, but they aren’t in my integration. So there’s two options:
/srv/www/<main site>
I’m using Lima’s default method of auto finding a free SSH forwarding port. It’s good because you don’t have to worry about manually setting it or having conflicts with multiple machines, but it does mean the port isn’t stable.
For things that trellis-cli can control (like trellis db open
, which I’ll fix soon), it will automatically use the generated inventory file ensuring everything works. But for external tools like sync script, it does mean you need to update the port manually each time
Maybe I could make an SSH port option if people want to hard code it?
I’d like to help but not sure how or where to get started working on a CLI package. If there is a crash-course out there, let me know. For now, my confusion here comes from trying to follow their instructions for default.yml. Specifically this part:
# The builtin defaults can be changed globally by creating a $LIMA_HOME/_config/default.yaml
# file. It will be used by ALL instances under the same $LIMA_HOME, and it
# will be applied on each `limactl start`, so can affect instance restarts.
Oh… I’d actually think that should take affect since it’s defaults. I’ll look into that first.