Skip to content

rbenv FileNotFoundError when installing markdownlint hook #1658

Description

@adithyabsk

I am trying to use https://github.com/markdownlint/markdownlint to lint my markdown files. I checked the issue tracker and don't seem to see any related issues.

I have .rbenv installed on my system and am wondering if that could be interfering with pre-commit?

.pre-commit-config.yaml

repos:
-   repo: https://github.com/markdownlint/markdownlint
    rev: master
    hooks:
    -   id: markdownlint

version information

pre-commit version: 2.7.1
sys.version:
    3.9.0 (default, Oct  9 2020, 16:41:50) 
    [Clang 12.0.0 (clang-1200.0.32.2)]
sys.executable: /usr/local/Cellar/pre-commit/2.7.1_1/libexec/bin/python
os.name: posix
sys.platform: darwin

error information

An unexpected error has occurred: FileNotFoundError: [Errno 2] No such file or directory: '/Users/adithyabalaji/.cache/pre-commit/repo09b5y8iv/rbenv-system/.install_state_v1staging'
Traceback (most recent call last):
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/error_handler.py", line 63, in error_handler
    yield
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/main.py", line 390, in main
    return run(args.config, store, args)
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/commands/run.py", line 388, in run
    install_hook_envs(hooks, store)
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/repository.py", line 206, in install_hook_envs
    _hook_install(hook)
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/repository.py", line 92, in _hook_install
    _write_state(hook.prefix, venv, _state(hook.additional_dependencies))
  File "/usr/local/Cellar/pre-commit/2.7.1_1/libexec/lib/python3.9/site-packages/pre_commit/repository.py", line 48, in _write_state
    with open(staging, 'w') as state_file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/adithyabalaji/.cache/pre-commit/repo09b5y8iv/rbenv-system/.install_state_v1staging'

Activity

  1. asottile commented on Oct 24, 2020

    @asottile
    Member

    hmm that's interesting, can you show env | grep -i rbenv or env | grep -i ruby

  2. adithyabsk commented on Oct 24, 2020

    @adithyabsk
    Author

    @asottile You know what, that hint led me to figure out the issue after banging my head against it for like an hour.

    Since I had installed rbenv using brew, I had a eval "$(rbenv init -)" in my .zshrc. The addition of the shim directory to the $PATH seemed to be the root cause of the problem. I'm still not entirely certain why that is the case.

    Before:

    $ env | grep -i rbenv
    PATH=/Users/adithyabalaji/.rbenv/shims:/Users/adithyabalaji/.cargo/bin:/Users/adithyabalaji/.jenv/shims:/Users/adithyabalaji/.nodenv/shims:/Users/adithyabalaji/.rbenv/shims:/usr/local/Cellar/pyenv-virtualenv/1.1.5/shims:/Users/adithyabalaji/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
    RBENV_SHELL=zsh
    

    After (removing the extra init, it's no longer in my PATH

    $ env | grep -i rbenv
    ~
    

    When the shim directory is not explicitly in my PATH the install runs smoothly.

  3. asottile commented on Oct 24, 2020

    @asottile
    Member

    interesting, it should probably still work even if you use rbenv, I'll see what I can do

  4. adithyabsk commented on Oct 24, 2020

    @adithyabsk
    Author

    Okay, thanks. For now, this workaround unblocks me. But, I'll keep an eye on this issue!

  5. avdv commented on Jun 10, 2021

    @avdv

    @asottile regarding my comments in #1668 sorry if that came off as rude, that was not my intention. I was trying to improve the situation, thank you ❤️

  6. lmilbaum commented on Mar 6, 2023

    @lmilbaum

    Would appreciate your help with a similar issue I am facing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions