lando / wordpress

The Official WordPress Lando Plugin
https://docs.lando.dev/wordpress/
GNU General Public License v3.0
13 stars 6 forks source link

WordPress recipe identifies/behaves as Laravel #17

Closed matpratta closed 2 years ago

matpratta commented 2 years ago

Lando Version: v3.6.5

Noticed that bug while writing a getting started guide to Lando, if you take a WordPress recipe (freshly initialized via lando init) and try running lando wp it won't work, but show a list of commands that belong to the Laravel plugin instead:

~
➜ mkdir lando-wp

~
➜ cd lando-wp

~/lando-wp
➜ lando init
? From where should we get your app's codebase? current working directory
? What recipe do you want to use? wordpress
? Where is your webroot relative to the init destination? .
? What do you want to call this app? my-lando-app

   _  __                       _
  / |/ /__ _    __  _    _____( )_______
 /    / _ \ |/|/ / | |/|/ / -_)// __/ -_)
/_/|_/\___/__,__/  |__,__/\__/ /_/  \__/

  _________  ____  __ _______  _______  _      ______________ __  ___________  ______
 / ___/ __ \/ __ \/ //_/  _/ |/ / ___/ | | /| / /  _/_  __/ // / / __/  _/ _ \/ __/ /
/ /__/ /_/ / /_/ / ,< _/ //    / (_ /  | |/ |/ // /  / / / _  / / _/_/ // , _/ _//_/
\___/\____/\____/_/|_/___/_/|_/\___/   |__/|__/___/ /_/ /_//_/ /_/ /___/_/|_/___(_)

Your app has been initialized!

Go to the directory where your app was initialized and run lando start to get rolling.
Check the LOCATION printed below if you are unsure where to go.

Oh... and here are some vitals:

 NAME      my-lando-app
 LOCATION  /home/matt/lando-wp
 RECIPE    wordpress
 DOCS      https://docs.lando.dev/config/wordpress.html

~/lando-wp took 6s
➜ lando wp
Usage: lando <command> [args] [options]

Commands:
  lando artisan           Runs artisan commands
  lando composer          Runs composer commands
  lando config            Displays the lando configuration
  lando db-export [file]  Exports database from a database service
                          to a file
  lando db-import <file>  Imports a dump file into a database
                          service
  lando destroy           Destroys your app
  lando info              Prints info about your app
  lando init              Initializes code for use with lando
  lando laravel           Runs laravel commands
  lando list              Lists all running lando apps and
                          containers
  lando logs              Displays logs for your app
  lando mysql             Drops into a MySQL shell on a database
                          service
  lando php               Runs php commands
  lando poweroff          Spins down all lando related containers
  lando rebuild           Rebuilds your app from scratch, preserving
                          data
  lando restart           Restarts your app
  lando share             Shares your local site publicly
  lando ssh               Drops into a shell on a service, runs
                          commands
  lando start             Starts your app
  lando stop              Stops your app
  lando version           Displays the lando version

Options:
  --channel       Sets the update channel
                         [array] [choices: "edge", "none", "stable"]
  --clear         Clears the lando tasks cache             [boolean]
  --experimental  Activates experimental features          [boolean]
  --help          Shows lando or delegated command help if
                  applicable                               [boolean]
  --verbose, -v   Runs with extra verbosity                  [count]

Examples:
  lando start            Run lando start
  lando rebuild --help   Get help about using the lando rebuild
                         command
  lando destroy -y -vvv  Run lando destroy non-interactively and
                         with maximum verbosity
  lando --clear          Clear the lando tasks cache

Did you mean php?

~/lando-wp
➜

The contents of my Landofile seem to be correct, too:

~/lando-wp
➜ cat .lando.yml
name: my-lando-app
recipe: wordpress
config:
  webroot: .
matpratta commented 2 years ago

Okay, I think there's two issues going on here.

First, the CLI would not be installed before I properly ran lando rebuild, this is the same I had with the Laravel recipe, seems like Lando is not initializing anything after running lando init

Second, more odd, bug: the recipes are being cached by Lando and not being fetched from the current directory. So what happens is, if I was working in a directory A with Laravel and switch to directory B with WordPress, Lando will not pick this change and will still behave as if it was working with Laravel, requiring me to run lando rebuild to pick up the change. Now if I go back to directory A it will still see as WordPress from directory B.

gitressa commented 2 years ago

You probably need to run lando start also to get everything running. lando init just sets the parameters. For more, see for example https://docs.lando.dev/wordpress/getting-started.html#quick-start

labboy0276 commented 2 years ago

Seems like its an issue with your machine. Could be confusion with the containers or a name space collision.

I would try purging everything and starting over. https://docs.lando.dev/help/purging-containers.html

gitressa commented 2 years ago

But isn't the real problem that they both share the same name my-lando-app and that lando start isn't run?

matpratta commented 2 years ago

@gitressa @labboy0276 yeah seems like the Lando CLI has some sort of cache where it will store what recipe it last used based on the project name (good catch there!). Running lando start or lando rebuild seems to update this cache and things work just fine, just found it a bit odd when trying to figure out what I did wrong lol

Anyways, I ended up opening an Issue regarding this on the CLI repo earlier, I think it belongs there so I'm closing this one...

Thanks for the help!

gitressa commented 2 years ago

Great that you got it working @MatheusMK3! Normally lando init is followed immediately by lando start (see for example https://docs.lando.dev/wordpress/getting-started.html#quick-start) since all init does is create the .lando config file, but doesn't start Lando.

I sometimes forget to start a Lando instance myself, so I usually create them with this one-liner, to make sure I don't forget it:

$ lando init --recipe drupal9 --name drupal9 --source cwd --webroot web && lando start