Jabba-Team / jabba

(cross-platform) Java Version Manager
Apache License 2.0
141 stars 11 forks source link

(Windows) Updated installation script not working #6

Closed ZaLiTHkA closed 2 years ago

ZaLiTHkA commented 2 years ago

hey @patrick-mccourt, just tried to "upgrade" from my previous Jabba install (original shyiko repo), but I'm running into some issues with this one..

I'm not all that familiar with GitHub's API though, so all I can do here is drop some notes on what's happening. please do let me know if there is anything specific you'd like me to check, yeah?


first I checked the current value of [Net.ServicePointManager]::SecurityProtocol, which came back as SystemDefault. then I ran the command..

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

..which changed this to Tls12. I then ran the following installation command..

Invoke-Expression (Invoke-WebRequest https://github.com/Jabba-Team/jabba/raw/main/install.ps1 -UseBasicParsing).Content

..which throws out the following error:

Invoke-RestMethod:
Line |
   9 |  … aVersion = (Invoke-RestMethod https://api.github.com/repos/Jabba-Team …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-the-latest-release"}

digging a little deeper, if I try run the following command directly:

Invoke-RestMethod https://api.github.com/repos/Jabba-Team/jabba/releases/tags/latest

I see the following error:

Invoke-RestMethod: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-release-by-tag-name"}

any ideas what might be going wrong here?

patrick-mccourt commented 2 years ago

Thanks @ZaLiTHkA, As you may have guessed, I hadn't yet tested this on Windows. I am going to be away for the rest of the weekend so I'll look at this properly on Monday

But for now, I've re-named the release now so it matches the tag so that one problem should be okay now.

ZaLiTHkA commented 2 years ago

no worries.. please do let me know if you do need some extra testing then, I have both Windows 10 and 11 with PowerShell 7.2.6. 👍🏼

patrick-mccourt commented 2 years ago

Hi @ZaLiTHkA, I've just been tinkering with this on Win11 with PowerShell 5.1 and get the same as you did above. I believe the problem is that 0.12.0-alpha1 is marked as a pre-release and the api call to latest fetches the latest release, but there are none.

There are a couple of things you can do as a workaround that seem to work for me:

1) Set the JABBA_INDEX variable with your current installation:

$env:JABBA_INDEX='https://raw.githubusercontent.com/Jabba-Team/jabba/main/index.json'

I've tried this myself by installing 0.11.2 from the original repo and setting the variable, ls-remote gives me the updated jdk indexes and I was able to install temurin 19 with jabba install temurin@19

2) Set the JABBA_VERSION variable before running the new install script:

$env:JABBA_VERSION='0.12.0-alpha1'

then the install command, this skips the api call to find 'latest' and installs the alpha version from the new repo.

Option 1 is probably my recommendation for now, as in terms of functionality, 0.11.2 is exactly the same as 0.12.0-alpha1, just a change of repository. Once a full release of 0.12.0 is available these workarounds won't be needed.

If you did want to go ahead with upgrading now, then I'd be curious on the experience and if all your previously installed jdks were all still present and working. I'd recommend making a copy of your %USERPROFILE%/.jabba folder before trying again though, just to be safe.

Please note as well, the names of some of the provided jdks may be different, so the readme is out of date, for example openjdk is not available in the new index, it's called oracle_open_jdk instead. There may be other differences too.

ZaLiTHkA commented 2 years ago

Hi @ZaLiTHkA, I've just been tinkering with this on Win11 with PowerShell 5.1 and get the same as you did above. I believe the problem is that 0.12.0-alpha1 is marked as a pre-release and the api call to latest fetches the latest release, but there are none.

yup, that makes perfect sense.. I haven't really used the GH API all that much, but that is logical behaviour after all. (:


with that said, I also just realised something.. at present, I'm only using this on Windows. so each time I've come to the README file to grab the install command, I've simply scrolled straight to it.

meanwhile, further up the same file it actually mentions installing specific versions by setting JABBA_VERSION first. 🤦🏼 really helps to RTFM hey.


anyways, I opted to install 0.12.0-alpha1, simply because that feels like the most appropriate way to test it.. so, the installation went without a hitch:

# 00:25:01 littl@Monstrosity   ~ 
❯ $env:JABBA_VERSION='0.12.0-alpha1'
# 00:25:22 littl@Monstrosity   ~ 
❯ $env:JABBA_VERSION
0.12.0-alpha1
# 00:25:27 littl@Monstrosity   ~ 
❯ iex (iwr https://github.com/Jabba-Team/jabba/raw/main/install.ps1 -UseBasicParsing).Content
Installing v0.12.0-alpha1...

Skipped update of D:\Users\Dre\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 (source string already present)

Installation completed
(if you have any problems please report them at https://github.com/Jabba-Team/jabba/issues)
# 00:27:41 littl@Monstrosity   ~ 
❯ jabba --version
0.12.0-alpha1

..and all of my existing Java installations still work as expected:

# 00:28:08 littl@Monstrosity   ~ 
❯ jabba ls
zulu@1.17.0-0
zulu@1.11.0
zulu@1.8.282
zulu@1.7.292
# 00:29:13 littl@Monstrosity   ~ 
❯ cat C:\Users\littl\.jabba\default.alias
zulu@1.11.0
# 00:30:08 littl@Monstrosity   ~ 
❯ java -version
openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment Zulu11.45+27-CA (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.45+27-CA (build 11.0.10+9-LTS, mixed mode)
# 00:31:17 littl@Monstrosity   ~ 
❯ jabba use zulu@1.7.292
# 00:31:57 littl@Monstrosity   ~ 
❯ java -version
openjdk version "1.7.0_292"
OpenJDK Runtime Environment (Zulu 7.44.0.11-CA-win64) (build 1.7.0_292-b07)
OpenJDK 64-Bit Server VM (Zulu 7.44.0.11-CA-win64) (build 24.292-b07, mixed mode)

lastly, I am seeing a metric ton of JDKs (won't post the output, don't worry) when I run jabba ls-remote, so it's most definitely working with the new list. 🖖🏼

ZaLiTHkA commented 2 years ago

in a separate comment now... what I thought was an issue, was simply a misunderstanding. commit a0d6422 does nothing to install.ps1 other than update GitHub repo URLs.

I'd like to peruse the README file properly now. which means I will most likely want to restructure it.. I kinda already do now.

so I'll close this issue off for now then, since it doesn't serve much purpose. I might be sending a documentation PR in the near future then. (:

patrick-mccourt commented 2 years ago

Hi @ZaLiTHkA, just as an FYI, I've just released 0.12.0 as a full release. Again no code changes, just finalised the migration. The Windows installer still didn't work though. I've figured out why. The Windows Installer reads the "release notes" section of a release and parses it into the "version" I've released 0.12.0 with '0.12.0' as the release notes and the Windows Installer worked for me.

Something for the backlog :)

ZaLiTHkA commented 2 years ago

thanks for the feedback.. :) I must say, this is starting to make me wonder about the current installation process, especially the Windows script, but also the Unix scripts.

would you be open to other installation options? perhaps something that can be automated from a Git tag to build and publish installation packages for all supported platforms?

if so, I think we should open a new issue (or "discussion") and do some brainstorming... 😎

patrick-mccourt commented 2 years ago

Agree, I've raised #11 to discuss.