Make first Version for Candidate default without confirmation #442

Open
squarepegsys opened this Issue Jul 17, 2016 · 7 comments

Projects

None yet

2 participants

@squarepegsys

This is similar to #425 but that fix didn't work. This happens in both ZSH and Bash. This is not a new installation of sdkman -- it used to work but I don't know what I changed.

bash-3.2$ sdk version
SDKMAN 5.0.0+51
bash-3.2$ sdk use grails 3.0.16

Using grails version 3.0.16 in this shell.
bash-3.2$ which grails
bash-3.2$ grails
bash: grails: command not found

Because you asked for this in the other question:

bash-3.2$ tree ~/.sdkman/candidates/grails/3.0.16|head -n 20
/Users/mikeh/.sdkman/candidates/grails/3.0.16
├── INSTALL
├── LICENSE
├── bin
│   ├── grails
│   └── grails.bat
├── dist
│   ├── grails-async-3.0.16-javadoc.asc
│   ├── grails-async-3.0.16-javadoc.asc.sha1
│   ├── grails-async-3.0.16-javadoc.jar
│   ├── grails-async-3.0.16-javadoc.jar.sha1
│   ├── grails-async-3.0.16-sources.asc
│   ├── grails-async-3.0.16-sources.asc.sha1
│   ├── grails-async-3.0.16-sources.jar
│   ├── grails-async-3.0.16-sources.jar.sha1
│   ├── grails-async-3.0.16.asc
│   ├── grails-async-3.0.16.asc.sha1
│   ├── grails-async-3.0.16.jar
│   ├── grails-async-3.0.16.jar.sha1
│   ├── grails-bootstrap-3.0.16-javadoc.asc

bash-3.2$ ls -lah ~/.sdkman/candidates/grails/3.0.16/bin
total 40
drwxrwxr-x  4 mikeh  staff   136B Apr 14 13:37 .
drwxr-xr-x  9 mikeh  staff   306B Apr 14 13:38 ..
-rwxrwxr-x  1 mikeh  staff   8.9K Apr 14 13:37 grails
-rw-rw-r--  1 mikeh  staff   6.4K Apr 14 13:37 grails.bat

It doesn't seem to matter if I switch versions.

@marc0der
Member

Could I ask you to paste the dump of the following command please?

$ ls -lah ~/.sdkman/candidates/grails
@squarepegsys

Here you go:

bash-3.2$ ls -lah ~/.sdkman/candidates/grails
total 8
drwxr-xr-x  7 mikeh  staff   238B Jul 17 07:49 .
drwxr-xr-x  5 mikeh  staff   170B Apr 13 08:56 ..
drwxr-xr-x  9 mikeh  staff   306B Dec  3  2015 3.0.10
drwxr-xr-x  9 mikeh  staff   306B Dec 22  2015 3.0.11
drwxr-xr-x  9 mikeh  staff   306B Apr 14 13:38 3.0.16
drwxr-xr-x  9 mikeh  staff   306B Apr 28 13:18 3.0.17
lrwxr-xr-x  1 mikeh  staff    33B Mar  7 09:47 current -> /Users/mikeh/.sdkman/grails/2.5.2
@marc0der
Member

It would seem like you once had Grails 2.5.2 installed, then somehow removed it without the uninstall command. Is that possible?

As you can see from the dump, you have a current symlink pointing to an installation that isn't present. You can easily fix this by running sdk default, which will reset the current symlink to the latest stable version.

I'd love to know how it got into that state. It's the first time I've come across this one.

@squarepegsys

I'd love to know how it got in this state too! But setting a new default doesn't seem to fix this:

 bash-3.2$ sdk default grails

 Default grails version set to 3.1.9
 bash-3.2$ grails
 bash: grails: command not found
 bash-3.2$ ls -lah ~/.sdkman/candidates/grails
 total 8
 drwxr-xr-x  8 mikeh  staff   272B Jul 18 06:30 .
 drwxr-xr-x  5 mikeh  staff   170B Apr 13 08:56 ..
 drwxr-xr-x  9 mikeh  staff   306B Dec  3  2015 3.0.10
 drwxr-xr-x  9 mikeh  staff   306B Dec 22  2015 3.0.11
 drwxr-xr-x  9 mikeh  staff   306B Apr 14 13:38 3.0.16
 drwxr-xr-x  9 mikeh  staff   306B Apr 28 13:18 3.0.17
 drwxr-xr-x  9 mikeh  staff   306B Jun 29 06:43 3.1.9
 lrwxr-xr-x  1 mikeh  staff    44B Jul 18 06:30 current -> /Users/mikeh/.sdkman/candidates/grails/3.1.9

I am not against just removing my ~/.sdkman folder and starting fresh, but I too would like to know how it got into this state.

@marc0der
Member

You would need to open a new terminal (or source the sdkman-init.sh) to recover from the bad state you were in. Can you give that a try?

Also, can you let me know how you go about installing a new version of Grails? Do you use the sdk install command? Do you answer Y when asked if it should be the new default version?

I'm asking this since I've come across people using the sdk use command to install candidates, then don't answer Y at the end of the flow. This potentially leaves the setup in a bad state.

@squarepegsys

Ok I started a new shell and now it works.

And I always have said 'N' to the "make this default?" question -- we use lots of version of Grails (even 2.1.1) and so I don't want new installed one to sneak up on me later.

@marc0der
Member

Excellent, as I thought then.

It does make sense having your very first version marked as default though (ie always answer Y here). If we don't, we sit with an orphaned candidate, and nothing to add to the path when the shell is initialised (this is what you were seeing).

I'm going to rename this ticket to reflect that scenario, and will add it to the backlog.

@marc0der marc0der changed the title from sdkman lets you choose, but not use Grails to Do not offer to make default on first Version installation Jul 18, 2016
@marc0der marc0der changed the title from Do not offer to make default on first Version installation to Make first Version for Candidate default without confirmation Jul 18, 2016
@marc0der marc0der added the bug label Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment