Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Error "Failed to open stream hoa://Library/Ruler/Grammar.pp" wich seems related to case sensitivity #86

Closed
ulk200 opened this issue May 30, 2016 · 8 comments

Comments

@ulk200
Copy link

ulk200 commented May 30, 2016

Hi,

I'm trying to use Ruler in my project, but when i "interpret" a rule, i get the following error :
Failed to open stream hoa://Library/Ruler/Grammar.pp

After some debugging i found that Hoa\Protocol\Protocol is looking into two directories (at the end of the "resolve" function) :
<my_root>/src/vendor/Hoathis/Ruler/Grammar.pp
<my_root>/src/vendor/Hoa/Ruler/Grammar.pp

But the file_exists that comes after always returns false because composer downloaded the files in <my_root>/src/vendor/hoa/ruler/Grammar.pp
The directories hoa and ruler are lowercase

Am i missing something ?
Thank you

@Hywan
Copy link
Member

Hywan commented May 31, 2016

Hello,

What versions are you using? What is the output of composer show please?

@ulk200
Copy link
Author

ulk200 commented May 31, 2016

Thank you for your answer, my composer.json is

{
  "require": {
    "hoa/ruler": "^2.16"
  }
}

composer show gives

hoa/compiler    3.16.01.14 The Hoa\Compiler library.
hoa/consistency 1.16.03.03 The Hoa\Consistency library.
hoa/event       1.16.03.15 The Hoa\Event library.
hoa/exception   1.16.01.11 The Hoa\Exception library.
hoa/file        1.16.01.15 The Hoa\File library.
hoa/iterator    2.16.03.15 The Hoa\Iterator library.
hoa/math        1.16.05.22 The Hoa\Math library.
hoa/protocol    1.16.03.07 The Hoa\Protocol library.
hoa/regex       1.16.01.15 The Hoa\Regex library.
hoa/ruler       2.16.04.06 The Hoa\Ruler library.
hoa/stream      1.16.01.14 The Hoa\Stream library.
hoa/ustring     4.16.01.11 The Hoa\Ustring library.
hoa/visitor     2.16.01.11 The Hoa\Visitor library.
hoa/zformat     1.16.03.15 The Hoa\Zformat library.

@ulk200
Copy link
Author

ulk200 commented May 31, 2016

Sorry, the problem seems to be from my own environement, i'm using the xautoload module of Drupal to load composer, but using a simple require_once vendor/autoload.php resolves the issue. I will look into what differs between the autoloader of xautoload and the one from composer. I will update this issue later if i find something usefull

@ulk200
Copy link
Author

ulk200 commented May 31, 2016

Ok found it, i managed to force the WITH_COMPOSER constant to true and it solves the issue : the \Hoa\Protocol\Node\Library object will do its things and not call its parent on top of the reach function.
This performs some strtolower that where needed in my case.

What is the use case behind the WITH_COMPOSER constant ? Maybe the issue is related to Hoa after all

@Hywan
Copy link
Member

Hywan commented May 31, 2016

The hoa:// protocol looks for resources. It abstracts the access to resources. In case resources are installed with Composer, we need to look in a very specific path (vendor/xxx/yyy/ for the Xxx\Yyy library). Because Composer puts the first two elements of the path in lowercase, we have to do tricky things. This is why we have the WITH_COMPOSER constant. It is used only in the Hoa\Protocol library so far if I remind correctly. It was used in our previous autoloader but it is no longer the case.

So, nop, it's not an issue with Hoa. It's just a side-effect from the ecosystem 😃.

Is your issue resolved? If yes, do you think it is necessary to close this issue?

@Hywan
Copy link
Member

Hywan commented May 31, 2016

Oh, and the WITH_COMPOSER constant is set to true if a class from Composer is present at runtime. You did install resources/dependencies with Composer but you're not using it after that. Is it an edge case?

@ulk200
Copy link
Author

ulk200 commented May 31, 2016

Thank you for the explanations :)
Yes i install the resources with composer but i'm using a third party autoloader (xautoload which is a Drupal 7 module), not the one from composer.
I don't know if it's an edge case, thinking in reverse why would an hypotetical WITHOUT_COMPOSER constant means that the directories be always camelcase ?
An improvement could be to separate the "downloaded_with_composer" (which sets a specific directory structure) from the "autoloaded_with_composer" (which imply the class present at runtime). Or maybe just to mention it on this page http://hoa-project.net/En/Source.html#Dependency_manager_(Composer) ?
Just to prevent someone else to face the same problem.

As for the issue yes i think you can close it. Thanks again

@Hywan Hywan closed this as completed May 31, 2016
@Hywan Hywan removed the in progress label May 31, 2016
@Hywan
Copy link
Member

Hywan commented May 31, 2016

We are discussing if we should consider this as an edge case or if this is more. Thank you for your feedback and your exemplary help. May I ask you to open an issue on Hoa\Protocol for the sequel of this discussion please?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants