felixfbecker / php-language-server

PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
ISC License
1.16k stars 185 forks source link

Error when it cannot read a directory (permission denied) #462

Open nmss opened 7 years ago

nmss commented 7 years ago

UnexpectedValueException: RecursiveDirectoryIterator::construct(...): failed to open dir: Permission denied in .../felixfbecker.php-intellisense-1.5.0/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php:43

It seems it prevents the plugin from working

If you need more information feel free to ask, I have no idea what to do

note: this folder is in the files.exclude config of vscode and in the .gitignore

bbak commented 7 years ago

Same Issue here, but I assume a different cause. Looks like the String passed to RecursiveDirectoryIterator::construct() contains the directory twice, sepaprated by comma. This leads to a nonexisting path.

felixfbecker commented 7 years ago

@bbak could you get me the full stack trace?

bbak commented 7 years ago

Is this sufficient (see below)? It's just the output from VS Code Dev-Tools. Else: Could you give me a hint? I know PHP and XDebug in a Web-Environment, but failed to make a XDebug Trace for a CLI Process started through VS Code (NodeJS).

Besides that: While playing around, I also discovered, that this happens only with Projects that are stored in my OneDrive Folder. Looks like a OneDrive Client Update ~2 month ago introduced this. Pausing OneDrive Sync doesn't help. Don't know, if that's also the cause of @nmss ' problem.

`messageService.ts:126 UnexpectedValueException: RecursiveDirectoryIterator::__construct(c:/Users/my_user/OneDrive/Git/pimcore_patch/pimcore-formbuilder,c:/Users/my_user/OneDrive/Git/pimcore_patch/pimcore-formbuilder): Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird. (code: 32) in C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\webmozart\glob\src\Iterator\RecursiveDirectoryIterator.php:43 Stack trace:

0 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\webmozart\glob\src\Iterator\RecursiveDirectoryIterator.php(43): RecursiveDirectoryIterator->__construct('c:/Users/my_user...', 4128)

1 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\webmozart\glob\src\Iterator\GlobIterator.php(75): Webmozart\Glob\Iterator\RecursiveDirectoryIterator->__construct('c:/Users/my_user...', 4128)

2 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\FilesFinder\FileSystemFilesFinder.php(24): Webmozart\Glob\Iterator\GlobIterator->__construct('c:/Users/my_user...')

3 [internal function]: LanguageServer\FilesFinder\FileSystemFilesFinder->LanguageServer\FilesFinder{closure}()

4 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(64): Generator->valid()

5 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(118): Sabre\Event{closure}()

6 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\FilesFinder\FileSystemFilesFinder.php(33): Sabre\Event\coroutine(Object(Closure))

7 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\LanguageServer.php(203): LanguageServer\FilesFinder\FileSystemFilesFinder->find('c:/Users/my_user...')

8 [internal function]: LanguageServer\LanguageServer->LanguageServer{closure}()

9 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(88): Generator->send(NULL)

10 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(118): Sabre\Event{closure}()

11 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\LanguageServer.php(286): Sabre\Event\coroutine(Object(Closure))

12 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\advanced-json-rpc\lib\Dispatcher.php(164): LanguageServer\LanguageServer->initialize(Object(LanguageServer\Protocol\ClientCapabilities), 'c:\Users\my_user...', 16424)

13 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\LanguageServer.php(130): AdvancedJsonRpc\Dispatcher->dispatch(Object(AdvancedJsonRpc\Request))

14 [internal function]: LanguageServer\LanguageServer->LanguageServer{closure}()

15 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(64): Generator->valid()

16 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\coroutine.php(118): Sabre\Event{closure}()

17 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\LanguageServer.php(153): Sabre\Event\coroutine(Object(Closure))

18 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\EmitterTrait.php(88): LanguageServer\LanguageServer->LanguageServer{closure}(Object(LanguageServer\Protocol\Message))

19 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\src\ProtocolStreamReader.php(56): Sabre\Event\Emitter->emit('message', Array)

20 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\Loop\Loop.php(311): LanguageServer\ProtocolStreamReader->LanguageServer{closure}()

21 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\Loop\Loop.php(233): Sabre\Event\Loop\Loop->runStreams(NULL)

22 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\Loop\Loop.php(194): Sabre\Event\Loop\Loop->tick(true)

23 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\sabre\event\lib\Loop\functions.php(122): Sabre\Event\Loop\Loop->run()

24 C:\Users\my_user.vscode\extensions\felixfbecker.php-intellisense-1.5.4\vendor\felixfbecker\language-server\bin\php-language-server.php(50): Sabre\Event\Loop\run()

25 {main}`

felixfbecker commented 7 years ago

Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

That's the error - the files are locked, likely by the OneDrive sync client. There is nothing the language server can do about that. I would recommend to not use OneDrive for source control ;)

bbak commented 7 years ago

I don't, promised! ;-) It was just the most convenient location since I redirected the "My Documents" Folder (as well as several others) into OneDrive.

andrewwippler commented 6 years ago

I have the same issue, only my stack trace is somewhat boring:

UnexpectedValueException: RecursiveDirectoryIterator::construct(/home/andrew/git_repos/snip/svc/docker/data/mysql/dev): failed to open dir: Permission denied in 
/home/andrew/.vscode/extensions/felixfbecker.php-intellisense-2.0.1/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php:43
Stack trace:
#0 /home/andrew/.vscode/extensions/felixfbecker.php-intellisense-2.0.1/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php(43): RecursiveDirectoryIterator->const

The folder it is trying to read is a docker mysql data directory. Permissions are set by docker when launched. When manually updating permissions on this directory to be owned by me, the plugin works as expected. This is a bit annoying due to the permissions being overwritten.

philpalmieri commented 6 years ago

same issue - but mine is with mysqldb storage created for my docker images in the project root.

I just added my user to the group for the directory so it has read access, but it really should just log the error and move on? Are you open to pull requests if I can work on it?

`[Error - 8:09:33 AM] Server initialization failed. Message: UnexpectedValueException: RecursiveDirectoryIterator::__construct(/home/ppalmieri/Dev/abbvie-abwow17-728-089/mysqldb/performance_schema): failed to open dir: Permission denied in /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php:43 Stack trace:

0 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php(43): RecursiveDirectoryIterator->__construct('/home/ppalmieri...', 4128)

1 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php(55): Webmozart\Glob\Iterator\RecursiveDirectoryIterator->__construct('/home/ppalmieri...', 4128)

2 [internal function]: Webmozart\Glob\Iterator\RecursiveDirectoryIterator->getChildren()

3 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/webmozart/glob/src/Iterator/RegexFilterIterator.php(130): FilterIterator->next()

4 [internal function]: Webmozart\Glob\Iterator\RegexFilterIterator->next()

5 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/felixfbecker/language-server/src/FilesFinder/FileSystemFilesFinder.php(24): IteratorIterator->next()

6 [internal function]: LanguageServer\FilesFinder\FileSystemFilesFinder->LanguageServer\FilesFinder{closure}()

7 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/coroutine.php(70): Generator->send(NULL)

8 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/Promise.php(242): Sabre\Event{closure}(NULL)

9 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\Event\Promise->Sabre\Event{closure}()

10 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\Event\Loop\Loop->runNextTicks()

11 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\Event\Loop\Loop->tick(true)

12 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\Event\Loop\Loop->run()

13 /home/ppalmieri/.vscode/extensions/felixfbecker.php-intellisense-2.2.8/vendor/felixfbecker/language-server/bin/php-language-server.php(50): Sabre\Event\Loop\run()

14 {main}

Code: -32603 `

felixfbecker commented 6 years ago

Of course

jchn-codes commented 6 years ago

same issue here.

[Error - 10:18:29 AM] Server initialization failed.
Message: UnexpectedValueException: RecursiveDirectoryIterator::__construct(/home/zeronine/dev/a-cup-of-code/~): failed to open dir: Permission denied in /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php:43

Stack trace:
0 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php(43): RecursiveDirectoryIterator->__construct('/home/zeronine/...', 4128)
1 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/webmozart/glob/src/Iterator/RecursiveDirectoryIterator.php(55): Webmozart\Glob\Iterator\RecursiveDirectoryIterator->__construct('/home/zeronine/...', 4128)
2 [internal function]: Webmozart\Glob\Iterator\RecursiveDirectoryIterator->getChildren()
3 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/webmozart/glob/src/Iterator/RegexFilterIterator.php(130): FilterIterator->next()
4 [internal function]: Webmozart\Glob\Iterator\RegexFilterIterator->next()
5 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/felixfbecker/language-server/src/FilesFinder/FileSystemFilesFinder.php(24): IteratorIterator->next()
6 [internal function]: LanguageServer\FilesFinder\FileSystemFilesFinder->LanguageServer\FilesFinder\{closure}()
7 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/coroutine.php(70): Generator->send(NULL)
8 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/Promise.php(242): Sabre\Event\{closure}(NULL)
9 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/Loop/Loop.php(261): Sabre\Event\Promise->Sabre\Event\{closure}()
10 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/Loop/Loop.php(215): Sabre\Event\Loop\Loop->runNextTicks()
11 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/Loop/Loop.php(194): Sabre\Event\Loop\Loop->tick(true)
12 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/sabre/event/lib/Loop/functions.php(122): Sabre\Event\Loop\Loop->run()
13 /home/zeronine/.vscode/extensions/felixfbecker.php-intellisense-2.3.0/vendor/felixfbecker/language-server/bin/php-language-server.php(55): Sabre\Event\Loop\run()
14 {main}
Code: -32603
teohhanhui commented 6 years ago

Same. In my case it's the data directory for my PostgreSQL Docker. Unreadable files and directories should be ignored.

teohhanhui commented 6 years ago

In addition, it'd be great to be able to exclude paths to avoid unnecessarily looking in node_modules directory, for example.

EDIT: That's https://github.com/felixfbecker/php-language-server/issues/159 and https://github.com/felixfbecker/php-language-server/issues/164

morphles commented 5 years ago

Just to add, this is still an issue, and quite serious IMO, as unless you can force everything (first, not necessarily possible, second why should you even) into readable the tool is in essence is unusable. I even tried looking at code hoping it might be some simple flag, but seems it might even be issue in libraries used...

pjio commented 5 years ago

As workaround for me is to make the files world readable: sudo chmod -R o+rx path/to/unreadable/files

This works at least for database files which get mounted into an docker container, assuming being on mac or linux.

Paulmicha commented 5 years ago

Use the CATCH_GET_CHILD flag in RecursiveIteratorIterator instanciation ? i.e. :

$ritit = new RecursiveIteratorIterator(
  new RecursiveDirectoryIterator($path),
  $order,
  RecursiveIteratorIterator::CATCH_GET_CHILD
);

See https://stackoverflow.com/a/4550051

desean1625 commented 5 years ago

The fix for this is

php-language-server-master/src/FilesFinder/FileSystemFilesFinder.php

<?php
declare (strict_types = 1);

namespace LanguageServer\FilesFinder;

use function LanguageServer\pathToUri;
use function LanguageServer\timeout;
use function Sabre\Event\coroutine;
use Sabre\Event\Promise;

class FileSystemFilesFinder implements FilesFinder
{
    /**
     * Returns all files in the workspace that match a glob.
     * If the client does not support workspace/xfiles, it falls back to searching the file system directly.
     *
     * @param string $glob
     * @return Promise <string[]>
     */
    public function find(string $glob): Promise
    {
        return coroutine(function () use ($glob) {
            $uris = [];
            foreach (new GlobIterator($glob) as $path) {
                // Exclude any directories that also match the glob pattern
                if (!is_dir($path) || !is_readable($path)) {
                    $uris[] = pathToUri($path);
                }

                yield timeout();
            }
            return $uris;
        });
    }
}

php-language-server-master/src/FilesFinder/GlobIterator.php


<?php

namespace LanguageServer\FilesFinder;

use ArrayIterator;
use EmptyIterator;
use IteratorIterator;
use RecursiveIteratorIterator;
use Webmozart\Glob\Glob;
use Webmozart\Glob\Iterator\GlobFilterIterator;
use Webmozart\Glob\Iterator\RecursiveDirectoryIterator;

/**
 * Returns filesystem paths matching a glob.
 *
 * @since  1.0
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @see    Glob
 */
class GlobIterator extends IteratorIterator
{
    /**
     * Creates a new iterator.
     *
     * @param string $glob  The glob pattern.
     * @param int    $flags A bitwise combination of the flag constants in
     *                      {@link Glob}.
     */
    public function __construct($glob, $flags = 0)
    {
        $basePath = Glob::getBasePath($glob, $flags);
        if (!Glob::isDynamic($glob) && file_exists($glob)) {
            // If the glob is a file path, return that path
            $innerIterator = new ArrayIterator(array($glob));
        } elseif (is_dir($basePath)) {
            // Use the system's much more efficient glob() function where we can
            if (
                // glob() does not support /**/
                false === strpos($glob, '/**/') &&
                // glob() does not support stream wrappers
                false === strpos($glob, '://') &&
                // glob() does not support [^...] on Windows
                ('\\' !== DIRECTORY_SEPARATOR || false === strpos($glob, '[^'))
            ) {
                $results = glob($glob, GLOB_BRACE);

                // $results may be empty or false if $glob is invalid
                if (empty($results)) {
                    // Parse glob and provoke errors if invalid
                    Glob::toRegEx($glob);

                    // Otherwise return empty result set
                    $innerIterator = new EmptyIterator();
                } else {
                    $innerIterator = new ArrayIterator($results);
                }
            } else {
                // Otherwise scan the glob's base directory for matches
                $innerIterator = new GlobFilterIterator(
                    $glob,
                    new RecursiveIteratorIterator(
                        new RecursiveDirectoryIterator(
                            $basePath,
                            RecursiveDirectoryIterator::CURRENT_AS_PATHNAME,
                            RecursiveDirectoryIterator::SKIP_DOTS
                        ),
                        RecursiveIteratorIterator::SELF_FIRST,
                        RecursiveIteratorIterator::CATCH_GET_CHILD
                    ),
                    GlobFilterIterator::FILTER_VALUE,
                    $flags
                );
            }
        } else {
            // If the glob's base directory does not exist, return nothing
            $innerIterator = new EmptyIterator();
        }

        parent::__construct($innerIterator);
    }
}
Ilkhom-S commented 5 years ago

The fix for this is

php-language-server-master/src/FilesFinder/FileSystemFilesFinder.php

<?php
declare (strict_types = 1);

namespace LanguageServer\FilesFinder;

use function LanguageServer\pathToUri;
use function LanguageServer\timeout;
use function Sabre\Event\coroutine;
use Sabre\Event\Promise;

class FileSystemFilesFinder implements FilesFinder
{
    /**
     * Returns all files in the workspace that match a glob.
     * If the client does not support workspace/xfiles, it falls back to searching the file system directly.
     *
     * @param string $glob
     * @return Promise <string[]>
     */
    public function find(string $glob): Promise
    {
        return coroutine(function () use ($glob) {
            $uris = [];
            foreach (new GlobIterator($glob) as $path) {
                // Exclude any directories that also match the glob pattern
                if (!is_dir($path) || !is_readable($path)) {
                    $uris[] = pathToUri($path);
                }

                yield timeout();
            }
            return $uris;
        });
    }
}

php-language-server-master/src/FilesFinder/GlobIterator.php


<?php

namespace LanguageServer\FilesFinder;

use ArrayIterator;
use EmptyIterator;
use IteratorIterator;
use RecursiveIteratorIterator;
use Webmozart\Glob\Glob;
use Webmozart\Glob\Iterator\GlobFilterIterator;
use Webmozart\Glob\Iterator\RecursiveDirectoryIterator;

/**
 * Returns filesystem paths matching a glob.
 *
 * @since  1.0
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @see    Glob
 */
class GlobIterator extends IteratorIterator
{
    /**
     * Creates a new iterator.
     *
     * @param string $glob  The glob pattern.
     * @param int    $flags A bitwise combination of the flag constants in
     *                      {@link Glob}.
     */
    public function __construct($glob, $flags = 0)
    {
        $basePath = Glob::getBasePath($glob, $flags);
        if (!Glob::isDynamic($glob) && file_exists($glob)) {
            // If the glob is a file path, return that path
            $innerIterator = new ArrayIterator(array($glob));
        } elseif (is_dir($basePath)) {
            // Use the system's much more efficient glob() function where we can
            if (
                // glob() does not support /**/
                false === strpos($glob, '/**/') &&
                // glob() does not support stream wrappers
                false === strpos($glob, '://') &&
                // glob() does not support [^...] on Windows
                ('\\' !== DIRECTORY_SEPARATOR || false === strpos($glob, '[^'))
            ) {
                $results = glob($glob, GLOB_BRACE);

                // $results may be empty or false if $glob is invalid
                if (empty($results)) {
                    // Parse glob and provoke errors if invalid
                    Glob::toRegEx($glob);

                    // Otherwise return empty result set
                    $innerIterator = new EmptyIterator();
                } else {
                    $innerIterator = new ArrayIterator($results);
                }
            } else {
                // Otherwise scan the glob's base directory for matches
                $innerIterator = new GlobFilterIterator(
                    $glob,
                    new RecursiveIteratorIterator(
                        new RecursiveDirectoryIterator(
                            $basePath,
                            RecursiveDirectoryIterator::CURRENT_AS_PATHNAME,
                            RecursiveDirectoryIterator::SKIP_DOTS
                        ),
                        RecursiveIteratorIterator::SELF_FIRST,
                        RecursiveIteratorIterator::CATCH_GET_CHILD
                    ),
                    GlobFilterIterator::FILTER_VALUE,
                    $flags
                );
            }
        } else {
            // If the glob's base directory does not exist, return nothing
            $innerIterator = new EmptyIterator();
        }

        parent::__construct($innerIterator);
    }
}

Thanks, your solution works. I modified on my notebook. It would be great if you could make pull request to fix on next version

Ilkhom-S commented 5 years ago

The fix for this is

php-language-server-master/src/FilesFinder/FileSystemFilesFinder.php

<?php
declare (strict_types = 1);

namespace LanguageServer\FilesFinder;

use function LanguageServer\pathToUri;
use function LanguageServer\timeout;
use function Sabre\Event\coroutine;
use Sabre\Event\Promise;

class FileSystemFilesFinder implements FilesFinder
{
    /**
     * Returns all files in the workspace that match a glob.
     * If the client does not support workspace/xfiles, it falls back to searching the file system directly.
     *
     * @param string $glob
     * @return Promise <string[]>
     */
    public function find(string $glob): Promise
    {
        return coroutine(function () use ($glob) {
            $uris = [];
            foreach (new GlobIterator($glob) as $path) {
                // Exclude any directories that also match the glob pattern
                if (!is_dir($path) || !is_readable($path)) {
                    $uris[] = pathToUri($path);
                }

                yield timeout();
            }
            return $uris;
        });
    }
}

