Skip to content

Conversation

drzraf
Copy link
Contributor

@drzraf drzraf commented Nov 6, 2024

Could be set to use /custom/path/wp on the remote end but also sudo -u user /some/wp to allow running wp under a distinct user.

See also #5974

@drzraf drzraf requested a review from a team as a code owner November 6, 2024 17:19
@mrsdizzie
Copy link
Member

I don't use this feature so this is more just a comment, but the existing documentation already recommends using an alias for wp for this specific case:

https://make.wordpress.org/cli/handbook/guides/running-commands-remotely/#alias-wp-to-php-which-runs-the-wp-cli-binary

alias wp="php ~/bin/wp"

So that case of "let the remote user specify what wp is" seems already covered by existing practices.

@drzraf
Copy link
Contributor Author

drzraf commented Nov 15, 2024

So that case of "let the remote user specify what wp is" seems already covered by existing practices.

non-interactive mode is not firing a "login-shell". ~/.bashrc isn't read and the aliases it may contain are not defined.

@mrsdizzie
Copy link
Member

mrsdizzie commented Nov 15, 2024

This is covered in the sections above on that same link:

https://make.wordpress.org/cli/handbook/guides/running-commands-remotely/#configure-the-remote-non-interactive-shell-to-resolve-aliases

Mostly just trying to gauge if this addresses a real problem that in some cases isn't possible with current advice -- ie: is there a situation where you can set an ENV var on remote but can't do the steps above? Or if it is just another way to accomplish that.

@drzraf
Copy link
Contributor Author

drzraf commented Jan 20, 2025

It addresses the problem in a way that doesn't need any hook nor modification on the remote server (like .bashrc to add aliases), either because:

  • These are not available
  • It's undesirable (because it need to work for multiple users with distinct .bashrc)
  • Because it's cumbersome to enable alias expansion, just to set on wp alias just to run wp with sudo under another user.

(and the diff in the codebase is just one-line)

@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Runner.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mrsdizzie
Copy link
Member

I think WP_CLI_BINARY is too vague because it is only used in SSH context with this PR. We already have WP_CLI_SSH_PRE_CMD so maybe this could be WP_CLI_SSH_BINARY / WP_CLI_SSH_REMOTE_BINARY / WP_CLI_SSH_REMOTE_WP_BINARY

Suggesting because these should also end up documented here in the list of all available ENV Vars that WP CLI supports and every other use of WP_CLI_XXX is for the local version, not the remote.

@drzraf
Copy link
Contributor Author

drzraf commented Apr 24, 2025

I'm fine renaming it for whatever gets your preference. Just let me know.

@schlessera schlessera mentioned this pull request Apr 29, 2025
47 tasks
@mrsdizzie
Copy link
Member

WP_CLI_SSH_BINARY seems fine to me (can add documentation separately)

@mrsdizzie mrsdizzie added this to the 2.12.0 milestone Apr 29, 2025
…o `sudo -u user /some/wp` would also allow running remote `wp-cli` under a distinct user
@drzraf drzraf force-pushed the wp-custom-binary branch from ff9677b to 6c736ef Compare April 29, 2025 23:39
@mrsdizzie mrsdizzie merged commit 98e8ec8 into wp-cli:main Apr 30, 2025
50 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants