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

fix: Add --install-python=false to install invocation. #85

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

fiadliel
Copy link
Contributor

Description

The installer may attempt to install a Python package on MacOS, if the versions do not line up with the minimum version blessed by the script. To do this, it attempts to run sudo.

This disables the installation with an install flag.

Motivation and Context

Having a plugin modify global state (like installing a version of python globally) goes against the very reason for having an asdf plugin. Also, asdf installs should be non-interactive, and sudo requires user input.

This causes the minimum supported version to be 352.0.0 or greater (as the first version with this flag).

Alternatives to remove backwards compatibility issues with the change:

  • only add flag for versions >= 352 (adds complexity to install script)
  • install files from archive instead of install script (large change, and removes some plugin functionality)

Fixes #82.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Installed the latest gcloud (450) using my version of the plugin.
  • Verified that the install command included the extra argument --install-python=false.
  • Verified that the plugin did not attempt to install a Python package using sudo.
  • Verified that gcloud worked correctly after installation.
  • Verified the same with a number of older versions of gcloud.
  • The first version that failed due to the extra argument was 351.0.0.

Checklist:

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

The installer may attempt to install a Python package on MacOS,
if the versions do not line up with the minimum version blessed
by the script. To do this, it attempts to run sudo.

This disables the installation with an install flag.

The flag is present in all versions of gcloud since 352.0.0.

Fixes jthegedus#82.
bin/install Show resolved Hide resolved
@tancnle
Copy link
Contributor

tancnle commented Jan 10, 2024

@jthegedus @fiadliel Thank you for your work here. I stumbled across this when trying to install gcloud 459.0.0.

@jthegedus Would it be possible to directly apply the suggested changes in #85 (comment) so we can unblock this PR? 🙏🏼

bin/install Outdated Show resolved Hide resolved
@tancnle
Copy link
Contributor

tancnle commented Jan 10, 2024

I can confirm @jthegedus suggestion work after patching the install file locally and running mise install glcloud again.

diff --git bin/install bin/install
index bd1489a..1e900af 100755
--- bin/install
+++ bin/install
@@ -32,7 +32,12 @@ install_gcloud() {
        log_success "extracted!"
 
        log_info "🚧  installing..."
-       "${ASDF_INSTALL_PATH}/install.sh" --usage-reporting=false --path-update=false --quiet
+       if [[ "${ASDF_INSTALL_VERSION}" > "352.0.0" ]]; then
+               "${ASDF_INSTALL_PATH}/install.sh" --usage-reporting=false --path-update=false --install-python=false --quiet
+       else
+               "${ASDF_INSTALL_PATH}/install.sh" --usage-reporting=false --path-update=false --quiet
+       fi
+       # "${ASDF_INSTALL_PATH}/install.sh" --usage-reporting=false --path-update=false --quiet
        # test executable
        test -x "${ASDF_INSTALL_PATH}/bin/gcloud" || log_failure_and_exit "Expected ${ASDF_INSTALL_PATH}/bin/gcloud to be executable."
        log_success "gcloud ${ASDF_INSTALL_VERSION} installed!"
❯ mise install
######################################################################## 100.0%
Your current Google Cloud CLI version is: 459.0.0
The latest available version is: 459.0.0
To install or remove components at your current SDK version [459.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID
To update your SDK installation to the latest version [459.0.0], run:
  $ gcloud components update
==> Source [/Users/tanle/.local/share/mise/installs/gcloud/459.0.0/path.fish.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.
mise [email protected] ✓ installed

Copy link
Owner

@jthegedus jthegedus left a comment

Choose a reason for hiding this comment

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

Thanks both! Sorry this took so long! 🙇

@jthegedus jthegedus merged commit 81b5d2c into jthegedus:main Jan 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gcloud 449.0.0 attempts to install python as root on MacOS
3 participants