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
No such file or directory: '/github/home/.cache/pre-commit/repo4mrvfeou/rbenv-system/.install_state_v1staging' #2799
Comments
you found an exact duplicate, why did you make an issue? |
Because I didn't understand how to fix my problem with the information provided on the other closed issue |
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 |
I've tried to check rbenv is installed in the container. It is not. |
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 |
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? |
@asottile I'm seeing the same issue described here, and do not have I've looked in 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 run rbenv init - . So are we expecting gem build ... to create the rbenv-system directory?
If the output of 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
|
I'm getting the same error on Windows, ruby 3.2.2, no rbenv. |
Seeing same thing as #2799 (comment) Occurs during repos:
- repo: https://github.com/rubocop/rubocop
rev: v1.52.0
hooks:
- id: rubocop
version information
error information
(I've partially elided the Python paths above.) There directory Ruby is installed via
By editing the source code to get the gem output I'm seeing this:
Gem env:
|
can you share your environment and gem and Ruby rc files? |
@asottile I edited my comment above yours to add more information, including the stdout/stderr of the gem build commands and the output of |
your |
Hmm, either Red Hat's packaging or possibly it's something with newer versions of gem? |
In my experience, you have to set both |
|
To be clear, the |
yes of course -- the useful part from
afaik that's coming from some config file -- are you sure this is an otherwise empty image? |
Here's what
Is that not what we expect? This image is based on Alma 9 and is customized for Python. Ruby is installed via |
Hmm, you're right, rubocop is installing to Let me see if I can track that down. |
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:
|
can you report it to them? unconditionally changing |
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: Can pre-commit use |
Work-around:
Blech. No more time for shaving yaks so that's the solution I'm going to live with. |
This looks to be an intended use-case by RubyGems: 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? |
And here's where upstream does their customization: https://src.fedoraproject.org/rpms/ruby/blob/rawhide/f/ruby.spec#_736 |
Note that Gentoo has similar customisation: https://github.com/gentoo/gentoo/blob/master/dev-ruby/rubygems/files/gentoo-defaults-5.rb |
@jaysoffian did you want to try your idea from #2799 (comment) ? |
@asottile this patch works for me under the environment described in #2799 (comment) diff --git i/pre_commit/languages/ruby.py w/pre_commit/languages/ruby.py
index 76631f2532..13cc628d80 100644
--- i/pre_commit/languages/ruby.py
+++ w/pre_commit/languages/ruby.py
@@ -125,6 +125,7 @@ def install_environment(
# Need to call this after installing to set up the shims
lang_base.setup_cmd(prefix, ('rbenv', 'rehash'))
+ envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
with in_env(prefix, version):
lang_base.setup_cmd(
prefix, ('gem', 'build', *prefix.star('.gemspec')),
@@ -135,6 +136,8 @@ def install_environment(
'gem', 'install',
'--no-document', '--no-format-executable',
'--no-user-install',
+ '--install-dir', os.path.join(envdir, 'gems'),
+ '--bindir', os.path.join(envdir, 'bin'),
*prefix.star('.gem'), *additional_dependencies,
),
) Would you like a PR? |
do you want to send a pr? |
|
RubyGems allows OS packagers to specify defaults for `--install-dir` and `--bindir` and these take precedence over `GEM_HOME`. The only way to override the defaults is to explicitly specify the options ourselves when running `gem install`. Examples of OSes where this is the case are RedHat 9.2 and Gentoo. Fixes pre-commit#2799.
RubyGems allows OS packagers to specify defaults for `--install-dir` and `--bindir` and these take precedence over `GEM_HOME`. The only way to override the defaults is to explicitly specify the options ourselves when running `gem install`. Examples of OSes where this is the case are RedHat 9.2 and Gentoo. Fixes pre-commit#2799.
RubyGems allows OS packagers to specify defaults for `--install-dir` and `--bindir` and these take precedence over `GEM_HOME`. The only way to override the defaults is to explicitly specify the options ourselves when running `gem install`. Examples of OSes where this is the case are RedHat 9.2 and Gentoo. Fixes pre-commit#2799.
search you tried in the issue tracker
Found this one #1658
describe your issue
Running pre-commit GitHub action in a custom container.
Workflow is broken:
pre-commit --version
pre-commit 2.20.0
.pre-commit-config.yaml
~/.cache/pre-commit/pre-commit.log (if present)
No response
The text was updated successfully, but these errors were encountered: