-
Notifications
You must be signed in to change notification settings - Fork 185
Error when it cannot read a directory (permission denied) #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same Issue here, but I assume a different cause. Looks like the String passed to |
@bbak could you get me the full stack trace? |
Is this sufficient (see below)? It's just the output from VS Code Dev-Tools. 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.
|
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! ;-) |
I have the same issue, only my stack trace is somewhat boring:
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?
|
Of course |
same issue here.
|
Same. In my case it's the data directory for my PostgreSQL Docker. Unreadable files and directories should be ignored. |
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. |
As workaround for me is to make the files world readable: This works at least for database files which get mounted into an docker container, assuming being on mac or linux. |
Use the $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 <[email protected]>
*
* @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 |
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: Since most of my company's projects are now developed in Docker this is increasingly becoming a showstopper for using this extension. |
#462 (comment) - Same issue for me. |
Any updates on this? I'm still encountering this issue in version v2.3.14 |
Is it really hard to add |
+1 |
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
The text was updated successfully, but these errors were encountered: