-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Redispatch to site-local drush if it exists #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redispatch to site-local drush if it exists #1138
Conversation
…es/all/drush. (i.e., path to drush executable should be ROOT/drush/drush/drush or ROOT/sites/all/drush/drush/drush.)
One minor error -- stuff is getting executed in simulated mode in some instances. Will fix it shortly (but not right now). |
I'm hesitant to go down this road. The PR is clever, but I'm wary.
This also overlaps with site aliases. Would a redispatch happen today if you call |
I agree that we should look in vendor, and get rid of the references to ROOT/drush and sites/all/drush. Today, %drush-script is ignored unless the invocation is remote. We could change this.
|
The solution I suggested above introduces inconsistent behavior depending on whether you are using aliases or --root / cwd. This isn't good, as an alias is supposed to just be a collection of configuration. A better idea: If the user sets drush-script, either via %drush-script in an alias, or via a drush-script option in a site-local configuration file, then set --local and redispatch to drush. Skip the redispatch if --local is set, or if drush-script points to the same executable that is currently running. |
The commit above removes the "magic locations", and instead depends on 'drush-script' set in a drushrc.php file or site alias. |
…ches, as this interferes with the --local option. We will still set 'propagate-cli-value', so that explicit --config options are still forwarded.
The one failing test right now is testShellAliasDrushRemote(). With my change, the cli value is passed to the remote invocation of Drush, whereas previously it was not. This reveals a basic problem. Given the following example:
The way Drush works today, --config specifies a local configuration path. Since the configuration path is local, it is never passed on to the remote side. However, what if you want to explicitly pass a remote config path from the cli, to send to the remote Drush? There is currently no way to do this. I don't recall anyone ever asking for this feature in all of the years that Drush has behaved this way, so I'm going to adjust the commit above appropriately, so that config paths are never propagated locally (as they currently are--a bug, I think) or remotely. If anyone thinks we need a --remote-config option or anything like that, please chime in. |
Never propagate is not the right thing; the unit tests presume that --config is propagated locally, and folks are likely depending on this behavior as well. |
…nfig option to be propagated. Maintain current behavior, and do not propagate --config remotely. Fix problem where paths to local config files discovered during bootstrap (not from the cli option) were propagated.
…ns, as Drush uses this info elsewhere, not just in backend invoke.
Okay, now https://travis-ci.org/drush-ops/drush/jobs/49215825 fails because it expects --config to be passed to remote systems. I guess Drush was inconsistent here. Thoughts on how this should work? I want to turn off propagation of discovered configuration paths, but we can either propagate, or not propagate --config on the cli to the remote system. If we propagate it, then it will apply to both the local and remote system. Of course, there is no harm if the propagated path does not exist in one place. Perhaps I should just roll back to the first version, where --config from the cli is consistently propagated, and fix the unit tests to reflect that. Any comments on the behavior of the rest of this PR? I think it's about ready to go in, once we make a decision about how --config should work. |
…al options, as Drush uses this info elsewhere, not just in backend invoke." This reverts commit c02f446.
…cli --config option to be propagated. Maintain current behavior, and do not propagate --config remotely. Fix problem where paths to local config files discovered during bootstrap (not from the cli option) were propagated." This reverts commit 40859f7.
This reverts commit 8ab1484.
Put this back so that --config cli options are remotely propagated, consistently now, and fixed tests to reflect this. I'd like to commit this PR like this, if the general strategy looks sound. |
As for --config, I think there are use cases for passing it to remote sites and use cases for not doing so. Could we have --config which does not pass along and --config-remote which does? The PR looks fine now but I admit I'm still a bit wary of recommending this. Do you have a need for this? At a high level, I think redispatch is confusing for people and for us to help them. Specifically, the logs get really verbose and confusing when there are two preflights and postflights. So this encourages a practice which I dont love. I'd love for something else to call into the local Drush, not the global drush. I'm happy to discuss this and other issues by phone anytime this week. |
Yes, let's talk on the phone sometime. Some analysis and brainstorming about possible alternate solutions. Feel free to alter the base assumptions, if you have any ideas for simplifications that make this better. Drush Bootstrapping
Characteristics of the redispatch code, as it exists today
Consideration: Could we autoload from the selected Drupal site, instead of redispatching?
Consideration: Could we make a tool that is not Drush that launches Drush after site selection?
Preliminary conclusion: I don’t think that we can make the code much better by changing the redispatch technique unless we remove desirable features (e.g. drush @site …). The flexibility of using Drush as the Drush launcher means that we don't need to solve the problem of what to do for commands that do not have a site, or sites that do not have a site-local Drush. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to grab from GLOBALS here? Maybe drush_build_drush_command() is helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thanks; I was lazy and then forgot to go back and fix it. I'll improve it in the next commit.
Committed this from another branch (to clean up the reverts), and fixed the GLOBALS thing. |
This was actually very simple.
Drush already has a redispatch mechanism in place for calling remote drush commands (e.g. "drush @Remote cc all"). This patch leverages this mechanism, and redispatches to a site-local Drush if it exists.
The paths checked for local Drush installations are ROOT/drush, and ROOT/site/aliases/drush. So, the actual path to the local Drush executable should be ROOT/drush/drush/drush, or ROOT/site/aliases/drush/drush/drush.
If there isn't a site-local drush installed, then this patch should have no affect on existing code -- but we'll see what Travis and our unit tests have to say about that.