php-language-server-master/src/FilesFinder/GlobIterator.php


<?php

namespace LanguageServer\FilesFinder;

use ArrayIterator;
use EmptyIterator;
use IteratorIterator;
use RecursiveIteratorIterator;
use Webmozart\Glob\Glob;
use Webmozart\Glob\Iterator\GlobFilterIterator;
use Webmozart\Glob\Iterator\RecursiveDirectoryIterator;

/**
 * Returns filesystem paths matching a glob.
 *
 * @since  1.0
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @see    Glob
 */
class GlobIterator extends IteratorIterator
{
    /**
     * Creates a new iterator.
     *
     * @param string $glob  The glob pattern.
     * @param int    $flags A bitwise combination of the flag constants in
     *                      {@link Glob}.
     */
    public function __construct($glob, $flags = 0)
    {
        $basePath = Glob::getBasePath($glob, $flags);
        if (!Glob::isDynamic($glob) && file_exists($glob)) {
            // If the glob is a file path, return that path
            $innerIterator = new ArrayIterator(array($glob));
        } elseif (is_dir($basePath)) {
            // Use the system's much more efficient glob() function where we can
            if (
                // glob() does not support /**/
                false === strpos($glob, '/**/') &&
                // glob() does not support stream wrappers
                false === strpos($glob, '://') &&
                // glob() does not support [^...] on Windows
                ('\\' !== DIRECTORY_SEPARATOR || false === strpos($glob, '[^'))
            ) {
                $results = glob($glob, GLOB_BRACE);

                // $results may be empty or false if $glob is invalid
                if (empty($results)) {
                    // Parse glob and provoke errors if invalid
                    Glob::toRegEx($glob);

                    // Otherwise return empty result set
                    $innerIterator = new EmptyIterator();
                } else {
                    $innerIterator = new ArrayIterator($results);
                }
            } else {
                // Otherwise scan the glob's base directory for matches
                $innerIterator = new GlobFilterIterator(
                    $glob,
                    new RecursiveIteratorIterator(
                        new RecursiveDirectoryIterator(
                            $basePath,
                            RecursiveDirectoryIterator::CURRENT_AS_PATHNAME,
                            RecursiveDirectoryIterator::SKIP_DOTS
                        ),
                        RecursiveIteratorIterator::SELF_FIRST,
                        RecursiveIteratorIterator::CATCH_GET_CHILD
                    ),
                    GlobFilterIterator::FILTER_VALUE,
                    $flags
                );
            }
        } else {
            // If the glob's base directory does not exist, return nothing
            $innerIterator = new EmptyIterator();
        }

        parent::__construct($innerIterator);
    }
}

It parses, all files in system. And make freeze. Everytime open vs-code

icedream commented 4 years ago

Just ran into this while I was developing plugins for Shopware 6 as their development setup makes use of Docker volume mount to a filesystem folder for the MySQL database (example: dev-ops/docker/_volumes/mysql/shopware_e2e). As with most volume mounts, it will default to only being accessible by root or whatever use the application inside the Docker container is running as.

Since most of my company's projects are now developed in Docker this is increasingly becoming a showstopper for using this extension.

jeffski commented 4 years ago

https://github.com/felixfbecker/php-language-server/issues/462#issuecomment-573723609 - Same issue for me.

mpasang commented 4 years ago

Any updates on this? I'm still encountering this issue in version v2.3.14

zorn-v commented 3 years ago

Is it really hard to add is_readable before break everything ? Or try/catch on last resort if "not my problem but in lib that I use" 3 years...

h4de5 commented 3 years ago

+1 using vscode-php-intellisense within theia web editor. intellisense breaks due to this issue.

erikbrgn commented 3 years ago

Any update on this issue? As others have mentioned, this seems to have become more of an issue with docker involved.

zorn-v commented 3 years ago

Seems to need fork this, and all related packages to fix and/or improve. Package creator is down many times ago.