Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

alda update prompt no longer works #35

Closed
elydpg opened this issue Jul 2, 2018 · 22 comments
Closed

alda update prompt no longer works #35

elydpg opened this issue Jul 2, 2018 · 22 comments
Labels

Comments

@elydpg
Copy link

elydpg commented Jul 2, 2018

Attempting to update via the suggested prompt no longer works.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\elyis> alda update
Automated updates to alda.exe are not possible due to limitations of the Windows OS.
For more information, see: https://github.com/alda-lang/alda-client-java/issues/24

To update alda.exe, first, make sure that the server is not up by running:

   alda down

Then, run the following command in your terminal to download the latest alda.exe:

    powershell -Command Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"

Or, if you'd prefer, you can install the latest alda.exe yourself from:
https://github.com/alda-lang/alda/releases

PS C:\Users\elyis> alda down
[27713] Server already down.
PS C:\Users\elyis> powershell -Command Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/downlo
ad/1.0.0-rc82/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:123
+ ... s/download/1.0.0-rc82/alda.exe -OutFile C:\Program Files (x86)\Alda\a ...
+                                                               ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\elyis> Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.e
xe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/do ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]
   , WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestComm
   and

PS C:\Users\elyis> Invoke-WebRequest -Uri "http://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.ex
e" -OutFile "C:\Program Files (x86)\Alda\alda.exe"
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-WebRequest -Uri "http://github.com/alda-lang/alda/releases/dow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]
   , WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestComm
   and

PS C:\Users\elyis> cd "C:\Program Files (x86)\Alda"
PS C:\Program Files (x86)\Alda> powershell -Command Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/re
leases/download/1.0.0-rc82/alda.exe" -OutFile "alda.exe"
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-WebRequest -Uri https://github.com/alda-lang/alda/releases/dow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]
   , WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestComm
   and

PS C:\Program Files (x86)\Alda> powershell -Command Invoke-WebRequest -Uri "http://github.com/alda-lang/alda/rel
eases/download/1.0.0-rc82/alda.exe" -OutFile "alda.exe"
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-WebRequest -Uri http://github.com/alda-lang/alda/releases/down ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]
   , WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestComm
   and

PS C:\Program Files (x86)\Alda>
@elydpg
Copy link
Author

elydpg commented Jul 2, 2018

If the text wall is too hard to read, here's an image version:

shell_output

@jgkamat
Copy link
Contributor

jgkamat commented Jul 2, 2018 via email

@TBuc
Copy link
Contributor

TBuc commented Jul 2, 2018

Hi @elyisgreat ,

I agree with @jgkamat. I was already looking at the reported issue (actually, two sub-issues are present), and I've found that the first sub-issue (x86) is avoidable trough single quoting, as per @jgkamat's suggestion, but also needs the command to be embraced in graph brackets. This the working version:
powershell -Command {Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.exe" -OutFile 'C:\Program Files (x86)\Alda\alda.exe'}

For what concerns the certificate error, you need to ensure you have Tls12 listed in [Net.ServicePointManager]::SecurityProtocol, which defines the cryptography protocols allowed by your client. From PowerShell, run:

PS C:\Users\myusr> [Net.ServicePointManager]::SecurityProtocol
Ssl3, Tls

This is my real output: as you can see, I had no Tls version 1.2 enabled, thus I got your very same error.

My Powershell details:

PS C:\Users\myusr> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17134  112

You can solve it just by adding Tls12 value to that list. To do so, you'll need to assign to the SecurityProtocol variable a list consisting of its current values plus the new one(s) you want to add. So, in my case:

[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3 -bor [System.Net.SecurityProtocolType]::Tls -bor [System.Net.SecurityProtocolType]::Tls12

Then check the list is correct (must contain previous values + Tls12):

PS C:\Users\myusr> [Net.ServicePointManager]::SecurityProtocol
Ssl3, Tls, Tls12

I was looking for a way to just append to the current list, without needing to fully re-definite it by adding again its current values too, but didn't succeed. If someone has better luck at this please drop a line.

Quick recap
So the problem is solvable by applying single quotes to the -Output parameter and embracing the passed command in graph brackets, plus enabling Tls12 on your system.

@elydpg
Copy link
Author

elydpg commented Jul 2, 2018

The single quotes does not affect the initial error with the (x86) file name, however the braces do allow the command to work properly. Nonetheless, I am still getting the same error even after enabling Tls12:

shell_output

@TBuc
Copy link
Contributor

TBuc commented Jul 2, 2018

Oh yes, sorry: the single quotes are actually not needed (even thought they are more proper in this case since there's no variable to evaluate).

I've just noted that the changes to SecurityProtocol are only session-scoped and not permanent. Thus, you'll need to invoke the command from the very same PowerShell session where you've modified SecurityProtocol. So, recapping:

  1. Launch PowerShell
  2. Update SecurityProtocol as per my previous post.
  3. Run the command as follows:
    Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.exe" -OutFile 'C:\Program Files (x86)\Alda\alda.exe'

HTH

@elydpg
Copy link
Author

elydpg commented Jul 2, 2018

I noticed that. My above photo depicts a single session.

Interestingly, after updating the SecurityProtocol, running

powershell -Command {Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/downl oad/1.0.0-rc82/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"}

creates an error, but running

Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"

works normally.

@TBuc
Copy link
Contributor

TBuc commented Jul 2, 2018

Exactly: invoking powershell -Command creates a separate session with its own context, whose lifetime boundaries are defined by the execution of the given command, and is not even needed in this case since we're directly executing from the PowerShell environment.

Unfortunately, I can't help users experiencing this issue from cmd.exe (you will need to launch a powershell to issue such update command). In case a user can't use Powershell, he/she will need to manually download the file, then autonomously replace the existing one in their Alda directory.

@daveyarwood
Copy link
Member

Maybe it would make sense for the Alda CLI to provide two separate commands that Windows users can run, depending on if they're using cmd.exe or PowerShell?

@elydpg
Copy link
Author

elydpg commented Jul 2, 2018

powershell -Command {[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3 -bor [System.Net.SecurityProtocolType]::Tls -bor [System.Net.SecurityProtocolType]::Tls12 ; Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/1.0.0-rc82/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"}

works as a one-liner for me! Unfortunately, it seems to work only in instances of PowerShell and not in cmd.exe (Of course this is all assuming the server is already down).

@elydpg
Copy link
Author

elydpg commented Dec 3, 2018

Can we update the Windows update prompt so that it says

Automated updates to alda.exe are not possible due to limitations of the Windows OS.
For more information, see: https://github.com/alda-lang/alda-client-java/issues/24

To update alda.exe, first, make sure that the server is not up by running:

   alda down

Then, run the following command in your terminal to download the latest alda.exe:

    powershell -Command {[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3 -bor [System.Net.SecurityProtocolType]::Tls -bor [System.Net.SecurityProtocolType]::Tls12 ; Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/<version>/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"}

Or, if you'd prefer, you can install the latest alda.exe yourself from:
https://github.com/alda-lang/alda/releases

instead of

Automated updates to alda.exe are not possible due to limitations of the Windows OS.
For more information, see: https://github.com/alda-lang/alda-client-java/issues/24

To update alda.exe, first, make sure that the server is not up by running:

   alda down

Then, run the following command in your terminal to download the latest alda.exe:

    powershell -Command Invoke-WebRequest -Uri "https://github.com/alda-lang/alda/releases/download/<version>/alda.exe" -OutFile "C:\Program Files (x86)\Alda\alda.exe"

Or, if you'd prefer, you can install the latest alda.exe yourself from:
https://github.com/alda-lang/alda/releases

?

@daveyarwood
Copy link
Member

@elyisgreat Does that only work when run in PowerShell?

If so, I'm still thinking that it might be best if we included 2 commands, one for cmd.exe and one for PowerShell.

On another note: that command is soooo long! It looks like PowerShell supports breaking up input over multiple lines, so perhaps we can do something like this for better readability?

    powershell `
        -Command {[Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3 `
        -bor [System.Net.SecurityProtocolType]::Tls `
        -bor [System.Net.SecurityProtocolType]::Tls12 ; `
        Invoke-WebRequest `
            -Uri "https://github.com/alda-lang/alda/releases/download/<version>/alda.exe" `
            -OutFile "C:\Program Files (x86)\Alda\alda.exe"}

@elydpg
Copy link
Author

elydpg commented Dec 3, 2018

Yea, but doesn't the old one have the same problem?

@daveyarwood
Copy link
Member

I don't think so. I think the existing one can be run in cmd.exe and it leverages powershell to do the thing. Take what I'm saying with a grain of salt because I don't have a Windows machine to test against, but I don't believe there is anything in the existing command that isn't valid syntax for cmd.exe.

@TBuc
Copy link
Contributor

TBuc commented Dec 4, 2018

@elyisgreat that one-liner looks great to me! Good job!

In July I did reach that solution too, sorry I didn't post it, but then got stuck at having it work from cmd.exe too - too high effort-to-improvement ratio job for my skills, so I gave up. That's a pity since most Windows users won't use Powershell.

@daveyarwood note that the line splitting will only work from native powershell - if you launch powershell from cmd.exe then launch the command it won't work instead.

@daveyarwood
Copy link
Member

daveyarwood commented Dec 4, 2018

Ah, that's a bummer. I guess we can't make it multi-line, then.

I'd still like to see a version that works for cmd.exe and a version that works for Powershell.

Is it the case that we could keep the current version as the one that works for cmd.exe, and use the new one @elyisgreat posted as the one that works for Powershell?

@TBuc
Copy link
Contributor

TBuc commented Dec 4, 2018

@daveyarwood AFAIK there's currently no version working on cmd.exe. Maybe I'm missing something?

@daveyarwood
Copy link
Member

daveyarwood commented Dec 4, 2018

Oh, I think I misunderstood!

So, I think what we should do, then, is to provide this new, improved version that works in Powershell, and make it clear that this will work if you're running Powershell, otherwise, you can manually download and install the latest release (which we're already including a link for).

@TBuc
Copy link
Contributor

TBuc commented Dec 5, 2018

Actually, keeping the single-line version proposed by @elyisgreat will work both when directly launching Powershell:
image
as much as when launching cmd.exe then therein invoking a powershell as follows:
image

The multi-line version of the same string will throw an error when launched from from the latter. For this reason, even thought the multi-line version is more readable, I'd suggest going for the single-line version.

But it's just my opinion on a presumably rare case, so if you decide to go for the multi-line version I will totally understand your point.

@daveyarwood
Copy link
Member

I'm fine with the single-line version. It sounds like the multi-line version is more trouble than it's worth.

If one of you would like to put together a PR, I'll happily merge it and include it with the next release of Alda!

@TBuc
Copy link
Contributor

TBuc commented Dec 18, 2018

PR submitted on that same day, sorry for forgetting to link it to this issue.

I've stumbled upon Chocolatey, a package manager for Windows. Looks like it's gaining a relevant user base (i.e., NodeJS installer will propose to install it too). This would add a layer, but would also enhance user experience.
Do you guys think we might rely on it for installing and updating Alda on Windows?

@daveyarwood
Copy link
Member

Chocolatey looks promising - definitely worth exploring for managing Alda updates on Windows.

I'm not seeing a PR that makes the change we discussed above. Are you sure you submitted one?

@daveyarwood
Copy link
Member

I think I've figured out how to make alda update Just Work™ in Alda v2, even for Windows. If I'm understanding correctly, the issue on Windows is that you can't replace a program while it's running, but you can rename it. So, I've read that there is this dance you can do where you rename the currently running executable, download the new version in its place, and then exit. Then, you have your program delete the old (renamed) versions on startup.

I'm planning to experiment with this and see if I can get it working in a Windows CI environment. If it works, the experience will be way better for Windows users.

I'm going to go ahead and close this issue, since it's Alda v1 specific and Alda v2 will be out soon 🤞

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants