Drupal-console: Bad path to /vendor/drupal/console-core/services.yml after console update

Created on 6 Oct 2016  路  51Comments  路  Source: hechoendrupal/drupal-console

I have DC globally installed with composer, was working fine before rc2. I've updated to rc4 and composer updated the project drupal console to rc4 as well, but still broken.

Project structure:
composer_root
- vendor
- web

outside web, "drupal list" gets the outside-root directory available commands list.
Inside, it throws this error:
The file "composer_root/web//vendor/drupal/console-core/services.yml" does not exist. in SymfonyComponentConfigFileLocator->locate()

Of course, the correct path is composer_root/web/../vendor/drupal/console-core/services.yml

console seems to know that "web" is the drupal webroot, but how can I tell it that it needs to go up a level to find the vendor directory?

And what is calling for services.yml? I don't grep that in ~/.console

Hacktoberfest bug

Most helpful comment

@ransomweaver @dustinleblanc @finnef @Lendude
can you confirm there is no composer.json file on your web directory?

I saw that happening on https://github.com/dustinleblanc/veccs/tree/master/web having a composer.json files that makes this validation to fail
https://github.com/hechoendrupal/DrupalConsole/blob/master/bin/drupal.php#L29

All 51 comments

+1 same here

@ransomweaver @finnef Starting on RC releases, DrupalConsole should be installed per site to avoid any issues with components and to support different versions of Drupal.

I tried calling the locally installed version using ../vendor/drupal/console/bin/drupal from the web dir, but the same result.
(local version installed using composer)

@finnef is you site based on DrupalComposer?

@finnef Try this:

cd web/
../vendor/bin/drupal

drupal-composer-drupal-console

@finnef which version of DrupalConsole you have installed on the site?

You can by use composer to find out

> composer show | grep drupal/console

drupal/console                        1.0.0-rc4 The Drupal Console is a CLI too...
drupal/console-core                   1.0.0-rc4 Drupal Console Core
drupal/console-en                     1.0.0-rc1 Drupal Console English Language

@jmolivas I will try this when I'm back at my machine, but AFAIK vendor/bin/drupal is just an alias to vendor/drupal/console/bin/drupal...

Just tried this using the same project repo as finnef, and still gives me
InvalidArgumentException: The file "/Applications/MAMP/htdocs/ucytech/web//vendor/drupal/console-core/services.yml" does not exist. in SymfonyComponentConfigFileLocator->locate() (line 44 of /Applications/MAMP/htdocs/ucytech/vendor/symfony/config/FileLocator.php).

@jmolivas I had a working install on 1.0.0-beta5, and this problem started when updating to 1.0.0-rc4, but this included some other updates, including drupal 8.2rc-x. Maybe I should try 8.2GM, should be out since yesterday :-)

@jmolivas

composer show | grep drupal/console

drupal/console 1.0.0-rc4 The Drupal Console is a CLI tool to generate boilerplate code, interact and debug Drupal 8.
drupal/console-core 1.0.0-rc4 Drupal Console Core
drupal/console-en 1.0.0-rc1 Drupal Console English Language

@Lendude are you executing DC like this https://github.com/hechoendrupal/DrupalConsole/issues/2770#issuecomment-251937199 ?

@jmolivas yeah

If I do ./vendor/bin/drupal outside the web dir it gives me:
Something goes wrong with your package.
Try downloading again.
Executing:
composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

Is that normal behaviour?

@Lendude

If I do ./vendor/bin/drupal outside the web dir it gives me:

This means it works form the web directory?

@jmolivas no, that still gives
InvalidArgumentException: The file "/Applications/MAMP/htdocs/ucytech/web//vendor/drupal/console-core/services.yml" does not exist. in SymfonyComponentConfigFileLocator->locate() (line 44 of /Applications/MAMP/htdocs/ucytech/vendor/symfony/config/FileLocator.php).

@jmolivas was just hoping that some extra info might give you a hint of where we can look :)

