Skip to content
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

General hello world review (some bugs) #2

Open
simesy opened this issue Jan 27, 2024 · 9 comments
Open

General hello world review (some bugs) #2

simesy opened this issue Jan 27, 2024 · 9 comments

Comments

@simesy
Copy link

simesy commented Jan 27, 2024

All of the sites that I have setup locally are hosted in different places for different clients (Platform.sh, Lagoon, etc), and I generally have a drush command that I can run on my host regardless of whether the local development environment (ddev, lando, etc, yes i use multiple) is running.

So my goal of using ash is to exectute a command on a remote site regardless of what i'm working on locally.

Setup

When i installed with composer globally, the I had to modify the PATH, and add: export PATH="~/.composer/vendor/bin:$PATH" rather than export PATH="$HOME/.config/composer:$PATH". I don't have a $HOME/.config directory.

I also had to add the directory ~/.ash because adding the initial site aliases resulted in this error. This went away when i manually added the directory.

Warning: file_put_contents(/Users/hobbss/.ash/foo.site.yml): Failed to open stream: No such file or directory in /Users/hobbss/.composer/vendor/jonpugh/ash/src/Cli/Commands/SiteCommands.php on line 195

After I'd added a couple of sites I get two files which looks pretty good:

~$ cat ~/.ash/foo.site.yml
default:
    root: /Users/hobbss/_/sites/foo

I then followed the advice to Call 'ash @foo' to access the site, so i swtiched to my home directory and ran it

~$ ash @foo
PHP Deprecated:  preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /Users/hobbss/.composer/vendor/consolidation/site-process/src/Util/Escape.php on line 49

But all that said, ash ls now shows me 6 aliases (expected).

Running a command

In one of my projects there is a site alias file ./drush/sites/self.site.yml that points to a Platform.sh environment and it looks like this:

prod:
  host: ssh.au.platform.sh
  user: redacted-main-redacted--drupal
  uri: 'https://frees.au'
  root: /app/web
  paths:
    drush-script: /app/vendor/bin/drush

And normally I can run it like this from the codebase that contains the alias.

$ ./vendor/bin/drush @prod st
Drupal version   : 10.1.6
Site URI         : https://frees.au
DB driver        : mysql
DB hostname      : database.internal
DB port          : 3306
...

So the goal is to run it from another location. However, when i run it with ash, I get this error:

$ ash site:exec @ash.fs-web.prod st
env: ‘st’: No such file or directory
 [error]  The command "ssh -o PasswordAuthentication=no redacted-main-redacted--drupal@ssh.au.platform.sh 'cd /app/web && env DRUSH_OPTIONS_URI=https://frees.au PATH=./vendor/bin:./bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: st'" failed.

Exit Code: 127(Command not found)

Working directory: /app/web

Output:
================
Error Output:
================
env: ‘st’: No such file or directory
@simesy simesy changed the title General feedback General hello world review (some bugs) Jan 27, 2024
@jonpugh
Copy link
Owner

jonpugh commented Jan 27, 2024

It doesn't pass to drush automatically.

Try ash @site drush st instead

@jonpugh
Copy link
Owner

jonpugh commented Jan 27, 2024

Also, the "ash" part of the alias is not required.

You can just use @site.env.

@simesy
Copy link
Author

simesy commented Jan 27, 2024

These all have the same error:

ash site:exec @ash.fs-web.prod drush st
ash site:exec @fs-web.prod drush st
ash @ash.fs-web.prod drush st
ash @fs-web.prod drush st

@simesy
Copy link
Author

simesy commented Jan 27, 2024

I'm assuming that it can't find the drush executable in the codebase

Error Output:
================
env: ‘drush’: No such file or directory

Is there an assumption about how drush is in the path once in that directory?

@simesy
Copy link
Author

simesy commented Jan 27, 2024

I'm debugging locally as i'm sure there's something about my setup

@simesy
Copy link
Author

simesy commented Jan 27, 2024

When i run it natively, the executed command is:

ssh -t -o \
  PasswordAuthentication=no \
  redacted-main-redacted--drupal@ssh.au.platform.sh \
  '/app/vendor/bin/drush st -vvv --uri=https://frees.au'

When i run it with ash the executed command is:

ssh -o \
  PasswordAuthentication=no \
  redacted-main-redacted---drupal@ssh.au.platform.sh \
  'cd /app/web && env DRUSH_OPTIONS_URI=https://frees.au PATH=./vendor/bin:./bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: drush st'

Note that my alias uses the paths: drush-script: /app/vendor/bin/drush which doesn't seem to be picked up when using ash.

@jonpugh
Copy link
Owner

jonpugh commented Jan 27, 2024

It is just execs whatever is after the alias.

You can try ash @s which drush to figure it out

@jonpugh
Copy link
Owner

jonpugh commented Jan 27, 2024

Ash runs in your alias root, which can be "web" or just git root.

The command will be relative to that.

So change your alias root or figure out how to change path to composer bin path.

@simesy
Copy link
Author

simesy commented Jan 27, 2024

I guess i'm a bit confused at this point with all the various contexts ash/local/remote, and can't help but think i'm using it in a way that it isn't designed for.

ash site:exec @fs-web 'which drush'

PHP Deprecated:  preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /Users/hobbss/.composer/vendor/consolidation/site-process/src/Util/Escape.php on line 49

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /Users/hobbss/.composer/vendor/consolidation/site-process/src/Util/Escape.php on line 49
env: which drush: No such file or directory
 [error]  The command "env DRUSH_OPTIONS_URI= PATH=./vendor/bin:./bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: 'which drush'" failed.

Exit Code: 127(Command not found)

(if i don't quote the command i get ERROR: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /Users/hobbss/.composer/vendor/consolidation/site-process/src/Util/Escape.php:49

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

No branches or pull requests

2 participants