ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

Error: spawn ENOTDIR #158

Open ravigehlot opened 5 years ago

ravigehlot commented 5 years ago

VSCode version: 1.39.1 VSCode extension: ikappas.phpcs ikappas.phpcs version: 1.0.5 Operating System: macOS Mojave version 10.14.6

VSCode set up: Using Workspaces with Folders.

The complete vscode workspace file can be seen below:

{
    "folders": [
        {
            // Debug file.
            "name": "debug.log (double click)",
            "path": "./wp-content/debug.log"
        },
        {
            // Active Theme.
            "name": "theme",
            "path": "./wp-content/themes/someprojectname"
        },
        {
            // Plugins
            "name": "plugins",
            "path": "./wp-content/plugins"
        },
        {
            // MU Plugins
            "name": "mu-plugins",
            "path": "./wp-content/mu-plugins"
        },
        {
            // Vagrant
            "name": "vagrant",
            "path": "./vagrant"
        },
        {
            // All folders
            "name": "main",
            "path": "."
        }
    ],
    "settings": {
        // Editor
        "editor.detectIndentation": true,
        "editor.formatOnPaste": true,

        // Workbench
        "workbench.editor.highlightModifiedTabs": true,

        // PHP
        "[php]":  {
          "editor.insertSpaces": true,
          "editor.tabSize": 4,
          "editor.autoIndent": true,
          "editor.renderWhitespace": "all",
        },
        "php.suggest.basic": false,
        "php.executablePath": "/usr/local/Cellar/php/7.3.9_1/bin/php",

        // phpcs
        "phpcs.enable": true,
        "phpcs.showSources": true,
        "phpcs.showWarnings": true,
        "phpcs.trace.server": "verbose",
        "phpcs.errorSeverity": 5,
        "phpcs.autoConfigSearch": true,
        "phpcs.warningSeverity": 5,
        "phpcs.composerJsonPath": "/Users/someuser/.composer/composer.json",
        "phpcs.executablePath": "/Users/someuser/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs",
        "phpcs.standard": "WordPress",
        "phpcs.ignorePatterns": [
            "*/node_modules/*",
            "*/vendor/*",
            "*/vagrant/linux/etc/mysql/*"
        ],
        // PHP Code Beautifier and Fixer (phpcbf)
        "phpcbf.enable": true,
        "phpcbf.onsave": false,
        "phpcbf.documentFormattingProvider": true,
        "phpcbf.debug": true,
        "phpcbf.executablePath": "~/.composer/vendor/squizlabs/php_codesniffer/bin/phpcbf",
        "phpcbf.standard": "./ruleset.xml",

        // Files
        "files.exclude": {
            "**/.git": true,
            "**/.DS_Store": true,
            "**/vendor": true,
            "**/node_modules": true,
            "**/vagrant/linux/etc/mysql": true,
        },
        "files.autoSave": "afterDelay",

        // Search
        "search.exclude": {
            "**/node_modules": true,
            "**/vendor": true,
            "**/vagrant/linux/etc/mysql": true,
        },   

        // Explorer
        "explorer.sortOrder": "type",
        "json.trace.server": "verbose",
        "html.trace.server": "verbose",
        "css.trace.server": "verbose",
    },
    "extensions": {
        "recommendations": [
            "editorconfig.editorconfig", // editorconfig
            "persoderlind.vscode-phpcbf", // phpcbf
            "felixfbecker.php-debug", // xdebug
            "felixfbecker.php-intellisense", // intellisense
            "neilbrayfield.php-docblocker", // docblocker
            "mikestead.dotenv", // dotenv
            "ikappas.phpcs" // phpcs
        ]
    },
    // For XDebug to work, it will require php@7.3 and php7.3-xdebug
    // installed on the host machine.
    "launch": {
        "configurations": [
            {
                "name": "Listen for XDebug",
                "type": "php",
                "request": "launch",
                "pathMappings": {
                    "/home/vagrant/Projects/": "${workspaceFolder:main}",
                },
                "xdebugSettings": {
                    "max_children": 6512,
                    "max_data": 12024,
                    "max_depth": 6,
                    "show_hidden": 1
                },
                "port": 9000,
                "log": true
            }
        ]
    }
}

Throws the following error:

[Error - 1:00:31 PM] Starting client failed
Error: spawn ENOTDIR
    at ChildProcess.spawn (internal/child_process.js:358:11)
    at spawn (child_process.js:543:9)
    at Object.fork (child_process.js:118:10)
    at Object.fork (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/utils/electron.js:83:23)
    at Promise (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/main.js:269:34)
    at new Promise (<anonymous>)
    at LanguageClient.createMessageTransports (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/main.js:249:24)
    at LanguageClient.createConnection (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/client.js:1854:21)
    at LanguageClient.resolveConnection (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/client.js:1697:44)
    at LanguageClient.start (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/node_modules/vscode-languageclient/lib/client.js:1628:14)
    at activate (/Users/someuser/.vscode/extensions/ikappas.phpcs-1.0.5/out/src/extension.js:67:12)
    at Function._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:667:613)
    at Function._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:667:264)
    at Promise.all.then.n (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:666:404)

From the vscode Developer Console, I can see:

[Extension Host] rejected promise not handled within 1 second: Error: spawn ENOTDIR

The solution was to remove the following:

        {
            // Debug file.
            "name": "debug.log (double click)",
            "path": "./wp-content/debug.log"
        },

Then it all worked! I would like to emphasize that vscode may not support the mapping of single files like the above. However, that does work for me. But it brakes vscode-phpcs though.