{"id":"e47f6263aebbbf40","repo":"pypa/pip","slug":"no-permission-to-execute-cls-name-r-install-it","errorCode":null,"errorMessage":"No permission to execute {cls.name!r} - install it locally, globally (ask admin), or check your PATH. See possible solutions at https://pip.pypa.io/en/latest/reference/pip_freeze/#fixing-permission-denied.","messagePattern":"No permission to execute (.+?) - install it locally, globally \\(ask admin\\), or check your PATH\\. See possible solutions at https://pip\\.pypa\\.io/en/latest/reference/pip_freeze/#fixing-permission-denied\\.","errorType":"exception","errorClass":"BadCommand","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/vcs/versioncontrol.py","lineNumber":664,"sourceCode":"                spinner=spinner,\n                log_failed_cmd=log_failed_cmd,\n                stdout_only=stdout_only,\n            )\n        except NotADirectoryError:\n            raise BadCommand(f\"Cannot find command {cls.name!r} - invalid PATH\")\n        except FileNotFoundError:\n            # errno.ENOENT = no such file or directory\n            # In other words, the VCS executable isn't available\n            raise BadCommand(\n                f\"Cannot find command {cls.name!r} - do you have \"\n                f\"{cls.name!r} installed and in your PATH?\"\n            )\n        except PermissionError:\n            # errno.EACCES = Permission denied\n            # This error occurs, for instance, when the command is installed\n            # only for another user. So, the current user don't have\n            # permission to call the other user command.\n            raise BadCommand(\n                f\"No permission to execute {cls.name!r} - install it \"\n                f\"locally, globally (ask admin), or check your PATH. \"\n                f\"See possible solutions at \"\n                f\"https://pip.pypa.io/en/latest/reference/pip_freeze/\"\n                f\"#fixing-permission-denied.\"\n            )\n\n    @classmethod\n    def is_repository_directory(cls, path: str) -> bool:\n        \"\"\"\n        Return whether a directory path is a repository directory.\n        \"\"\"\n        logger.debug(\"Checking in %s for %s (%s)...\", path, cls.dirname, cls.name)\n        return os.path.exists(os.path.join(path, cls.dirname))\n\n    @classmethod\n    def get_repository_root(cls, location: str) -> str | None:\n        \"\"\"","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/vcs/versioncontrol.py#L646-L682","documentation":"Raised by `VCS.run_command` when executing the VCS binary raises `PermissionError` (EACCES) — the file exists but the current user lacks execute permission on it. Common when a tool is installed for a different user or the binary's mode bits forbid execution. pip wraps it as `BadCommand` and links the pip docs on fixing permission-denied.","triggerScenarios":"`call_subprocess` raises `PermissionError` while spawning `git`/`svn`/`hg`/`bzr`. The executable is present on PATH but its filesystem permissions (or a parent directory's) deny the current user the x-bit.","commonSituations":"A shared server where git was installed by another user with mode 0700; a broken `chmod` that stripped execute bits; running pip as a different uid than the one that owns the binary; containers where binaries were copied without preserving exec permissions.","solutions":["Run `chmod +x $(which git)` (or `svn`/`hg`/`bzr`) to restore the execute bit.","Reinstall the VCS tool for the current user, or system-wide via the package manager so permissions are correct.","If you lack admin rights, install a local user copy (e.g. via conda/homebrew user install) and prepend its bin to PATH.","Check parent directory permissions do not block traversal to the binary."],"exampleFix":"# before\n$ pip install git+https://github.com/org/repo.git\n-> BadCommand: No permission to execute 'git'\n\n# after\n$ sudo chmod +x $(which git)\n$ pip install git+https://github.com/org/repo.git","handlingStrategy":"validation","validationCode":"import os, shutil, stat\n\ndef ensure_vcs_executable(name: str) -> None:\n    path = shutil.which(name)\n    if path is None:\n        raise EnvironmentError(f\"{name!r} not on PATH\")\n    if not os.access(path, os.X_OK):\n        raise PermissionError(f\"{path} is not executable by current user\")","typeGuard":"null","tryCatchPattern":"from pip._internal.exceptions import BadCommand\ntry:\n    pip_api_call(...)\nexcept BadCommand as e:\n    if \"No permission to execute\" in str(e):\n        # chmod/reinstall path\n        ...","preventionTips":["Install VCS tools via package manager so exec bits are correct.","Avoid copying binaries without preserving mode bits (`cp -p`).","On shared hosts, install a user-local copy if you lack sudo."],"tags":["vcs","permissions","environment","filesystem"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}