Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pre_commit/languages/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def _add_dependencies(
lang_base.setup_cmd(prefix, ('cargo', 'add', *crates))


def install_rust_with_toolchain(toolchain: str) -> None:
def install_rust_with_toolchain(toolchain: str, envdir: str) -> None:
with tempfile.TemporaryDirectory() as rustup_dir:
with envcontext((('RUSTUP_HOME', rustup_dir),)):
with envcontext((('CARGO_HOME', envdir), ('RUSTUP_HOME', rustup_dir))):
# acquire `rustup` if not present
if parse_shebang.find_executable('rustup') is None:
# We did not detect rustup and need to download it first.
Expand Down Expand Up @@ -145,7 +145,7 @@ def install_environment(
ctx.enter_context(in_env(prefix, version))

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

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