alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

attempting alda update throws exception in windows 10 #43

Closed elydpg closed 7 years ago

elydpg commented 7 years ago

when I attempt alda update on my windows 10 pc, the following happens:

C:\Users\elyis>alda update
Install alda '1.0.0-rc60' over '1.0.0-rc59' ? [yN]: y
Downloading https://github.com/alda-lang/alda/releases/download/1.0.0-rc60/alda.exe...
An error occured while downloading a file (2).
java.io.FileNotFoundException: C:\Program Files (x86)\Alda\alda.exe (The process cannot access the file because it is being used by another process)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
        at alda.Util.downloadFile(Util.java:190)
        at alda.AldaClient.updateAlda(AldaClient.java:87)
        at alda.Main.main(Main.java:222)

Updated alda 1.0.0-rc59 => 1.0.0-rc60.
If you have any currently running servers, you may want to restart them so that they are running the latest version.

C:\Users\elyis>alda version
Client version: 1.0.0-rc59
Server version: [27713] ERROR Alda server is down. To start the server, run `alda up`.

C:\Users\elyis>

the machine has just been booted so there shouldn't be any issue with used processes. what's going on?

daveyarwood commented 7 years ago

Hmm, so I researched this issue a bit, and I have two hypotheses:

1) This is a Windows-specific issue where the OS won't let a program replace itself while it's running.

(This is what the `alda update` command does -- it downloads the latest `alda` executable from GitHub and writes it to its own location in your filesystem, so that the next time you run it, it is a new version.)

2) You might have some other program holding a handle to the file open. I've read that certain antivirus software can cause problems like this (see: https://github.com/docker/for-win/issues/657 )

elydpg commented 7 years ago

I don't have any antivirus installed other than Windows Defender, so I'm guessing that it's option 1. For now I'm guessing that the best way to update is to download the latest version of alda.exe and replace it manually :/

daveyarwood commented 7 years ago

Yeah, I think that should work as a workaround. Can you let us know if that works, so we can confirm if that was the issue? You may also need to run alda down first to shut down existing instances of the program before replacing it. I'm sorry, I know this is not ideal.

I've actually been thinking about us having a separate program that manages Alda processes, instead of having everything bundled into one executable. That would allow us to replace individual components of Alda with alternate implementations written in other languages, which is an idea I've been playing with. If we did this, I think it would incidentally also allow you to update by shutting down your server via alda down and then running alda update... unless you need to update the updater, in which case you would be out of luck 😅

Unfortunately, I don't have a quick fix for this, as I'm not equipped to troubleshoot Windows-specific issues. Any help from Windows developers would be appreciated.

elydpg commented 7 years ago

So I tried that and it's still telling me that I'm running 1.0.0 rc59 :|

daveyarwood commented 7 years ago

I think that's a bug in the alda-client-java code that gets run when you update Alda. After An error occured while downloading a file (2). is printed, we should bail out, not tell you that it updated successfully.

Did you get an error this time?

elydpg commented 7 years ago

No, I meant that after manually updating it's still telling me I'm on rc59...

daveyarwood commented 7 years ago

Oh, huh. I think I accidentally messed up the version number in the build. I just tried it myself and it also said that I'm on rc59 despite it really being rc60. You can tell that you're really on rc60 if you run alda stop and it returns Stopping playback...

I re-built it and it says rc60 now. I ran alda update and it updated successfully for me, and correctly reports the version as rc60.

Would you mind trying alda update again? I'm curious if that somehow fixed it.

elydpg commented 7 years ago

yep; it's rc60 since alda stop works. Still won't update though

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\elyis>alda update
Install alda '1.0.0-rc60' over '1.0.0-rc59' ? [yN]: y
Downloading https://github.com/alda-lang/alda/releases/download/1.0.0-rc60/alda.exe...
An error occured while downloading a file (2).
java.io.FileNotFoundException: C:\Program Files (x86)\Alda\alda.exe (The process cannot access the file because it is being used by another process)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
        at alda.Util.downloadFile(Util.java:190)
        at alda.AldaClient.updateAlda(AldaClient.java:87)
        at alda.Main.main(Main.java:227)

Updated alda 1.0.0-rc59 => 1.0.0-rc60.
If you have any currently running servers, you may want to restart them so that they are running the latest version.

C:\Users\elyis>
daveyarwood commented 7 years ago

https://github.com/alda-lang/alda-client-java/commit/080fc4fee075cc75fb2af2ce522e94487a509477 will at least fix the fact that it falsely claims to have updated Alda after there was clearly an error downloading the file.

Help wanted fixing the underlying problem, which I believe is a Windows-specific issue.

daveyarwood commented 7 years ago

Moved to https://github.com/alda-lang/alda-client-java/issues/24 as this is a problem with the Alda client.