Skip to content
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

Add extra checks when installing Rust - display some warning messages, if needed #366

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 18 additions & 1 deletion multiversx_sdk_cli/dependencies/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,13 @@ def is_installed(self, tag: str) -> bool:
return all(dependency is not None for dependency in dependencies)

def install(self, overwrite: bool) -> None:
self._check_install_env()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if someone uses the --overwrite flag, the existing CARGO_HOME and RUSTUP_HOME should reset to the default location, as if rust was not previously installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we should do that 🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


module = dependencies.get_module_by_key("rust")
tag: str = config.get_dependency_tag(module.key)

show_warning(f"We recommend using rust {tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.")
if not overwrite:
show_warning(f"We recommend using rust {tag}. If you'd like to overwrite your current version please run `mxpy deps install rust --overwrite`.")
logger.info(f"install: key={self.key}, tag={tag}, overwrite={overwrite}")

if overwrite:
Expand All @@ -289,6 +292,20 @@ def install(self, overwrite: bool) -> None:
self._install_wasm_opt()
self._install_twiggy()

def _check_install_env(self):
"""
See https://rust-lang.github.io/rustup/installation/index.html#choosing-where-to-install.
"""

current_cargo_home = os.environ.get("CARGO_HOME", None)
current_rustup_home = os.environ.get("RUSTUP_HOME", None)
if current_cargo_home:
show_warning(f"""CARGO_HOME variable is set to: {current_cargo_home}.
This may cause problems with the installation.""")
if current_rustup_home:
show_warning(f"""RUSTUP_HOME variable is set to: {current_rustup_home}.
This may cause problems with the installation of rust.""")

def _install_rust(self, tag: str) -> None:
installer_url = self._get_installer_url()
installer_path = self._get_installer_path()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "multiversx-sdk-cli"
version = "9.0.1"
version = "9.0.2"
authors = [
{ name="MultiversX" },
]
Expand Down
Loading