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

GrumPHP relative config path doesn't work #294

Closed
Bilge opened this issue Feb 14, 2017 · 4 comments
Closed

GrumPHP relative config path doesn't work #294

Bilge opened this issue Feb 14, 2017 · 4 comments
Labels
bug help wanted Paths Issues related to paths

Comments

@Bilge
Copy link
Contributor

Bilge commented Feb 14, 2017

Q A
Branch v0.11.1
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets n/a

Given that my composer.json contains the following

"extra": {
      "grumphp": {
          "config-default-path": "config/grumphp.yml"
      }
},

When I run git commit -a I see the following error.

$ git commit -a

Fatal error: Uncaught exception 'Symfony\Component\Config\Exception\FileLocatorFileNotFoundException' with message 'The file "config/grumphp.yml" does not exist (in: D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Configuration/../../../resources/config).' in D:\Users\f\g\h\api\vendor\symfony\config\FileLocator.php on line 71

Symfony\Component\Config\Exception\FileLocatorFileNotFoundException: The file "config/grumphp.yml" does not exist (in: D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Configuration/../../../resources/config). in D:\Users\f\g\h\api\vendor\symfony\config\FileLocator.php on line 71

Call Stack:
0.0005 236784 1. {main}() D:\Users\f\g\h\api\vendor\phpro\grumphp\bin\grumphp:0
0.0190 2792784 2. GrumPHP\Console\Application->__construct() D:\Users\f\g\h\api\vendor\phpro\grumphp\bin\grumphp:30
0.0200 2978760 3. GrumPHP\Console\Application->getContainer() D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Console\Application.php:57
0.2620 5946456 4. GrumPHP\Configuration\ContainerFactory::buildFromConfiguration() D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Console\Application.php:158
0.4965 7964888 5. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Configuration\ContainerFactory.php:53
0.4965 7964936 6. Symfony\Component\Config\FileLocator->locate() D:\Users\f\g\h\api\vendor\symfony\dependency-injection\Loader\YamlFileLoader.php:67

PHP Fatal error: Uncaught exception 'Symfony\Component\Config\Exception\FileLocatorFileNotFoundException' with message 'The file "config/grumphp.yml" does not exist (in: D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Configuration/../../../resources/config).' in D:\Users\f\g\h\api\vendor\symfony\config\FileLocator.php:71
Stack trace:
#0 D:\Users\f\g\h\api\vendor\symfony\dependency-injection\Loader\YamlFileLoader.php(67): Symfony\Component\Config\FileLocator->locate('config/grumphp....')
#1 D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Configuration\ContainerFactory.php(53): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load('config/grumphp....')
#2 D:\Users\f\g\h\api\vendor\phpro\grumphp\src\GrumPHP\Console\Application.php(158): GrumPHP\Configuration\ContainerFactory::buildFromConfiguration('config/grumphp....')
#3 D:\Users\f\g\h\api\vendor\symfony\config\FileLocator.php on line 71

I do not know why this is happening now. I could have sworn this was working but now it definitely does not. No amount of git:deinit/git:init is helping alleviate the problem. Nevertheless, the file definitely exists.

$ ll config/grumphp.yml
-rw-r--r-- 1 Bilge 197121 202 Feb 14 14:55 config/grumphp.yml

Update

I have nailed down exactly how and when this occurs and why it used to seem to work.

I have observed that changes to composer.json's extra parameter are picked up immediately by GrumPHP. This can be observed by running the binary because it outputs the default config path in the console usage, which changes as soon as the extra parameter is updated.

However, if the extra parameter is set during git:init it modifies the git pre-commit hook to include the relative config parameter which overrides the absolute default. Therefore, the fix should simply be to stop passing the config path in the git hook!

@Bilge Bilge changed the title GrumPHP relative config doesn't work GrumPHP relative config path doesn't work Feb 14, 2017
@veewee veewee added the bug label Feb 14, 2017
@veewee
Copy link
Contributor

veewee commented Feb 14, 2017

The config parameter was added for projects with strange folder structures. It is not ok to remove this entirely. I thinnk the solution is to keep the path relatively.

@Bilge
Copy link
Contributor Author

Bilge commented Feb 15, 2017

I thinnk the solution is to keep the path relatively.

@veewee That solution doesn't make sense because the relative path is causing the problem. If you think we need to keep the config parameter in the git hook, either the path needs to be absolute or the relative path resolution needs to be fixed.

However, I think it's strictly incorrect to have the config parameter specified in the git hook because any project that needs a custom config location, no matter how "exotic", can simply specify it in the Composer config. Why does it need to be duplicate in the git hook? Furthermore, why does the relative path resolution specified on the command line use a different (broken?) resolver to the one specified in the Composer "extra" config?

@veewee
Copy link
Contributor

veewee commented Feb 15, 2017

We really should take a look at all the paths that are being used. They currently solve a lot of problems: local installation, global installation, vagrant installations, .... It is not a good idea to just remove theses lines of code because it most likely solves another issue. Normally relative paths should work just fine, but then again: they are based on realpaths which might cause other issues.

@Bilge Bilge changed the title GrumPHP relative config path doesn't work GrumPHP relative config path doesn't work in Git hook Feb 15, 2017
@Bilge Bilge changed the title GrumPHP relative config path doesn't work in Git hook GrumPHP relative config path doesn't work Feb 15, 2017
@veewee veewee added the Paths Issues related to paths label Aug 30, 2019
@veewee
Copy link
Contributor

veewee commented Aug 30, 2019

Since the path system got a rewrite in #644 which supports relative config paths in composer, I am closing this issue for now.
Feel free to test that PR out and validate if it still works on your environment.
A new release will follow soon-ish.
Feel free to open up a new issue if this PR doesn't solve this issue for you.

@veewee veewee closed this as completed Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Paths Issues related to paths
Projects
None yet
Development

No branches or pull requests

3 participants