Skip to content

Commit a54391e

Browse files
committed
Force gem installation into GEM_HOME
When `--user-install` is set in the gemrc config file, `gem` ignores `GEM_HOME`. `--no-user-install` prevents this behaviour.
1 parent cc9d950 commit a54391e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pre_commit/languages/ruby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def install_environment(
138138
(
139139
'gem', 'install',
140140
'--no-document', '--no-format-executable',
141+
'--no-user-install',
141142
*prefix.star('.gem'), *additional_dependencies,
142143
),
143144
)

tests/repository_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ def test_run_a_ruby_hook(tempdir_factory, store):
332332
)
333333

334334

335+
def test_run_a_ruby_hook_with_user_install_set(tempdir_factory, store, tmpdir):
336+
gemrc = tmpdir.join('gemrc')
337+
gemrc.write('gem: --user-install\n')
338+
with envcontext((('GEMRC', str(gemrc)),)):
339+
test_run_a_ruby_hook(tempdir_factory, store)
340+
341+
335342
@xfailif_windows # pragma: win32 no cover
336343
def test_run_versioned_ruby_hook(tempdir_factory, store):
337344
_test_hook_repo(

0 commit comments

Comments
 (0)