RobertCraigie / pyright-python

Python command line wrapper for pyright, a static type checker
https://pypi.org/project/pyright/
MIT License
178 stars 22 forks source link

ENOTEMPTY: directory not empty, rmdir '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/xml/etree' #190

Closed copdips closed 1 year ago

copdips commented 1 year ago

Hello,

I'm using pyright inside a pre-commit, and I encounter some strange error.

I have also enable the cache where the cache source location is : /opt/hostedtoolcache/Python/3.10.12/x64 where we found all the install python packages.

And hereunder a part of my pre-commit file:

pyright is installed in a previsous CI pipeline task by pip install pyright

- id: pyright
  name: pyright
  language: system
  entry: pyright
  types: [python]
  args:
    - "."
The error message is: ```bash ##[section]Starting: Lint code ============================================================================== Task : Command line Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows Version : 2.212.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line ============================================================================== Generating script. Script contents: pre-commit run --all-files ========================== Starting Command Output =========================== [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/95183db4-ecb6-4505-81dd-9a1f9adeecf6.sh [INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks. [INFO] Initializing environment for https://github.com/Lucas-C/pre-commit-hooks. [INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier. [INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier:prettier@3.0.0-alpha.9-for-vscode. [INFO] Initializing environment for https://github.com/pre-commit/pygrep-hooks. [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/Lucas-C/pre-commit-hooks. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... check json...........................................(no files to check)Skipped check yaml...............................................................Passed check toml...............................................................Passed fix end of files.........................................................Passed trim trailing whitespace.................................................Passed debug statements (python)................................................Passed fix requirements.txt.....................................................Passed detect private key.......................................................Passed mixed line ending........................................................Passed check for added large files..............................................Passed don't commit to branch...................................................Passed CRLF end-lines checker...................................................Passed CRLF end-lines remover...................................................Passed No-tabs checker..........................................................Passed Tabs remover.............................................................Passed prettier.................................................................Passed check blanket type ignore................................................Passed check for not-real mock methods..........................................Passed use logger.warning(......................................................Passed type annotations not comments............................................Passed bandit...................................................................Passed ruff.....................................................................Passed black....................................................................Passed pyright..................................................................Failed - hook id: pyright - exit code: 1 npm WARN cleanup Failed to remove some directories [ npm WARN cleanup [ npm WARN cleanup undefined, npm WARN cleanup TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined npm WARN cleanup at rm (node:internal/fs/promises:679:38) npm WARN cleanup at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:553:20 npm WARN cleanup at Array.map () npm WARN cleanup at [rollbackCreateSparseTree] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:553:8) npm WARN cleanup at [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:256:31) npm WARN cleanup at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:170:5) npm WARN cleanup at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:146:5) npm WARN cleanup at async module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:134:5) { npm WARN cleanup code: 'ERR_INVALID_ARG_TYPE' npm WARN cleanup } npm WARN cleanup ] npm WARN cleanup ] npm ERR! code ENOTEMPTY npm ERR! syscall rmdir npm ERR! path /home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/xml/etree npm ERR! errno -39 npm ERR! ENOTEMPTY: directory not empty, rmdir '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/xml/etree' npm ERR! A complete log of this run can be found in: npm ERR! /home/vsts/.npm/_logs/2023-06-30T12_47_25_972Z-debug-0.log Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.10.12/x64/bin/pyright", line 8, in sys.exit(entrypoint()) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 34, in entrypoint sys.exit(main(sys.argv[1:])) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 19, in main return run(*args, **kwargs).returncode File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 25, in run pkg_dir = install_pyright(args, quiet=None) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/_utils.py", line 61, in install_pyright node.run( File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/node.py", line 122, in run subprocess.run(node_args, env=env, **kwargs), File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/subprocess.py", line 526, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/npm', 'install', 'pyright@1.1.316']' returned non-zero exit status 217. npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/json/encoder.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/html/entities.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/urllib/error.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/pyexpat/errors.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stubs/WebOb/webob/etag.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/asyncio/events.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stubs/gdb/gdb/events.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stubs/WebOb/webob/exc.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stdlib/asyncio/exceptions.pyi' npm WARN tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/dist/typeshed-fallback/stubs/jmespath/jmespath/exceptions.pyi' ...similar lines discarded... added 1 package, and audited 2 packages in 2s found 0 vulnerabilities Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.10.12/x64/bin/pyright", line 8, in sys.exit(entrypoint()) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 34, in entrypoint sys.exit(main(sys.argv[1:])) File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 19, in main return run(*args, **kwargs).returncode File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyright/cli.py", line 28, in run raise RuntimeError(f'Expected CLI entrypoint: {script} to exist') RuntimeError: Expected CLI entrypoint: /home/vsts/.cache/pyright-python/1.1.316/node_modules/pyright/index.js to exist pytest...................................................................Passed ##[error]Bash exited with code '1'. ##[section]Finishing: Lint code ```
copdips commented 1 year ago

I think I found the issue. It should due to cache, as I only cache the folder /opt/hostedtoolcache/Python/3.10.12/x64, but pyright needs also ~/.cache/pyright-python. In the CICD pipeline, when the cache is restored successfully, it thinks all the python packages including pyright are restored, but in fact not for ~/.cache/pyright-python