roots / trellis-cli

A CLI to manage Trellis projects
https://roots.io/trellis/
MIT License
165 stars 25 forks source link

Trellis Lima not adding new mounts #421

Closed mmoollllee closed 3 weeks ago

mmoollllee commented 10 months ago

Version

1.11.1

What did you expect to happen?

After adding a new wordpress site to group_vars and running trellis provision development I expected trellis-cli to add the new local_path to lima mount points.

What actually happens?

trellis provision development complains about missing composer.json and fails due to missing mount to local_path.

To solve the issue:

Steps to reproduce

Add another site to group_vars/development/wordpress_sites.yml in a existing project and run trellis provision development

System info

macOS trellis-cli lima

Log output

No response

Please confirm this isn't a support request.

Yes

dalepgrant commented 2 months ago

Can confirm this. I've just been setting things back up on a new machine and decided to give Lima a go. Previously (not using Lima), to add a new WP site to development I had to run trellis down && trellis up && trellis provision --tags wordpress development. The down && up is necessary for vagrant to realise there's a new folder to link to, otherwise the exact same error happens (have to set no-log to true to see the error). Example of the error from running trellis provision --tags wordpress development with Lima after adding a new site:

TASK [wordpress-install : Setup composer authentications (HTTP Basic) - example.com] ***
failed: [default] (item=default-type.composer.deliciousbrains.com) => {"ansible_loop_var": "item", "changed": false, "item": {"hostname": "composer.deliciousbrains.com", "password": "hahayeahright", "username": "notleavingthishere"}, "msg": "In ConfigCommand.php line 218: File \"./composer.json\" cannot be found in the current directory config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [-j|--json] [-m|--merge] [--append] [--source] [--] [<setting-key> [<setting-value>...]]", "stdout": "\nIn ConfigCommand.php line 218:\n                                                                   \n  File \"./composer.json\" cannot be found in the current directory [the rest redacted, you get the gist]

The folder exists correctly in the vm but the current dir contains only an empty web dir, not the project files.

Edit: this looks vaguely similar to this Discourse thread which was ultimately solved by destroying the vm. Would like to avoid that.

Edit: Manually editing the file at /Users/[username]/.lima/[instance name]/lima.yaml, restarting and re-provisioning the vm works. I fell into the trap of thinking one could edit .trellis/lima/[instance name].yml as this person on Discourse also did.

One more edit: this has been explained by @swalkinshaw in this post.

dalepgrant commented 3 weeks ago

Testing this out: adding a site with Lima now works 🙌

For anyone in future: until the CLI gets a tagged release (higher than v1.12.0), follow the readme to install the unstable version.

To add a site, if your vm is running, you'll need to run trellis vm stop && trellis vm start && trellis provision --tags wordpress development otherwise the provision will fail on "Setup composer authentications (HTTP Basic)".

Thanks @swalkinshaw! 🫶

swalkinshaw commented 3 weeks ago

Thanks for much for testing this @dalepgrant! I'll release it soon

As a next step I was thinking of having the CLI detect when the saved Lima config is out of date based on Trellis site configs. Just need to figure out the UX for it mainly because it's easy now to generate the config in-memory (on every vm start at least and maybe provision development?) and show a note or prompt for a restart.

dalepgrant commented 2 weeks ago

That's a nice idea... a message earlier in the process would be very welcome as it'd mean we don't have to wait as long to find out there's an error. Would a flag to also restart the vm on provision be possible, something like trellis provision --reload --tags wordpress development (taking reload from vagrant)? If that's worth a separate issue to discuss I'll create one.

swalkinshaw commented 2 weeks ago

Yeah a separate issue would be good since there's a lot of options 👍