-
Notifications
You must be signed in to change notification settings - Fork 394
Allow users to run BLT commands from their host environment #2938
Comments
I'm in favor of this, but as I recall the reasoning for the change was:
One alternate suggested to reinstating the VM proxy functionality in BLT proper was to use the vagrant-exec plugin https://github.com/p0deje/vagrant-exec. I've only tried this on a test project, and I found that it required creating a Vagrantfile.local that included something like this:
If this works well, perhaps we can provide documentation for this in BLT as an easy way to bring back this functionality? |
Maintenance for this feature was an absolute nightmare, particularly when combined with the use of to drush aliases. There were a seemingly infinite number of edge cases related to it. Proceed at your own peril. |
By the way, if individuals want to run commands outside the VM like "the old way" just to test this, it's pretty easy to do: just change your local alias in blt.yml to match the vm, then run commands like I know that running commands outside the VM creates a maintenance burden for BLT, but I think it's undeniably a better user experience in a lot of areas, and we should try to optimize that experience. Specifically:
Some of these issues create their own maintenance burden for BLT. For instance, we get countless issues related to problems of SSH key forwarding and people trying to run composer/npm operations or git pushes inside the VM. I can't tell you if this burden is more or less than before, but it certainly feels bad now. |
While I saw first-hand how difficult the VM proxy behavior was to maintain, I think there are enough DX pain-points here to warrant reintroducing the behavior. I personally have run into a couple of the issues outlined above by @danepowell (especially commits authored by It might be helpful to aggregate a list of the bug tickets related to this behavior here to get a better understanding of where all of the edge-cases lie. I ran into the following at various points:
|
@danepowell while, like you, I would still like to see this functionality return to BLT, I am using one workaround that alleviates the git pain points. The following can be added to a project's
|
Update on using the vagrant-exec plugin: https://github.com/p0deje/vagrant-exec I've found that this works pretty well on a couple projects. Steps I took:
(Could possibly just add it to the Vagrantfile and commit it.) Notes:
|
The BLT feature that allowed commands to be run from outside the VM simply added I think it would be far better to take @wu-edward's suggestion and let users directly use the plugin rather than having BLT do it on their behalf. |
As much as I would love this feature, I don't think we have the resources to worry about it right now. |
Actually... I do think this is a good idea and we need to find resources to support it. It just doesn't make sense to do things like composer updates or git commits inside a VM, and forcing people to drop in and out of the VM based on what command they are running isn't any better. Redispatching BLT commands definitely has its pitfalls but it seems like the best user experience. |
composer on a shared folder in the vm has considerable worse performance. You don't need a plugin, you just need to execute vagrant ssh -c "command". For drush, I added support for vagrant transport, which would remove the need to handle the ssh key through the now present ssh transport. But still, you won't be able to run drush from the host and sync between 2 remotes, because drush will see the vm alias as a remote. For vagrant, you can have an option to run commands prefixed with vagrant ssh -c. Unless the vm is not started, there's no problem with that, otherwise the vm won't be working at all if that connection is broken. |
There are very few BLT commands that are tightly coupled to anything inside the VM -- namely Drupal installs and updates. Pretty much every other BLT command can be run the same (if not better) on the host, right? If that's true, then redispatching the entire BLT CLI via When BLT sets up a VM, it already generates a VM-aware Drush alias. You'd just need to set this as your default local alias. And BLT would need to remove all of its nasty warnings about running on the host. Does anyone see a problem with that? I know it's not ideal to run things like npm or composer on the host since you might run into issues with version mismatches, but it's so much faster that way, and I think it would be better to encourage people to use And if anyone really loves waiting on Composer to update dependencies on NFS (barf), well they can still do things the old way by simply keeping the local drush alias as 'self'. We'll document the pros and cons of both options. |
I think you still want to run npm and the frontend commands inside the VM, because node-sass, for example, has OS specific dependencies and blows up until you go into the VM and rebuild. ETA: Unless all that can be done exclusively on the host: basically all of it needs to happen either on the host or the VM. |
Yeah, I would advocate for doing it all on the host. It's marginally less safe, maybe, if you aren't good about enforcing NPM versions. But so much faster and cleaner (NPM complaints violently about running on NFS). I'm open to other opinions though. |
The only problem I see is that I often see the prompt where I am told a blt command should be run inside the vm, but I still get the option to run it outside, which is confusing and slowing you down. If we can get rid of that prompt and just do the right thing, run it in the vm or outside, I think that fixes this ticket. |
I created #3613 to start testing this. I'm sure there are edge cases we haven't considered which is why I want to keep this a hidden-ish feature to start. Once it's shaken out a bit, we can fully document it (i.e. how and why to choose to run blt inside or outside the vm, maybe even make outside the default, etc...) |
User Story
As a user of BLT, I want to run BLT commands from my host environment so that I don't have to keep ssh'ing into the VM.
Discussion
In BLT 8x, we allowed users to run blt commands from their host environment. That feature was dropped in BLT 9x and users are now required to ssh into their VM to run most commands. That is an impediment to the development process and we've gotten pretty dissed for going that way. Let's reverse course and go back to allowing blt commands from the host machine.
The text was updated successfully, but these errors were encountered: