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

0.7.5: no response when in drupal directory #565

Closed
Mark-L6n opened this issue Apr 5, 2015 · 25 comments
Closed

0.7.5: no response when in drupal directory #565

Mark-L6n opened this issue Apr 5, 2015 · 25 comments

Comments

@Mark-L6n
Copy link

Mark-L6n commented Apr 5, 2015

I have Drupal beta 9 and beta 7 installations.
With console 0.7.4, I could be in the root directory of either and console worked fine.
I just replaced console with version 0.7.5: it works fine in all directories but the beta 9 and beta 7 directories: nothing happens, there is no default help display nor any error message; the linux prompt simply quickly reappears. Trying drupal -V, drupal help or drupal list gives the same results.
I didn't see anything in a php error file.
Any idea what could be happening?

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

I tested v0.7.5 on Beta9 and --version, help and list works fine inside and outside of the drupal root.

Console should work on Beta9 since we only support latest beta release, not sure about Beta7.

@weaverryan
Copy link

@jmolivas I also have absolutely no output with Beta9 and 0.7.5 when I'm inside a Drupal install. Outside a D8 install, I can run php console.phar and get the normal list output, but inside, I get nothing for any command. error reporting is on, so if there were some sort of error, I should see it.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

If drupal is not installed you should see the following error message
In order to list all of the available commands you should install drupal first.

If drupal is already installed you should see the Available commands list.

I am attaching a video with the steps I follow to get the Drupal8 beta9 and the 0.7.5 version of this project in my local machine:

drupal-console-d8-beta9

How did you guys @Mark-L6n @weaverryan get the 0.7.5 version of the project ?

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 6, 2015

Thanks for the responses, @jmolivas. Here is some info on my setup:

  • Mac OSX 10.10.2, using a Vagrant Box created with PuphPet, using CentOS 6 x64, PHP 5.4
  • Drupal betas downloaded from drupal.org/download, installed with standard web interface
  • Console installed with instructions at http://drupalconsole.com/:
    • $ curl -LSs http://drupalconsole.com/installer | php
    • $ mv console.phar /usr/local/bin/drupal

When not in a drupal root directory, I get that message In order to list all of the available commands you should install drupal first. after the Usage/Options/Available Commands info.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

We need to have a better message when not in a drupal directory something like:
In order to list all of the available commands, you should run this inside a drupal root directory.

What does console show when inside a drupal root @Mark-L6n ?

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 6, 2015

In console 0.7.4, much more information would show up.
Now with 0.7.5, nothing at all: just the same as if you'd press enter on an empty command line. Since the behavior is different, it's apparent the program identifies that it's in a drupal directory, before exiting without any messages. It's surprising that even drupal -V and drupal help don't work—make's it appear that they're trying to load/read info about the Drupal install and fail somehow.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

I just updated the project to show this message when executing outside a d8 root dir

In order to list all of the available commands, you should run this inside a drupal root directory.

screen shot 2015-04-06 at 12 44 00 pm

When executing console inside a d8 dir but drupal no installed yet

In order to list all of the available commands you should install drupal first.

screen shot 2015-04-06 at 12 45 35 pm

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 6, 2015

Sounds like a good update. Further questions: will Console commands such as drupal generate:module work if you are not in a Drupal root directory? If you have multiple Drupal installs, will it work on whichever Drupal root you are in?
Also, when downloading Console with $ curl -LSs http://drupalconsole.com/installer | php, will it

  1. download the most current version, or
  2. download the version at the most recent tag (now 0.7.5)?

If 2), is there a way to download the most current version?

jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 6, 2015
@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

At this point Console only works inside a drupal root directory, since DrupalCore is bootstrapped in order to access service container.

We are planning to:
a) Add commands to work outside of a Drupal root like site:install
b) Add support for site aliases.

When downloading Console using the installer $ curl -LSs http://drupalconsole.com/installer | php you get the latest tagged version at this time 0.7.5

In order to get the most current version you need to fork this repo.

Instructions to fork, clone & get 3rd party libraries using composer at:
http://hechoendrupal.gitbooks.io/drupal-console/content/how-to-contribute/getting-the-project.html

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

I just merged the PR containing this fix
#566

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 6, 2015

Thanks! Maybe for now it would be good to change the message:

In order to list all of the available commands, you should run this inside a drupal root directory.

to something like:

Drupal Console needs to be run from a Drupal root directory.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

@Mark-L6n related to you previous question

If you have multiple Drupal installs, will it work on whichever Drupal root you are in?

Since you can have Console available system-wide moving the executable console.phar to a global accesible path using:

$ mv console.phar /usr/local/bin/drupal

Yes drupal will work with multiple Drupal installations

@weaverryan
Copy link

Hey @jmolivas

I think we should re-open this, but I have more information now (was short on time). To repeat this bug, you may need to delete the /.console/config.yml file from your home directory. I don't have this file, and that's key to the error. What happens is:

  1. UserConfig::mergeConfig is called. But I DON'T have a "user config", so I don't hit the if statement that sets $this->config, which means that the $config property is null - it is NOT populated with the defaults from the config.yml at the root of the DrupalAppConsole project

  2. Application::__construct sets the env property from the config, but this is now set to null.

  3. In KernelHelper::bootKernel, that null (blank string) environment is passed into DrupalKernel::createFromRequest. Later, when $kernel->boot() is called, it just dies. If I manually set $this->environment to dev or prod, it works. But for some reason, it being empty just borks everything.