@Lendude what I see is not building the path correctly
This
Applications/MAMP/htdocs/ucytech/web//vendor/drupal/console-core/services.yml
Should be
Applications/MAMP/htdocs/ucytech/vendor/drupal/console-core/services.yml

But no idea why

@jmolivas Ok thanks for thinking along. Since @finnef and I both have the same problems inside the same project repo and this is not something that is happening for everybody using a DrupalComposer setup, I assume it's something in our settings/config that messing things up.

Will report back if we figure anything out!

@finnef @Lendude did you try using the global executable launcher?

Install global executable launcher tool:

# Run this in your terminal to get the latest project version:
curl https://drupalconsole.com/installer -L -o drupal.phar

# Accessing from anywhere on your system:
mv drupal.phar /usr/local/bin/drupal

# Apply executable permissions on the downloaded file:
chmod +x /usr/local/bin/drupal

After this try drupal initand answer yes to the first question about copying at current directory

@finnef @Lendude you can also log into the gitter channel https://gitter.im/hechoendrupal/DrupalConsole to ask questions and we can continue this via private messages on gitter.

So this seems like a bug related to having DC installed globally (.console in my ~ home directory) but also installed in a drupal project's /vendor directory by composer? Earlier you said we should only install locally in a project, which is what composer is doing with require drupal/console, right? So should we uninstall the global DC? And how do we do that? But... just above you are telling how to install globally. If we do that, where should we run "drupal init"? in ~home, the composer root or the drupal root?

@ransomweaver

The global executable is not the DrupalConsole project. Is a global executable launcher tool (kinda like the Symfony or Laravel installer) this help you providing some minimum number of commands and it also help you executing console from site root without calling /vendor/bin/drupal.

DrupalConsole should be installed from site root using

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

You can also use the awesome DrupalComposer a composer template to download Drupal + DrupalConsole + other tools
https://github.com/drupal-composer/drupal-project

composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction

@ransomweaver It also does not matter from where do you run drupal initthe command will ask you to copy the configuration files on the current working directory or globally.

drupal-init-from-site

You can remove DrupalConsole global installation by

composer global remove drupal/console

I think I am more or less back where I started. I have:

  • removed all trace of global drupal/console (I think) by deleting /usr/local/bin/drupal, ~/.console, and any mention of console in my .bash_profile. restart my bash shell, and I have:
    -bash: drupal: command not found
  • now I install the global executable launcher tool as per the instructions above
  • in my home dir I run drupal init --override --no-interaction, now I have a .console in ~
  • for testing I do the following:
    1) composer create-project drupal-composer/drupal-project:8.x-dev justd8 --stability dev --no-interaction
  • cd justd8/web, drupal list, I get the list, not the error, so that's great. But my project is based on drupalcommerce/project-base so also try this:
    2) composer create-project drupalcommerce/project-base justcommerce --stability dev
  • cd justcommerce/web, drupal list and I get:
    [ERROR] Drupal Console is not installed at: /Users/ransom/MAMP/commerce/web/
    You must execute this composer command:
    composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
  • but require drupal/console:~1.0 is already in composer.json, and running that composer commaned does nothing to fix the error from DC.
  • the composer.json and composer.lock for justd8 and justcommerce are EXACTY the same (with regard to DC), and so is the project structure, so WHY does DC treat the projects differently?
  • if I try my own project (which is an extension of drupalcommerce/project-base) , I still the the initial path to console-core/services.yml error

What are we all missing here? I used DC for months on this project with no problems, now broken.

@ransomweaver what is your project template to test this?

@ransomweaver

Instead of cd justd8/web

Try executing drupal init from justd8and answer yes to

Copy at current directory console/config.yml? (yes/no)
> 

justd8 seems to be fine. drupal list shows normally there. Its justcommerce that complains about console not being installed except it is, via composer into justcommerce/vendor

my project is a private bitbucket repo, it is a modification of drupalcommerce/commerce_base profile, which I show installing for test above. In my project, If I composer remove drupal/console from the project I don't get the path error; instead I get the error that drupal/console is not installed. but I have a problem at the moment adding it back in as it doesn't like the version of symfony/dom-browser that is also required. I will try to solve that.

@ransomweaver related to symfony/dom-crawlerthis may helps: https://github.com/hechoendrupal/DrupalConsole/issues/2754#issuecomment-251361912

Another dead end. requiring symfony/dom-crawler:~2.8.11 allowed me to remove drupal/console and require it again, coming back as rc5. but the path error is still there.

@ransomweaver this may be something in you package or composer definition?

Since have no access to you package is hard to test I will try testing the DrupalCommerce composer template

@jmolivas I have emailed you the composer.json and composer.lock

@ransomweaver can you copy paste the output for composer show | grep drupal

drupal-composer/drupal-scaffold 2.1.0
drupal/console 1.0.0-rc5
drupal/console-core 1.0.0-rc5
drupal/console-en 1.0.0-rc1
drupal/core 8.2.0

Just chiming to provide an example, here is the project: https://github.com/dustinleblanc/veccs

I am having issues running drupal or ./vendor/bin/drupal or ../vendor/bin/drupal from web root. Console is installed in /usr/local/bin via the phar install method as well as a dev dependency of the site. Console config has been generated at the project root.

Happy to help continuing to debug.

@ransomweaver @dustinleblanc @finnef @Lendude
can you confirm there is no composer.json file on your web directory?

I saw that happening on https://github.com/dustinleblanc/veccs/tree/master/web having a composer.json files that makes this validation to fail
https://github.com/hechoendrupal/DrupalConsole/blob/master/bin/drupal.php#L29

Yes! There is an empty composer.json file in the web directory, which has been there since forever, and DC never was bothered by it. Now I find that removing it fixes the services.yml not found error, but drupal list did then show a "warning: In order to list all of the available commands you should install drupal first" even though drupal was installed. Then, after entering just "drupal", the error is gone for "drupal list".

So I will mark this issue closed.

Experienced the same issue, deleting the composer.json & composer.lock files in de web dir solved the issue.

I'm experiencing same issue with the latest RC. Removing composer files works but imho isn't solution.

@miromichalicka Which version are you using?. Make sure you have the RC-9 on the site and also the Launcher (the global executable)

I Just tried with RC-9, created a composer.json file and it works as expected
drupal

@jmolivas I'm using rc9. I have installed also the Launcher.
Now, when running the Launcher, I'm getting following error: [ERROR] Drupal Console is not installed at, it's installed in composer file one level up (installation through drupal-composer/drupal-project).

I ran into this as well and deleting the composer stuff in the web root was the solution.

I ran into this as well and deleting an empty composer.json in the web directory fixed it.

+1 Ran into this issue and fixed by deleting empty composer.json and composer.locl in web/ root of a drupal-composer/drupal-project repo.

Me too, for the second time. Baah :( Time to call it a day!

What if drupal console would give a warning message about the empty composer.json?

@badrange we can probably send a PR to the drupal-finder project https://github.com/webflo/drupal-finder this is the one detecting the drupal site

Thanks for that @jmolivas - the issue is here:
https://github.com/webflo/drupal-finder/issues/12

I experienced similar issues on a shared hosting platform. After
Updating dependencies (including require-dev)
it was taking too long and I cancelled command and I got
Write failed: Broken pipe
Tried again and it said
Drupal8.dev file not empty
Deleted Drupal8.dev and started again, and it was taking too long exactly as my first try. I left it overnight
but had Write failed: Broken pipe message when I checked in morning.

I am going back to Drush for now.

I ran into this as well and deleting an empty composer.json in the web directory fixed it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bojanz picture bojanz  路  6Comments

julfabre picture julfabre  路  7Comments

wturrell picture wturrell  路  6Comments

extravio picture extravio  路  6Comments

dreamfony picture dreamfony  路  5Comments