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

YamlFileLoader throws InvalidArgumentException #821

Closed
boesing opened this issue Feb 9, 2022 · 5 comments · Fixed by #822
Closed

YamlFileLoader throws InvalidArgumentException #821

boesing opened this issue Feb 9, 2022 · 5 comments · Fixed by #822

Comments

@boesing
Copy link

boesing commented Feb 9, 2022

Hey there,

I wanted to start using deptrac so I've installed it using phive.
Afterwards, I've created a configuration and immediately after doing so, the YamlFileLoader blocks me from executing any command:

→ tools/deptrac -vvv
Using /usr/local/opt/php@8.1/bin/php

Box Requirements Checker
========================

> Using PHP 8.1.2
> PHP is using the following php.ini file:
  /usr/local/etc/php/8.1/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^7.4 || ^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "json".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  
                                                                                                                                                                                                                                        
 [OK] Your system is ready to run the application.                                                                                                                                                                                      
                                                                                                                                                                                                                                        


Box Requirements Checker
========================

> Using PHP 8.1.2
> PHP is using the following php.ini file:
  /private/var/folders/ty/7p8zhqjs2yd7v9sjgw6fwjc40000gn/T/KXeZRi

> Checking Box requirements:
  ✔ The application requires the version "^7.4 || ^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "json".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  
                                                                                                                                                                                                                                        
 [OK] Your system is ready to run the application.                                                                                                                                                                                      
                                                                                                                                                                                                                                        


In YamlFileLoader.php line 596:
                                                                                                                                                                                    
  [_HumbugBox8098b5a961eb\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]                                                                                 
  There is no extension able to load the configuration for "layers" (in "/Users/max/git/whatever/deptrac.yaml"). Looked for namespace "layers", found "none".  
                                                                                                                                                                                    

Exception trace:
  at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:596
 _HumbugBox8098b5a961eb\Symfony\Component\DependencyInjection\Loader\YamlFileLoader->validate() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:573
 _HumbugBox8098b5a961eb\Symfony\Component\DependencyInjection\Loader\YamlFileLoader->loadFile() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php:54
 _HumbugBox8098b5a961eb\Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/src/Console/ServiceContainerBuilder.php:85
 Qossmic\Deptrac\Console\ServiceContainerBuilder::loadConfiguration() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/src/Console/ServiceContainerBuilder.php:55
 Qossmic\Deptrac\Console\ServiceContainerBuilder->build() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/src/Console/Application.php:50
 Qossmic\Deptrac\Console\Application->doRun() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/vendor/symfony/console/Application.php:157
 _HumbugBox8098b5a961eb\Symfony\Component\Console\Application->run() at phar:///Users/max/.phive/phars/deptrac-0.19.3.phar/deptrac.php:24
 require() at /Users/max/.phive/phars/deptrac-0.19.3.phar:14
paths:
  - './src'
layers:
  -
    name: Contracts
    collectors:
      - type: className
        regex: ".*ContractInterface$"

Am I missing some details?

@patrickkusebauch
Copy link
Collaborator

Hi, starting with deptrac v 0.19, both paths and layers are sub-items under parameters. So your config should look like this:

parameters:
  paths:
    - './src'
  layers:
    -
      name: Contracts
      collectors:
        - type: className
          regex: ".*ContractInterface$"

Please refer to the documentation for details. The config file you have right now is applicable to the previous versions of deptrac.

@boesing
Copy link
Author

boesing commented Feb 10, 2022

Oh, that works indeed. Thanks, I've copied the example config from the documentation.

@boesing boesing closed this as completed Feb 10, 2022
@mnogokotin
Copy link

mnogokotin commented Jun 12, 2022

Hi, guys.

All documentation examples (https://github.com/qossmic/deptrac/tree/main/docs/) have "deptrac" root element. It is not working now. Where can I find correct examples?

@dbrumann
Copy link
Collaborator

dbrumann commented Jun 12, 2022

Which version of deptrac are you using?

If deptrac: as root is not working try parameters: instead, but be aware that import may not work as expected. That should only be a problem if you have multiple files, though.

You can still find the old docs when you switch to the version tag in GitHub's file explorer and then navigate to the docs dir.

@mnogokotin
Copy link

@dbrumann thank u very much for reply ) waiting for imports fix

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

Successfully merging a pull request may close this issue.

4 participants