Skip to content

Commit 9a7ed8b

Browse files
committed
Force gem installation into envdir
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 #2799.
1 parent f073f8e commit 9a7ed8b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pre_commit/languages/ruby.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def _install_ruby(
114114
def install_environment(
115115
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
116116
) -> None:
117+
envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
118+
117119
if version != 'system': # pragma: win32 no cover
118120
_install_rbenv(prefix, version)
119121
with in_env(prefix, version):
@@ -135,6 +137,8 @@ def install_environment(
135137
'gem', 'install',
136138
'--no-document', '--no-format-executable',
137139
'--no-user-install',
140+
'--install-dir', os.path.join(envdir, 'gems'),
141+
'--bindir', os.path.join(envdir, 'gems', 'bin'),
138142
*prefix.star('.gem'), *additional_dependencies,
139143
),
140144
)

0 commit comments

Comments
 (0)