spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
555 stars 102 forks source link

Package "spatie/laravel-ray" is not installed on Ubuntu VM #111

Closed elfeffe closed 3 years ago

elfeffe commented 3 years ago

Describe the bug I run composer require spatie/laravel-ray but when I try to debug using ray()->showQueries(); I get that error

Versions 1.0.8

You can use composer show to get the version numbers of: spatie/ray 1.5.2 spatie/laravel-ray 1.3.4

PHP version: 7.4 Laravel version 8

Desktop (please complete the following information):

freekmurze commented 3 years ago

Could you post a full stacktrace?

I'm pretty sure that this problem is caused by something specific to your environment as the tests run fine and I'm getting no other reports about this problem.

Jackpump commented 3 years ago

@elfeffe try clearing your apps cache, maybe that would work

elfeffe commented 3 years ago

I have cleared my cache, but still get it.

The problem seems to be this line $meta['laravel_ray_package_version'] = InstalledVersions::getVersion('spatie/laravel-ray');

Here: Spatie\LaravelRay\Ray::sendRequest vendor/spatie/laravel-ray/src/Ray.php:159

    protected function queryLogger(): QueryLogger

    {

        return app(QueryLogger::class);

    }

    /**

     * @param \Spatie\Ray\Payloads\Payload|\Spatie\Ray\Payloads\Payload[] $payloads

     * @param array $meta

     *

     * @return \Spatie\Ray\Ray

     * @throws \Exception

     */

    public function sendRequest($payloads, array $meta = []): BaseRay

    {

        if (! static::$enabled) {

            return $this;

        }

        $meta = [

            'laravel_version' => app()->version(),

        ];

        if (class_exists(InstalledVersions::class)) {

            $meta['laravel_ray_package_version'] = InstalledVersions::getVersion('spatie/laravel-ray');

        }

        return BaseRay::sendRequest($payloads, $meta);

    }

}

This is my system Environment information Laravel version 8.21.0 Laravel locale en Laravel config cached false PHP version 7.4.13

freekmurze commented 3 years ago

Could you show us the output of composer show

elfeffe commented 3 years ago

asm89/stack-cors v2.0.2 Cross-origin resource sharing library and stack middleware bacon/bacon-qr-code 2.0.3 BaconQrCode is a QR code generator for PHP. barryvdh/laravel-ide-helper v2.9.0 Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion. barryvdh/reflection-docblock v2.0.6 bensampo/laravel-embed dev-elfeffe-patch-tailwind-responsive-embeds fea9643 Painless responsive embeds for videos, slideshows and more. beyondcode/laravel-dump-server 1.7.0 Symfony Var-Dump Server for Laravel blade-ui-kit/blade-heroicons 0.3.1 A package to easily make use of Heroicons in your Laravel Blade views. blade-ui-kit/blade-icons 0.5.1 A package to easily make use of icons in your Laravel Blade views. blade-ui-kit/blade-ui-kit 0.2.0 A set of renderless components to utilise in your Laravel Blade views. brick/math 0.9.1 Arbitrary-precision arithmetic library clue/socket-raw v1.5.0 Simple and lightweight OOP wrapper for PHP's low-level sockets extension (ext-sockets). cocur/slugify v4.0.0 Converts a string into a slug. composer/ca-bundle 1.2.9 Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle. composer/composer 2.0.8 Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywh... composer/package-versions-deprecated 1.11.99.1 Composer plugin that provides efficient querying for installed package versions (no runtime IO) composer/semver 3.2.4 Semver library that offers utilities, version constraint parsing and validation. composer/spdx-licenses 1.5.5 SPDX licenses list and validation library. composer/xdebug-handler 1.4.5 Restarts a process without Xdebug. cviebrock/eloquent-sluggable 8.0.2 Easy creation of slugs for your Eloquent models in Laravel dasprid/enum 1.0.3 PHP 7.1 enum implementation dnoegel/php-xdg-base-dir v0.1.1 implementation of xdg base directory specification for php doctrine/cache 1.10.2 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcach... doctrine/dbal 3.0.0 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management. doctrine/event-manager 1.1.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects. doctrine/inflector 2.0.3 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singu... doctrine/instantiator 1.4.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 1.2.1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. dragonmantank/cron-expression v3.1.0 CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due egulias/email-validator 2.1.25 A library for validating emails against several RFCs elfeffe/buildercomponent dev-master Laravel Livewire Drag & Drop Builder facade/flare-client-php 1.3.7 Send PHP errors to Flare facade/ignition 2.5.8 A beautiful error page for Laravel applications. facade/ignition-contracts 1.0.2 Solution contracts for Ignition fakerphp/faker v1.9.2 Faker is a PHP library that generates fake data for you. fideloper/proxy 4.4.1 Set trusted proxies for Laravel filp/whoops 2.9.1 php error handling for cool kids fruitcake/laravel-cors v2.0.3 Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application graham-campbell/result-type v1.0.1 An Implementation Of The Result Type guzzlehttp/guzzle 7.2.0 Guzzle is a PHP HTTP client library guzzlehttp/promises 1.4.0 Guzzle promises library guzzlehttp/psr7 1.7.0 PSR-7 message implementation that also provides common utility methods hamcrest/hamcrest-php v2.0.1 This is the PHP port of Hamcrest Matchers hautelook/phpass 0.3.5 Portable PHP password hashing framework hexadog/laravel-theme-installer v1.0.5 hexadog/laravel-themes-manager v1.6.0 Bring multi themes support to your Laravel application with a full-featured Themes Manager intervention/image 2.5.1 Image handling and manipulation library with support for Laravel integration itsgoingd/clockwork v5.0.6 php dev tools in your browser jaybizzle/crawler-detect v1.2.103 CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent jean85/pretty-package-versions 1.5.1 A wrapper for ocramius/package-versions to get pretty versions strings jenssegers/agent v2.6.4 Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect jenssegers/mongodb v3.8.2 A MongoDB based Eloquent model and Query builder for Laravel (Moloquent) jgrossi/corcel v5.0.0 Use WordPress backend with Laravel or any PHP framework justinrainbow/json-schema 5.2.10 A library to validate a json schema. laravel/fortify v1.7.4 Backend controllers and scaffolding for Laravel authentication. laravel/framework v8.21.0 The Laravel Framework. laravel/jetstream v2.0.3 Tailwind scaffolding for the Laravel framework. laravel/sanctum v2.8.2 Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs. laravel/tinker v2.5.0 Powerful REPL for the Laravel framework. league/commonmark 1.5.7 Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM) league/flysystem 1.1.3 Filesystem abstraction: Many filesystems, one API. league/glide 1.7.0 Wonderfully easy on-demand image manipulation library with an HTTP based API. league/mime-type-detection 1.5.1 Mime-type detection for Flysystem livewire/livewire v2.3.6 A front-end framework for Laravel. maennchen/zipstream-php 2.1.0 ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the se... mobiledetect/mobiledetectlib 2.8.34 Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with speci... mockery/mockery 1.4.2 Mockery is a simple yet flexible PHP mock object framework mongodb/mongodb 1.8.0 MongoDB driver library monolog/monolog 2.2.0 Sends your logs to files, sockets, inboxes, databases and various web services myclabs/deep-copy 1.10.2 Create deep copies (clones) of your objects myclabs/php-enum 1.7.7 PHP Enum implementation nesbot/carbon 2.43.0 An API extension for DateTime that supports 281 different languages. nesk/puphpeteer 2.0.0 A Puppeteer bridge for PHP, supporting the entire API. nesk/rialto 1.4.0 Manage Node resources from PHP nikic/php-parser v4.10.4 A PHP parser written in PHP nunomaduro/collision v5.1.0 Cli error handling for console/command-line PHP applications. opis/closure 3.6.1 A library that can be used to serialize closures (anonymous functions) and arbitrary objects. paquettg/php-html-parser 3.1.1 An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery. paquettg/string-encode 1.0.1 Facilitating the process of altering string encoding in PHP. paragonie/constant_time_encoding v2.4.0 Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16) phar-io/manifest 2.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 3.0.4 Library for handling version information and constraints php-http/httplug 2.2.0 HTTPlug, the HTTP client abstraction for PHP php-http/promise 1.1.0 Promise used for asynchronous HTTP requests phpdocumentor/reflection-common 2.2.0 Common reflection classes used by phpdocumentor to reflect the code structure phpdocumentor/reflection-docblock 5.2.2 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that ... phpdocumentor/type-resolver 1.4.0 A PSR-5 based resolver of Class names, Types and Structural Element Names phpoption/phpoption 1.7.5 Option Type for PHP phpspec/prophecy 1.12.2 Highly opinionated mocking framework for PHP 5.3+ phpunit/php-code-coverage 9.2.5 Library that provides collection, processing, and rendering functionality for PHP code coverage information. phpunit/php-file-iterator 3.0.5 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-invoker 3.1.1 Invoke callables with a timeout phpunit/php-text-template 2.0.4 Simple template engine. phpunit/php-timer 5.0.3 Utility class for timing phpunit/phpunit 9.5.0 The PHP Unit Testing framework. pragmarx/google2fa 8.0.0 A One Time Password Authentication package, compatible with Google Authenticator. psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11) psr/event-dispatcher 1.0.0 Standard interfaces for event handling. psr/http-client 1.0.1 Common interface for HTTP clients psr/http-message 1.0.1 Common interface for HTTP messages psr/log 1.1.3 Common interface for logging libraries psr/simple-cache 1.0.1 Common interfaces for simple caching psy/psysh v0.10.5 An interactive shell for modern PHP. ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. ramsey/collection 1.1.1 A PHP 7.2+ library for representing and manipulating collections. ramsey/uuid 4.1.1 A PHP library for generating and working with universally unique identifiers (UUIDs). react/promise v2.8.0 A lightweight implementation of CommonJS Promises/A for PHP sebastian/cli-parser 1.0.1 Library for parsing CLI options sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to sebastian/comparator 4.0.6 Provides the functionality to compare PHP values for equality sebastian/complexity 2.0.2 Library for calculating the complexity of PHP code units sebastian/diff 4.0.4 Diff implementation sebastian/environment 5.1.3 Provides functionality to handle HHVM/PHP environments sebastian/exporter 4.0.3 Provides the functionality to export PHP variables for visualization sebastian/global-state 5.0.2 Snapshotting of global state sebastian/lines-of-code 1.0.3 Library for counting the lines of code in PHP source code sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 4.0.4 Provides functionality to recursively process PHP variables sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on resources sebastian/type 2.3.1 Collection of value objects that represent the types of the PHP type system sebastian/version 3.0.2 Library that helps with managing the version number of Git-hosted PHP projects seld/jsonlint 1.8.3 JSON Linter seld/phar-utils 1.1.1 PHAR file format utilities, for when PHP phars you up spatie/backtrace 1.0.0 A better backtrace spatie/blink 1.1.3 Cache that expires in the blink of an eye spatie/image 1.10.1 Manipulate images with an expressive API spatie/image-optimizer 1.3.2 Easily optimize images using PHP spatie/laravel-blink 1.5.0 Cache that expires in the blink of an eye spatie/laravel-medialibrary 9.4.1 Associate files with Eloquent models spatie/laravel-ray 1.3.4 Easily debug Laravel apps spatie/laravel-schemaless-attributes 1.8.3 Add schemaless attributes to Eloquent models spatie/macroable 1.0.1 A trait to dynamically add methods to a class spatie/ray 1.5.5 Debug with Ray to fix problems faster spatie/temporary-directory 1.3.0 Easily create, use and destroy temporary directories spatie/url 1.3.5 Parse, build and manipulate URL's swiftmailer/swiftmailer v6.2.5 Swiftmailer, free feature-rich PHP mailer symfony/console v5.2.1 Symfony Console Component symfony/css-selector v5.2.1 Symfony CssSelector Component symfony/deprecation-contracts v2.2.0 A generic function and convention to trigger deprecation notices symfony/error-handler v5.2.1 Symfony ErrorHandler Component symfony/event-dispatcher v5.2.1 Symfony EventDispatcher Component symfony/event-dispatcher-contracts v2.2.0 Generic abstractions related to dispatching event symfony/filesystem v5.2.1 Symfony Filesystem Component symfony/finder v5.2.1 Symfony Finder Component symfony/http-client-contracts v2.3.1 Generic abstractions related to HTTP clients symfony/http-foundation v5.2.1 Symfony HttpFoundation Component symfony/http-kernel v5.2.1 Symfony HttpKernel Component symfony/mime v5.2.1 A library to manipulate MIME messages symfony/polyfill-ctype v1.22.0 Symfony polyfill for ctype functions symfony/polyfill-iconv v1.22.0 Symfony polyfill for the Iconv extension symfony/polyfill-intl-grapheme v1.22.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-idn v1.22.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.22.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.22.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php72 v1.22.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/polyfill-php73 v1.22.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 v1.22.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/process v5.2.1 Symfony Process Component symfony/routing v5.2.1 Symfony Routing Component symfony/service-contracts v2.2.0 Generic abstractions related to writing services symfony/stopwatch v5.2.1 Symfony Stopwatch Component symfony/string v5.2.1 Symfony String component symfony/translation v5.2.1 Symfony Translation Component symfony/translation-contracts v2.3.0 Generic abstractions related to translation symfony/var-dumper v5.2.1 Symfony mechanism for exploring and dumping PHP variables theseer/tokenizer 1.2.0 A small library for converting tokenized PHP source code into XML and potentially other formats thunderer/shortcode v0.7.4 Advanced shortcode (BBCode) parser and engine for PHP tijsverkoyen/css-to-inline-styles 2.2.3 CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This... vierbergenlars/php-semver 3.0.2 The Semantic Versioner for PHP vlucas/phpdotenv v5.2.0 Loads environment variables from .env to getenv(), $_ENV and $_SERVER automagically. voku/portable-ascii 1.5.6 Portable ASCII library - performance optimized (ascii) string functions for php. webmozart/assert 1.9.1 Assertions to validate method input/output with nice error messages. webwizo/laravel-shortcodes v1.0.20 Wordpress like shortcodes for Laravel 5, 6, 7, and 8

jozydapozy commented 3 years ago

This happens (for me at least) when you're using more then 1 composer.json in your project.

Although this is not advised to do in the first place, it would be nice if Ray didn't depend on the InstalledVersions-check, to prevent this error from happening..

elfeffe commented 3 years ago

This happens (for me at least) when you're using more then 1 composer.json in your project.

Although this is not advised to do in the first place, it would be nice if Ray didn't depend on the InstalledVersions-check, to prevent this error from happening..

I have 1 composer.json, but I have some local packages with their composer.json

jozydapozy commented 3 years ago

That's probably it, but as I said, would be nice if Ray didn't bother about that..

binaryk commented 3 years ago

@freekmurze The same problem here, on local it works, but on ubuntu server it doesn't, I guess it's because on the server we don't have the application itself

Package "spatie/laravel-ray" is not installed {"userId":719,"exception":"[object] (OutOfBoundsException(code: 0): Package \"spatie/laravel-ray\" is not installed at /home/forge/testsite.com/releases/20210112151527/vendor/composer/composer/src/Composer/InstalledVersions.php:110)
[stacktrace]
#0 /home/forge/testsite.com/releases/20210112151527/vendor/spatie/laravel-ray/src/Ray.php(159)
freekmurze commented 3 years ago

Could somebody create a small app that I can use locally to reproduce this error? I'm feeling that this problem is caused by some weird edge case.

elfeffe commented 3 years ago

The problem is not the App, it seems to be related to the Ubuntu VM. I have a Mac, but I run my websites inside an Ubuntu VM to make it as similar as possible to my real servers.

freekmurze commented 3 years ago

Seems to me that this is more a problem of Composer 2 not being able to properly detect installed packages in such environment.

I don't have access to such environment. I'd accept a PR that would solve this problem for you in a non-breaking way.

Closing this here, as this is likely an issue with Composer.

elfeffe commented 3 years ago

@freekmurze Composer 2..., I see it. Well kept secret my friend :)

It works now.

qwertynik commented 1 year ago

Ray was being used for debugging earlier. Later in this project under discussion, since the usage of ray was not required, all related method calls were removed and the package was also removed from the server. However, the following error is now being logged.

Package "spatie/laravel-ray" is not installed {"exception":"[object] (OutOfBoundsException(code: 0): Package \"spatie/laravel-ray\" is not installed at /var/www/html/project/vendor/composer/composer/src/Composer/InstalledVersions.php:167

Any ideas on how this issue can be resolved? Wondering if updating to composer version 2 is the only option.

@freekmurze

qwertynik commented 1 year ago

This was resolved mysteriously after trying a variety of things and finally restarting PHP and NGINX. More details here

Note: Updated to composer 2, validated the fix, and then reverted back to composer 1 and the issue did not re-appear.