Skip to content

Commit

Permalink
set RUSTUP_HOME when using a non-system rust
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Feb 28, 2023
1 parent 294590f commit 2700a7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pre_commit/languages/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ def install_environment(
else:
packages_to_install.add((package,))

with in_env(prefix, version):
with contextlib.ExitStack() as ctx:
ctx.enter_context(in_env(prefix, version))

if version != 'system':
install_rust_with_toolchain(_rust_toolchain(version))

tmpdir = ctx.enter_context(tempfile.TemporaryDirectory())
ctx.enter_context(envcontext((('RUSTUP_HOME', tmpdir),)))

if len(lib_deps) > 0:
_add_dependencies(prefix, lib_deps)

Expand Down

0 comments on commit 2700a7d

Please sign in to comment.