I hope this helps! As soon as I create a ~/.console/config.yml with anything in it, everything starts working perfectly.

Cheers!

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 6, 2015

More experimentation:

  1. Unsurprising: I downloaded the v0.7.4. console.phar from https://github.com/hechoendrupal/DrupalAppConsole/releases and everything still worked fine on my system, while v0.7.5 still didn't work.
  2. Surprising: I made a 2nd clean install of Drupal Beta 9, and v0.7.5 works with that!
  3. Unsurprising: Only difference between the 2 installs were custom modules. Copied them over and system was borked. Deleted them, still borked. Cleared cache, v0.7.5 OK.
  4. Surprising: The solution was annoyingly simple: clear cache! v0.7.5 works now.

So, after upgrading Drupal Console, you need to go into the Drupal installations that used it, and clear cache.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

@weaverryan I think implementing something like this in order to fix the issue

    protected function mergeConfig()
    {
        $baseConfig = $this->getBaseConfig();
        $userConfig = $this->getUserConfig();

        $this->config = array_replace_recursive($baseConfig, $userConfig);
    }

    protected function getBaseConfig()
    {
        if (file_exists(__DIR__ . '/../config.yml')) {
            return $this->readYamlFile(__DIR__ . '/../config.yml');
        }

        return [];
    }

    protected function getUserConfig()
    {
        if (file_exists($this->getUserHomeDir() . '/.console/config.yml')) {
            return $this->readYamlFile(
              $this->getUserHomeDir() . '/.console/config.yml'
            );
        }

        return [];
    }

I will send an merge a PR and tag a new release for today.

@jmolivas
Copy link
Member

jmolivas commented Apr 6, 2015

Also I am planning to:

a) Copy the config.yml at https://github.com/hechoendrupal/DrupalAppConsole/tree/master/config/dist
to user home directory when running the installer.

b) Add an init command to copy if command was installed via composer or downloaded directly from releases page.

@weaverryan
Copy link

@jmolivas 👍 for the fix! About the copying of config.yml into the user home directory, I think this probably makes sense, assuming you can consistently do this for all users, including our Windows friends :). But yea, I can definitely see how it might be helpful to modify those options by editing a file, versus creating a new one.

I'll be using the console tomorrow during a training, so I'm happy that I'll be able to get things work just fine (I'll have them create their user config.yml file to avoid issues).

Cheers!

@jmolivas
Copy link
Member

jmolivas commented Apr 7, 2015

  • I am planning to tag a new release today, I added a new command init
    screen shot 2015-04-06 at 7 49 30 pm

@jmolivas
Copy link
Member

jmolivas commented Apr 7, 2015

  • InitCommand.php source code
<?php
/**
 * @file
 * Contains \Drupal\AppConsole\Command\InitCommand.
 */
namespace Drupal\AppConsole\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;

class InitCommand extends ContainerAwareCommand
{

    private $files = [
      [
        'source' => 'config/dist/config.yml',
        'destination' => 'config.yml'
      ],
      [
        'source' => 'config/dist/chain.yml',
        'destination' => 'chain/sample.yml'
      ]
    ];

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
          ->setName('init')
          ->setDescription($this->trans('commands.init.description'))
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $application = $this->getApplication();
        $config = $application->getConfig();
        $message = $this->getHelperSet()->get('message');
        $basePath = __DIR__ . '/../../';
        $userPath = $config->getUserHomeDir() . '/.console/';
        $copiedFiles = [];

        foreach ($this->files as $file) {
            $source = $basePath . $file['source'];
            $destination = $userPath . '/' . $file['destination'];
            if ($this->copyFile($source, $destination)) {
                $copiedFiles[] = $file['destination'];
            }
        }

        if ($copiedFiles) {
            $message->showCopiedFiles($output, $copiedFiles);
        }
    }

    public function copyFile($source, $destination)
    {
        if (file_exists($destination)) {
            return false;
        }

        if (!is_dir(dirname($destination))) {
            mkdir(dirname($destination));
        }

        return copy(
          $source,
          $destination
        );
    }
}

jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
jmolivas added a commit to jmolivas/drupal-console that referenced this issue Apr 7, 2015
@jmolivas
Copy link
Member

jmolivas commented Apr 7, 2015

New init command added @weaverryan PR merged.

@jmolivas jmolivas added the fixed label Apr 7, 2015
@jmolivas
Copy link
Member

jmolivas commented Apr 7, 2015

@jmolivas jmolivas closed this as completed Apr 7, 2015
@weaverryan
Copy link

I had an entire group of people install the DrupalConsole this morning and nobody had any issues at all. Thanks for the fast fix AND tag @jmolivas!

@jmolivas
Copy link
Member

jmolivas commented Apr 7, 2015

Awesome I am glad it works.

Are you planning to have a training tomorrow @weaverryan ?

We are planning to rename the repo name and don't want to create confusion, you can see the issue at: #571

@weaverryan
Copy link

I noticed that - no issues for me, all done with training for now. The suggestion for the name change came from the training (best place for feedback) - I said DrupalAppConsole, and people found dupalconsole.com and wondered if it was the same. So, I think it's a good change.

Thanks!

@Mark-L6n
Copy link
Author

Mark-L6n commented Apr 8, 2015

Works for me too!
Turns out the 'clear cache' suggestion I had above had to be redone after every Drupal Console command, so the fix is great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants