zend-server-extensions / Z-Ray-Composer

Composer Extension for Zend Server Z-Ray
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

file_get_contents([...]installed.json): failed to open stream: No such file or directory #3

Open mmic-bjohnson opened 9 years ago

mmic-bjohnson commented 9 years ago

Hello,

Is this the Z-Ray-Composer extension that is bundled with Zend Server 8.0.1? Or am I in the wrong place?

Provided I am in the correct place, I'm seeing an unknown exception occur when browsing a Laravel site.

file_get_contents(/var/www/clients/client1/web2/web/vendor/cartalyst/extensions/src/installed.json): failed to open stream: No such file or directory

The stack-trace cites the following offending code:

public function registerExit($context, &$storage)
{
$composerDir = dirname($context['calledFromFile']);
$json = file_get_contents($composerDir.'/installed.json');
$data = json_decode($json);

I'm not familiar with the inner-workings of installed.json, but is this file really guaranteed to be present? My use-case suggests not.

Thanks for any insight here.

zsuraski commented 9 years ago

Ben,

Thanks for the report!

Is it possible for you to share an app that reproduces this problem? If not, can you check whether you have the ‘installed.json’ file available anywhere in the project?

Zeev

From: Ben [mailto:notifications@github.com] Sent: Tuesday, January 20, 2015 2:06 PM To: zend-server-extensions/Z-Ray-Composer Subject: [Z-Ray-Composer] file_get_contents([...]installed.json): failed to open stream: No such file or directory (#3)

Hello,

Is this the Z-Ray-Composer extension that is bundled with Zend Server 8.0.1? Or am I in the wrong place?

Provided I am in the correct place, I'm seeing an unknown exception occur when browsing a Laravel site.

file_get_contents(/var/www/clients/client1/web2/web/vendor/cartalyst/extensions/src/installed.json): failed to open stream: No such file or directory

The stack-trace cites the following offending code:

public function registerExit($context, &$storage)

{

$composerDir = dirname($context['calledFromFile']);

$json = file_get_contents($composerDir.'/installed.json');

$data = json_decode($json);

I'm not familiar with the inner-workings of installed.json, but is this file really guaranteed to be present? My use-case suggests not.

Thanks for any insight here.

— Reply to this email directly or view it on GitHub https://github.com/zend-server-extensions/Z-Ray-Composer/issues/3.

mmic-bjohnson commented 9 years ago

Hello, and thank you for the quick reply!

Unfortunately, I cannot readily package the application in such a way that the issue would be reproducible. Although, it would be easy enough to send-over just the offending vendor directory. Please let me know if that would be helpful.

I've looked through my various Laravel projects and none of the vendor directories contain this installed.json file, excepting only ./vendor/composer/installed.json (relative to the web/project root). I just ran composer update for that project and no new files with the name installed.json are created.

Information regarding installed.json is scarce, and the file lacks comments at the top (unlike composer.lock), so it's not clear whether there is only supposed to be one instance of this file (within the composer vendor directory), or whether there should be others.

What's strange, too, is that this plugin doesn't choke on the first vendor directory (assuming they are parsed in alphabetical order); it chokes on the second directory.

Please let me know if I can provide any additional information. Thanks again!

mmic-bjohnson commented 9 years ago

Hi, Zeev!

I know that you must be busy preparing your keynote for phptek in May (see you there!)...

But, alas, I'm wondering if you've been able to investigate this issue any further.

Regardless of the root-cause, I noticed that the thrown exception is of type "unknown" (Laravel's built-in trace mechanism cites, ErrorException (E_UNKNOWN)).

Perhaps it's too inefficient to to call file_exists() on installed.json files that may or may not exist before calling file_get_contents() on them, but at a minimum, it would be ideal to have this exception handled more gracefully, so that it doesn't cause a fatal condition. Perhaps this is one of those rare cases in which using the @ operator is actually prudent.

We'd love to get cookin' with Z-Ray, but this issue is a roadblock for us.

Thanks!

zsuraski commented 9 years ago

Hi again Ben, sorry for the slow replies, been hammered; I did try to get some info from Composer wizards as to what's the right methodology to employ if installed.json isn't there, but didn't get replies. Trying again. Either way I'll add protective code so that if it doesn't exist, it won't crash.

zsuraski commented 9 years ago

Ben,

Sorry for the very slow reply! Been swamped, and failed to get the data I wanted regarding what's the right way to obtain this data in case installed.json doesn't exist.

We did add protective code in the latest version - https://github.com/zend-server-extensions/Z-Ray-Composer/blob/master/zray.php

So it wouldn't give you the data you need, but at least won't crash your app. I'll still try to figure out if there's another way to obtain the data.

mmic-bjohnson commented 9 years ago

Thanks for the follow-up, Zeev. I appreciate it.

No problem at all; we'll await a more comprehensive solution, and will employ this stop-gap solution in the meantime.

We'll keep an eye on this thread for any updates.