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

Existing Installation Detection Enhancements #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rgajason
Copy link

fixes #53

@rgajason
Copy link
Author

Note that -A is not part of POSIX ls. I am unable to test these changes outside of macOS and Linux.

echo "Cannot install to requested location."
echo ""
echo "======================================================================================================"
echo " A file of the same name as the installation directory exists."
Copy link
Member

Choose a reason for hiding this comment

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

I really don't see why we should check for the presence of a file here. This seems like a very odd situation to be in and perhaps something that you've gotten yourself into by accidentally touching a file called ~/.sdkman. This seems highly unlikely to ever happen out in the wild and feels over-defensive to me.

Copy link
Author

Choose a reason for hiding this comment

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

I understand the concern, just offering it up while I was in making enhancements. The installer makes a lot of assumptions about the availability of the installation directory and throws all sorts of errors if there is a file in the way. It's obviously your call, but what's the harm in better testing that is simple?

echo "Looking for a previous installation of SDKMAN..."
if [ -d "$SDKMAN_DIR" ]; then
if [ -d "$SDKMAN_DIR" ] && [ ! -z $(ls -A "$SDKMAN_DIR") ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Why would an empty ~/.sdkman directory be present? If it is empty, why not simply delete the empty directory and re-attempt the installation?

Copy link
Author

Choose a reason for hiding this comment

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

I put a detailed explanation of why the ability to install into an existing, empty directory is necessary here: #53

Check out the "Why does this matter?" heading. Short story is, allows unprivileged users to install in privileged locations.

@@ -9,10 +9,11 @@ SDKMAN_VERSION="@cliVersion"
SDKMAN_PLATFORM=$(uname)

if [ -z "$SDKMAN_DIR" ]; then
SDKMAN_DIR="$HOME/.sdkman"
SDKMAN_DIR=$(readlink -f "$HOME/.sdkman")
Copy link
Member

Choose a reason for hiding this comment

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

If we are going to allow these changes, they should only be done in the beta hook until we can verify that they work on all platforms in the beta channel.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if readlink -f works on Mac without installing coreutils.

Copy link
Member

@marc0der marc0der left a comment

Choose a reason for hiding this comment

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

All in all, I'm very hesitant to touch this code because of the sheer risk that it poses. This code is very difficult to test, and I'd prefer not to run the risk of outages.

@rgajason
Copy link
Author

Hesitation is understood. If you have ideas about a different method I could take to help provide some code to address this situation I'm happy to make changes. Perhaps we could introduce some sort of "force" flag for the installer that defaults to "no" that would instruct the installer to go ahead and keep going even if the install directory already exists.

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.

Existing Installation Detection Issues
3 participants