Open nmss opened 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.
@bbak could you get me the full stack trace?
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:
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 ;)
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.
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.
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:
Code: -32603 `
Of course
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
Same. In my case it's the data directory for my PostgreSQL Docker. Unreadable files and directories should be ignored.
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
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...
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.
Use the CATCH_GET_CHILD
flag in RecursiveIteratorIterator
instanciation ? i.e. :
$ritit = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path),
$order,
RecursiveIteratorIterator::CATCH_GET_CHILD
);
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);
}
}
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
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
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.
Any updates on this? I'm still encountering this issue in version v2.3.14
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...
+1 using vscode-php-intellisense within theia web editor. intellisense breaks due to this issue.
Any update on this issue? As others have mentioned, this seems to have become more of an issue with docker involved.
Seems to need fork this, and all related packages to fix and/or improve. Package creator is down many times 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