microsoft / vscode-black-formatter

Formatting support for Python using the Black formatter
https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
MIT License
153 stars 36 forks source link

permission error #537

Closed Foreist closed 1 month ago

Foreist commented 1 month ago

I cannot pass this situation. The same goes for reinstallation. If you run the actual black in command, it runs very well, so I don't know why this is happening. in vscode and WSL2 docker container, python version 3.10.14

2024-09-18 22:03:53.693 [info] Name: Black Formatter
2024-09-18 22:03:53.693 [info] Module: black
2024-09-18 22:03:53.693 [info] Default formatter is set to ms-python.black-formatter for workspace /workspace/competition
2024-09-18 22:03:53.693 [info] Python extension loading
2024-09-18 22:03:53.693 [info] Waiting for interpreter from python extension.
2024-09-18 22:03:53.693 [info] No interpreter found from setting black-formatter.interpreter
2024-09-18 22:03:53.693 [info] Getting interpreter from ms-python.python extension for workspace /workspace/competition
2024-09-18 22:03:53.693 [info] Python extension loaded
2024-09-18 22:03:53.693 [info] Interpreter from ms-python.python extension for /workspace/competition: /opt/conda/bin/python
2024-09-18 22:03:53.693 [info] Workspace settings for /workspace/competition (client side): {
    "cwd": "/workspace/competition",
    "workspace": "file:///workspace/competition",
    "args": [],
    "path": [
        ""
    ],
    "interpreter": [
        "/opt/conda/bin/python"
    ],
    "importStrategy": "useBundled",
    "showNotifications": "off"
}
2024-09-18 22:03:53.693 [info] No interpreter found from setting black-formatter.interpreter
2024-09-18 22:03:53.693 [info] Getting interpreter from ms-python.python extension for workspace /workspace/competition
2024-09-18 22:03:53.693 [info] Interpreter from ms-python.python extension for /workspace/competition: /opt/conda/bin/python
2024-09-18 22:03:53.693 [info] Workspace settings for /workspace/competition (client side): {
    "cwd": "/workspace/competition",
    "workspace": "file:///workspace/competition",
    "args": [],
    "path": [
        ""
    ],
    "interpreter": [
        "/opt/conda/bin/python"
    ],
    "importStrategy": "useBundled",
    "showNotifications": "off"
}
2024-09-18 22:03:53.693 [info] Global settings (client side): {
    "cwd": "/root/.cursor-server/bin/63dae81aea2c3fc079420fe72578a8eef26ba870",
    "workspace": "/root/.cursor-server/bin/63dae81aea2c3fc079420fe72578a8eef26ba870",
    "args": [],
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "off"
}
2024-09-18 22:03:53.693 [info] Server run command: /opt/conda/bin/python /root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py
2024-09-18 22:03:53.693 [info] Server: Start requested.
2024-09-18 22:03:54.111 [info] CWD Server: /workspace/competition
2024-09-18 22:03:54.112 [info] Settings received on server:
[
    {
        "cwd": "/workspace/competition",
        "workspace": "file:///workspace/competition",
        "args": [],
        "path": [
            ""
        ],
        "interpreter": [
            "/opt/conda/bin/python"
        ],
        "importStrategy": "useBundled",
        "showNotifications": "off"
    }
]

2024-09-18 22:03:54.150 [info] Global settings received on server:
{
    "cwd": "/root/.cursor-server/bin/63dae81aea2c3fc079420fe72578a8eef26ba870",
    "workspace": "/root/.cursor-server/bin/63dae81aea2c3fc079420fe72578a8eef26ba870",
    "args": [],
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "off"
}

2024-09-18 22:03:54.151 [info] sys.path used to run Server:
   /root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/libs
   /root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool
   /opt/conda/lib/python310.zip
   /opt/conda/lib/python3.10
   /opt/conda/lib/python3.10/lib-dynload
   /opt/conda/lib/python3.10/site-packages
   __editable__.kollava-0.1.0.finder.__path_hook__
2024-09-18 22:03:54.152 [info]  --version
2024-09-18 22:03:54.153 [info] CWD Server: /workspace/competition
2024-09-18 22:03:54.154 [info] Error while detecting black version:
Traceback (most recent call last):
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py", line 302, in _update_workspace_settings_with_version_info
    result = _run_tool(["--version"], copy.deepcopy(settings))
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py", line 576, in _run_tool
    result = utils.run_path(argv=argv, use_stdin=True, cwd=cwd)
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_utils.py", line 181, in run_path
    with subprocess.Popen(
  File "/opt/conda/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/conda/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: ''

2024-09-18 22:04:08.940 [info] [Trace - 10:04:08 PM] Sending request 'textDocument/formatting - (1)'.
2024-09-18 22:04:08.946 [info] [Trace - 10:04:08 PM] Received notification 'window/logMessage'.
2024-09-18 22:04:08.946 [info]  --stdin-filename /workspace/competition/eedi/code/test.py -
2024-09-18 22:04:08.946 [info] [Trace - 10:04:08 PM] Received notification 'window/logMessage'.
2024-09-18 22:04:08.946 [info] CWD Server: /workspace/competition
2024-09-18 22:04:08.947 [info] Failed to handle request 1 textDocument/formatting DocumentFormattingParams(text_document=TextDocumentIdentifier(uri='vscode-notebook-cell://attached-container%2B7b22636f6e7461696e65724e616d65223a222f6b6f6c6c617661227d@ssh-remote%2Bdxodnd/workspace/competition/eedi/code/test.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D'), options=FormattingOptions(tab_size=4, insert_spaces=True, trim_trailing_whitespace=None, insert_final_newline=None, trim_final_newlines=None), work_done_token=None)
Traceback (most recent call last):
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/libs/pygls/protocol/json_rpc.py", line 266, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/libs/pygls/protocol/json_rpc.py", line 188, in _execute_request
    self._send_response(msg_id, handler(params))
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py", line 109, in formatting
    return _formatting_helper(document)
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py", line 176, in _formatting_helper
    result = _run_tool_on_document(document, use_stdin=True, extra_args=extra_args)
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py", line 496, in _run_tool_on_document
    result = utils.run_path(
  File "/root/.cursor-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_utils.py", line 181, in run_path
    with subprocess.Popen(
  File "/opt/conda/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/conda/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: ''

2024-09-18 22:04:08.948 [info] [Trace - 10:04:08 PM] Received response 'textDocument/formatting - (1)' in 8ms. Request failed: PermissionError: [Errno 13] Permission denied: '' (-32603).
2024-09-18 22:04:08.948 [info] [Error - 10:04:08 PM] Request textDocument/formatting failed.
2024-09-18 22:04:08.948 [info]   Message: PermissionError: [Errno 13] Permission denied: ''
  Code: -32603 
[object Object]
karthiknadig commented 1 month ago

@Foreist why is the path setting set to empty string. Path should not be set to anything. It should be empty array. This is likely the cause for failure.