Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception if HOME is not an existing path #1640

Closed
dhinus opened this issue Aug 1, 2022 · 1 comment · Fixed by #1642
Closed

Exception if HOME is not an existing path #1640

dhinus opened this issue Aug 1, 2022 · 1 comment · Fixed by #1642

Comments

@dhinus
Copy link

dhinus commented Aug 1, 2022

how did you install flake8?

$ pip install flake8

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.9.13",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.9.0"
    },
    {
      "plugin": "pyflakes",
      "version": "2.5.0"
    }
  ],
  "version": "5.0.1"
}

describe the problem

what I expected to happen

flake8 should not raise an exception if $HOME points to an invalid directory

For example, when running as the nobody user in a Debian-based Docker image, and $HOME points to /nonexistent.

commands ran

# sudo -u nobody flake8
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/usr/local/lib/python3.9/site-packages/flake8/main/application.py", line 336, in run
    self._run(argv)
  File "/usr/local/lib/python3.9/site-packages/flake8/main/application.py", line 324, in _run
    self.initialize(argv)
  File "/usr/local/lib/python3.9/site-packages/flake8/main/application.py", line 296, in initialize
    cfg, cfg_dir = config.load_config(
  File "/usr/local/lib/python3.9/site-packages/flake8/options/config.py", line 73, in load_config
    config = _find_config_file(pwd)
  File "/usr/local/lib/python3.9/site-packages/flake8/options/config.py", line 26, in _find_config_file
    home_stat = _stat_key(home) if home != "~" else None
  File "/usr/local/lib/python3.9/site-packages/flake8/options/config.py", line 19, in _stat_key
    st = os.stat(s)
FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent'
@dhinus
Copy link
Author

dhinus commented Aug 1, 2022

This was introduced by #1618

Our CI runs many commands as the nobody user in a Docker container, and this means the new flake8 release broke a few of our pipelines. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants