Skip to content

Default rcfile locations are scanned even when --rcfile option is specified #7169

Closed
@daisuke834

Description

@daisuke834

Bug description

With the latest version 2.14.4, pylint scans the default rcfile locations even when --rcfile option with valid rcfile path is specified. It is problematic because it caused a permission error when an user doesn't have an access permissions to the pre-determined default path of default rcfile files.

Configuration

No response

Command used

$ pylint --rcfile /config/pyproject.toml

Pylint output

Traceback (most recent call last):
  File "/home/myhome/.pyenv/versions/3.10.5/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/__init__.py", line 22, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/lint/__init__.py", line 19, in <module>
    from pylint.config.exceptions import ArgumentPreprocessingError
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/__init__.py", line 27, in <module>
    from pylint.config.environment_variable import PYLINTRC
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/environment_variable.py", line 11, in <module>
    PYLINTRC = find_pylintrc()
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 94, in find_pylintrc
    for config_file in find_default_config_files():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 76, in find_default_config_files
    if home_rc.is_file():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1322, in is_file
    return S_ISREG(self.stat().st_mode)
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '/home/myhome/.config/pylintrc'

Expected behavior

With the prior version at least 2.13.5, the problem didn't happen. 2.13.5 don't seem to scan default rcfile locations when --rcfile option with valid rcfile path is specified. Similar to 2.13.5, I think the latest version 2.14.4 and later version are also expected to skip scanning the default paths when --rcfile option with valid path is specified.

Pylint version

Used 2.14.4.

`$ pylint --version` didn't work because of the issue.

$ pylint --version
Traceback (most recent call last):
  File "/home/myhome/.pyenv/versions/3.10.5/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/__init__.py", line 22, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/lint/__init__.py", line 19, in <module>
    from pylint.config.exceptions import ArgumentPreprocessingError
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/__init__.py", line 27, in <module>
    from pylint.config.environment_variable import PYLINTRC
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/environment_variable.py", line 11, in <module>
    PYLINTRC = find_pylintrc()
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 94, in find_pylintrc
    for config_file in find_default_config_files():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pylint/config/find_default_config_files.py", line 76, in find_default_config_files
    if home_rc.is_file():
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1322, in is_file
    return S_ISREG(self.stat().st_mode)
  File "/home/myhome/.pyenv/versions/3.10.5/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '/home/myhome/.config/pylintrc'

OS / Environment

Ubuntu focal by using the docker image via FROM ubuntu:focal-20220531

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

Bug 🪲ConfigurationRelated to configurationNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationRegression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions