When running this command from root it returns with a command not found.

drupal lightning:subprofile

Comments

AverilL created an issue. See original summary.

AverilL’s picture

Issue summary: View changes
balsama’s picture

Hi. Do you actually have Lightning installed when you try to run that command? An unfortunate characteristic of DrupalConsole is that the providing extension actually needs to be enabled for DC to find it.

jmolivas’s picture

@balsama @AverilL Latest DrupalConsole allows you to load commands when Drupal is not installed I will check the command registration and try this new feature.

AverilL’s picture

@Balsama Yes Lightning is installed.

AverilL’s picture

More information which may be useful.

I have lightning installed in a drupalVM on nginx.

jmolivas’s picture

@balsama @AverilL I did some research last night. So far this is what I found:

Lightning is loading commands as services using lightning.services.yml this file is only loaded when the profile is installed.

DrupalConsole allows you to provide commands on modules & themes but the same issue is present.

I did some code changes on DrupalConsole to load commands from profile when drupal is not installed
https://patch-diff.githubusercontent.com/raw/hechoendrupal/drupal-consol...

As you can see I am loading `console.services.yml` instead of `lightning.services.yml` this is done to avoid breaking the site trying to load services from DrupalConsole classes if DrupalConsole is not downloaded on the site. I can send a PR to lightning adding this new file and moving service definition.

I still have two issues to fix
* DrupalConsole: Create and inject console.translator_manager Interface instead of concrete class.
* Lightning:
* Command is trying to load Drupal services like `info_parser` but not available. (we can try $this->infoParser = new \Drupal\Core\Extension\InfoParser(); and see if it works)
* Command is trying to load ComponentDiscovery class but class no loaded since profile is not installed autoloader is not loading profile/src files. (I can autoload all of the profile files same as I did with the Commands)

jmolivas’s picture

I loaded the ComponentDiscovery.php manually and get the command to work and I was able to generate a profile when Drupal is not installed.

I still need to check why loading the src directory breaks the execution.

jmolivas’s picture

I found the ofending class was `src/Task/SetXMLPropertyTask.php`

What I found about this class:
* Do not contains a namespace declaration.
* Contains a require_once 'phing/Task.php'; call.

btully’s picture

Any update or workaround for this?

drupal lightning:subprofile --root=./docroot

 [ERROR] Command "lightning:subprofile", is not a valid command name.
phenaproxima’s picture

@btully: If you can, try running the command from within docroot. Does that help?

firstlut’s picture

Switching to docroot/ didn't help me.

However, I noticed that Lightning's composer.json file has a strict version constraint on Drupal Console (1.0.1). Wouldn't that keep all the fixes Jesus added upthread from taking effect?

Also, why would you limit DC like that? What's the reasoning, or was this unintentional?

phenaproxima’s picture

Fear not! We recently removed the constraint from Lightning, so it will be possible to use the latest version of Drupal Console as of the next release. It had been pinned to 1.0.1 due to old problems with our internal testing infrastructure, which have long since been resolved. :)

firstlut’s picture

Well, I jumped ahead and updated Drupal Console, and the command still doesn't show up, in either project or docroot. I'm attempting to use it before installation of the site.

Any other helpful hints?

phenaproxima’s picture

As @jmolivas suggests in #9, try removing SetXMLPropertyTask.php. Does that help? If so, we'll try to remove that in the next release. It is not used by Lightning or Drupal in any way; it's just an artifact from when we were using Phing to power our internal build scripts.

phenaproxima’s picture

I tested this today. Unfortunately, it is not resolved.

I changed SetXMLPropertyTask.php to look like this:

<?php

@trigger_error('SetXMLPropertyTask is deprecated and will be removed from Lightning.', E_USER_DEPRECATED);

class SetXMLPropertyTask {

  public $file;
  public $element;
  public $attribute;
  public $value;

  public function setFile($file) {}
  public function setElement($element) {}
  public function setAttribute($attribute) {}
  public function setValue($value) {}
  public function main() {}

}

With Drupal Console 1.8.0 installed, and Lightning not installed (but set up in a proper docroot with all dependencies), I ran:

vendor/bin/drupal lightning:subprofile

And I got this error:

[ERROR] Command "lightning:subprofile", is not a valid command name.

I'm at a bit of a loss for what to do here.

balsama’s picture

Status: Active » Closed (cannot reproduce)

This is now tested as part of our CI process.

Lightning needs to be installed and the command line needs to be able to talk to the database for this command to work. To verify, run the following command:

$ drupal site:status
You should see the following in the output:

System Info
 Drupal                                     8.6.0-rc1                                                                                                                      
 Installation profile                       Lightning (lightning-8.x-N.N)

and Database connection with your database connection details listed.

If you are using a virtual machine, you will need to run the Drupal Console commands from within the VM.