You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No such file or directory: '/github/home/.cache/pre-commit/repo4mrvfeou/rbenv-system/.install_state_v1staging' #2799
[INFO] Installing environment for https://github.com/markdownlint/markdownlint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: FileNotFoundError: [Errno 2] No such file or directory: '/github/home/.cache/pre-commit/repo4mrvfeou/rbenv-system/.install_state_v1staging'
I've tried to check rbenv is installed in the container. It is not.
I've checked the ruby version. It is 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux].
What else can I try?
clearly that container is broken -- why do you need that container? also looks like your CI is running both pre-commit.ci and github actions pre-commit -- which is kind of wasteful
clearly that container is broken -- why do you need that container? also looks like your CI is running both pre-commit.ci and github actions pre-commit -- which is kind of wasteful
Agree. It is broken but I don't have enough ruby expriance to figure out what is broken and fix it. The container is built by me and it used for baking all my team tooling in a container image instead of installing/upgrading them on our laptops.
if your company wants paid support I'm happy to provide it -- but this seems like you've already got several solutions which don't involve that container
I am pocking the pre-commit code. It seems like the language ruby ENVIRONMENT_DIR is set to rbenv while the container image doesn't have it. The error is persistent even if rbenv is installed.
This seems to be responsible for creating the environment directory. If the version is system, we don't run rbenv init -. So are we expecting gem build ... to create the rbenv-system directory?
If the output of gem build ... contains some useful information on what's going wrong, it's being dropped:
This calls `cmd_output_b() but ignores the return values. Perhaps more verbose output is needed in the case of an error.
Contents of ~/.cache/pre-commit/pre-commit.log
version information
pre-commit version: 3.2.2
git --version: git version 2.39.2
sys.version:
3.10.10 (main, Mar 26 2023, 19:47:56) [GCC 12.2.1 20230121]
sys.executable: /home/pbarker/Projects/pbarker.dev/venv/bin/python
os.name: posix
sys.platform: linux
error information
An unexpected error has occurred: FileNotFoundError: [Errno 2] No such file or directory: '/home/pbarker/.cache/pre-commit/repoiuzm_cni/rbenv-system/.install_state_v1staging'
Traceback (most recent call last):
File "/home/pbarker/Projects/pbarker.dev/venv/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/home/pbarker/Projects/pbarker.dev/venv/lib/python3.10/site-packages/pre_commit/main.py", line 409, in main
return run(args.config, store, args)
File "/home/pbarker/Projects/pbarker.dev/venv/lib/python3.10/site-packages/pre_commit/commands/run.py", line 442, in run
install_hook_envs(to_install, store)
File "/home/pbarker/Projects/pbarker.dev/venv/lib/python3.10/site-packages/pre_commit/repository.py", line 248, in install_hook_envs
_hook_install(hook)
File "/home/pbarker/Projects/pbarker.dev/venv/lib/python3.10/site-packages/pre_commit/repository.py", line 111, in _hook_install
with open(staging, 'w') as state_file:
FileNotFoundError: [Errno 2] No such file or directory: '/home/pbarker/.cache/pre-commit/repoiuzm_cni/rbenv-system/.install_state_v1staging'
pre-commit version: 3.3.2
git --version: git version 2.39.3
sys.version:
3.11.2 (main, Mar 9 2023, 21:49:05) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
sys.executable: .../bin/python3.11
os.name: posix
sys.platform: linux
error information
An unexpected error has occurred: FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/pre-commit/repo238a8i_c/rbenv-system/.install_state_v1staging'
Traceback (most recent call last):
File ".../lib/python3.11/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File ".../lib/python3.11/site-packages/pre_commit/main.py", line 410, in main
return install_hooks(args.config, store)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/pre_commit/commands/install_uninstall.py", line 146, in install_hooks
install_hook_envs(all_hooks(load_config(config_file), store), store)
File ".../lib/python3.11/site-packages/pre_commit/repository.py", line 248, in install_hook_envs
_hook_install(hook)
File ".../lib/python3.11/site-packages/pre_commit/repository.py", line 111, in _hook_install
with open(staging, 'w') as state_file:
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/pre-commit/repo238a8i_c/rbenv-system/.install_state_v1staging'
(I've partially elided the Python paths above.)
There directory /root/.cache/pre-commit/repo238a8i_c/rbenv-system does NOT exist. I'm not sure what's supposed to create it.
Ruby is installed via dnf -y -q install ruby ruby-devel:
By editing the source code to get the gem output I'm seeing this:
[root@e736e09e3d9d foo]# pre-commit install-hooks
cmd=('git', 'rev-parse', '--show-cdup')
cmd=('git', 'rev-parse', '--is-inside-git-dir')
[INFO] Installing environment for https://github.com/rubocop/rubocop.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
cmd=('gem', 'build', 'rubocop.gemspec')
stdout:
Successfully built RubyGem
Name: rubocop
Version: 1.52.0
File: rubocop-1.52.0.gem
stderr:
WARNING: open-ended dependency on parser (>= 3.2.0.0) is not recommended
if parser is semantically versioned, use:
add_runtime_dependency 'parser', '~> 3.2', '>= 3.2.0.0'
WARNING: See https://guides.rubygems.org/specification-reference/ for help
cmd=('gem', 'install', '--no-document', '--no-format-executable', '--no-user-install', 'rubocop-1.52.0.gem')
stdout:
Successfully installed rubocop-1.52.0
1 gem installed
stderr:
An unexpected error has occurred: FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/pre-commit/repo98m3m8cs/rbenv-system/.install_state_v1staging'
cmd=('git', '--version')
Check the log at /root/.cache/pre-commit/pre-commit.log
Hmm, you're right, rubocop is installing to /usr/local/share/gems/gems/rubocop-1.52.. I gather we want it to be installing to /root/.cache/pre-commit/repo98m3m8cs/rbenv-system/gems.
Activity
asottile commentedon Mar 6, 2023
you found an exact duplicate, why did you make an issue?
lmilbaum commentedon Mar 6, 2023
Because I didn't understand how to fix my problem with the information provided on the other closed issue
asottile commentedon Mar 6, 2023
you've not shown what you've tried so I don't know how to help you. right now it looks like you've tried nothing
lmilbaum commentedon Mar 6, 2023
I've tried to check rbenv is installed in the container. It is not.
I've checked the ruby version. It is 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux].
What else can I try?
asottile commentedon Mar 6, 2023
clearly that container is broken -- why do you need that container? also looks like your CI is running both pre-commit.ci and github actions pre-commit -- which is kind of wasteful
lmilbaum commentedon Mar 6, 2023
Agree. It is broken but I don't have enough ruby expriance to figure out what is broken and fix it. The container is built by me and it used for baking all my team tooling in a container image instead of installing/upgrading them on our laptops.
asottile commentedon Mar 6, 2023
if your company wants paid support I'm happy to provide it -- but this seems like you've already got several solutions which don't involve that container
lmilbaum commentedon Mar 7, 2023
I am pocking the pre-commit code. It seems like the language ruby ENVIRONMENT_DIR is set to
rbenvwhile the container image doesn't have it. The error is persistent even ifrbenvis installed.lmilbaum commentedon Mar 7, 2023
In repository.py line 108, it tries to write a file in a directory which doesn't exist. Could you provide me a hint where it is created?
pbrkr commentedon Apr 16, 2023
@asottile I'm seeing the same issue described here, and do not have
rbenvinstalled so #1658 doesn't give a solution.I've looked in
~/.cache/pre-commit/pre-commit.logbut I don't see any useful information.Looking at the code:
pre-commit/pre_commit/languages/ruby.py
Line 114 in 8d84a7a
This seems to be responsible for creating the environment directory. If the version is
system, we don't runrbenv init -. So are we expectinggem build ...to create therbenv-systemdirectory?If the output of
gem build ...contains some useful information on what's going wrong, it's being dropped:pre-commit/pre_commit/util.py
Line 89 in 8d84a7a
This collects the stdout & stderr of the called process and returns them.
pre-commit/pre_commit/lang_base.py
Line 91 in 8d84a7a
This calls `cmd_output_b() but ignores the return values. Perhaps more verbose output is needed in the case of an error.
Contents of
~/.cache/pre-commit/pre-commit.logversion information
error information
seanharmer commentedon Jun 6, 2023
I'm getting the same error on Windows, ruby 3.2.2, no rbenv.
pre-commit.log
jaysoffian commentedon Jun 7, 2023
Seeing same thing as #2799 (comment)
Occurs during
pre-commit install-hookswith this hook:version information
error information
(I've partially elided the Python paths above.)
There directory
/root/.cache/pre-commit/repo238a8i_c/rbenv-systemdoes NOT exist. I'm not sure what's supposed to create it.Ruby is installed via
dnf -y -q install ruby ruby-devel:By editing the source code to get the gem output I'm seeing this:
Gem env:
asottile commentedon Jun 7, 2023
can you share your environment and gem and Ruby rc files?
jaysoffian commentedon Jun 7, 2023
@asottile I edited my comment above yours to add more information, including the stdout/stderr of the gem build commands and the output of
gem env.7 remaining items
jaysoffian commentedon Jun 8, 2023
Hmm, you're right, rubocop is installing to
/usr/local/share/gems/gems/rubocop-1.52.. I gather we want it to be installing to/root/.cache/pre-commit/repo98m3m8cs/rbenv-system/gems.Let me see if I can track that down.
jaysoffian commentedon Jun 8, 2023
This is apparently an issue with Alma Linux (aka Red Hat) 9.2. You can repro it with:
And I gather it's an issue with how Alma Linux packages up rubygems:
asottile commentedon Jun 8, 2023
can you report it to them? unconditionally changing
--install-dirseems wrong especially when the user is requesting a different onejaysoffian commentedon Jun 8, 2023
I'm really not a fan of Ruby, but I don't think this is something RedHat is likely to fix. FWIW:
That's where it comes from. RedHat's answer will probably be: "Pound sand. You shouldn't be using the system ruby. Install your own ruby."
RubyGems accommodated this issue:
ruby/rubygems#5566
Can pre-commit use
--install-dirinstead ofGEM_HOME?jaysoffian commentedon Jun 8, 2023
Work-around:
Blech. No more time for shaving yaks so that's the solution I'm going to live with.
jaysoffian commentedon Jun 8, 2023
This looks to be an intended use-case by RubyGems:
ruby/rubygems#2116
This means that pre-commit is not compatible with any packaged gem that uses this feature.
If you don't want to accommodate it I understand. Would you accept a PR that at least causes pre-commit to emit a more helpful error message?
jaysoffian commentedon Jun 8, 2023
And here's where upstream does their customization:
https://src.fedoraproject.org/rpms/ruby/blob/rawhide/f/ruby.spec#_736
https://src.fedoraproject.org/rpms/ruby/blob/rawhide/f/operating_system.rb
pbrkr commentedon Jun 8, 2023
Note that Gentoo has similar customisation: https://github.com/gentoo/gentoo/blob/master/dev-ruby/rubygems/files/gentoo-defaults-5.rb
asottile commentedon Jun 8, 2023
@jaysoffian did you want to try your idea from #2799 (comment) ?
jaysoffian commentedon Jun 12, 2023
@asottile this patch works for me under the environment described in #2799 (comment)
Would you like a PR?
asottile commentedon Jun 12, 2023
do you want to send a pr?
jaysoffian commentedon Jun 12, 2023
Will do.Edit: #2905Force gem installation into envdir
Force gem installation into envdir
Force gem installation into envdir