Xav83 / chocolatey-packages

Implementation of the template to create and maintain chocolatey packages both manual and automatic (mostly automatic)
https://chocolatey.org/profiles/Xav83
Apache License 2.0
3 stars 4 forks source link

pluginval isn't compatible with the generated shim #2

Closed phraemer closed 2 years ago

phraemer commented 3 years ago

To reproduce the issue install pluginval with choco and call it with like so from the command line:

C:\ProgramData\chocolatey\bin\pluginval.exe

C:\WINDOWS\system32>pluginval --version

C:\WINDOWS\system32>

You'll see that no version information is printed. However, you can start it by just running pluginval without any arguments. Validating a vst3, for example, with --validate-in-process reveals that the child process is launched but the original process does not wait on it and ends.

I suspected this is some problem with the shim generated during install by choco. https://docs.chocolatey.org/en-us/features/shim

You can confirm this by instead calling the pluginval exe directly

C:\WINDOWS\system32>C:\ProgramData\chocolatey\lib\pluginval\tools\pluginval --version

C:\WINDOWS\system32>pluginval - 0.2.9

And validating in process works this way too, the parent process does not exit until validation is complete.

 C:\ProgramData\chocolatey\lib\pluginval\tools\pluginval --validate "[path-to-plugin]" --validate-in-process
...
Finished validating: [path-to-plugin]
ALL TESTS PASSED

The documentation suggests shimming can be disabled

https://docs.chocolatey.org/en-us/create/create-packages#how-do-i-exclude-executables-from-getting-shims

Although perhaps shims need to be specified that they are gui shims. I haven't tried these steps yet as I have no experience with creating choco packages.

https://docs.chocolatey.org/en-us/create/create-packages#how-do-i-set-up-shims-for-applications-that-have-a-gui

Link to original pluginval issue comment: https://github.com/Tracktion/pluginval/issues/26#issuecomment-769762329

Xav83 commented 3 years ago

Hi @phraemer,

Since the creation of this issue, I had some time to experiment and reproduce it, and like you suggest I can confirm that the problem comes from the executable shimming feature of Chocolatey. πŸ™‚πŸ‘

I have also found a workaround to allow you to use pluginval installed via Chocolatey without problem, by using the option --shimgen-waitforexit.

Capture

I will work on excluding pluginval executable from getting shims, and ping you when I will have a working solution πŸ˜‰

phraemer commented 3 years ago

@Xav83 hey thanks a lot!

Xav83 commented 3 years ago

Hi @phraemer,

I have create a Pull Request (#3) which seems to fix this problem. I will do more tests in the next week, with some plugins I have on my computer, to be sure that the behavior is the one we actually want.

Feel free to review this Pull Request (#3), ask question or add some commentaries πŸ˜‰

Moreover, if you have some plugins in mind, for me to check, with some specific pluginval command line options, please add a comment on the Pull Request (#3). This will help me make sure that integrating this fix won't broke setup πŸ™‚

Finally, if you want to test this package on your machine, I can also give you the process to do it πŸ˜‰

phraemer commented 3 years ago

Looks good! If you would like me to test it let me know. I can do that for you.

Xav83 commented 3 years ago

@phraemer So I have integrated the Pull Request #3, after testing it with VST and VST3 plugins on Windows.

I have tried to upgrade the version 0.2.9 of the pluginval package, but, unfortunately, it seems that Chocolatey want to avoid having package modified once they have been validated and published.

   [10/10] pluginval ERROR: 
     Chocolatey v0.10.15 Attempting to push pluginval.0.2.9.nupkg to https://push.chocolatey.org An error has occurred. It's possible the package version already exists on the repository. (30.31s)

(link to Appveyor output)

We may have to wait for the next version of pluginval to be published to have the correction of #3 available in a chocolatey package. And meanwhile, use the workaround --shimgen-waitforexit.

phraemer commented 3 years ago

@Xav83 nice!

And thanks :)

Xav83 commented 3 years ago

Hi @phraemer ! πŸ™‚

I have been experimenting a little bit more with Chocolatey and AU Framework, as I had the same problem with another package (I needed to correct the package on Chocolatey server, since it was completely broken 😝), and I've found a working solution 🍾

By adding the instruction param([switch]$Force) in the update script of the package, we are able to force a new build of the package, even if the version stays the same (actually, it appends automatically the date of the build to the version of the package to have a new package version and by pass the version check πŸ˜†)

So I've also updated pluginval chocolatey package using the same solution. You will soon find a new version of the pluginval Chocolatey package here, which fix the shimming !

If you want, here is the link to the commit containing the fix.

If you can confirm that the new version of the pluginval package works on you machine (when Chocolatey will have validated it), it would be great, as it will allow me to close this issue πŸ˜‰

Thanks again for your help and your patience πŸ™‚

phraemer commented 3 years ago

Hi @Xav83 ! Thanks for continuing to look into this.

The package updated fine but it still needs the --shimgen-waitforexit switch in order to wait for the process to exit.

Xav83 commented 3 years ago

πŸ€”

@phraemer, can you look which pluginval executable you are running, by using the command which pluginval, please ?

Your system may still use the pluginval installed before the shimming correction. On my machine, for example, the pluginval corrected binary is in /c/ProgramData/chocolatey/lib/pluginval/tools/pluginval while the older version of the chocolatey package installed it in /c/ProgramData/chocolatey/bin.

So it is possible that all you have to do is to remove an old version of pluginval in /c/ProgramData/chocolatey/bin.

phraemer commented 3 years ago

Ah yes, choco did indeed leave that binary behind! Which is surprising because I did choco uninstall pluginval. Once I manually removed it then it works as expected, thanks!

I wonder if it's possible for you to add something to the package to ensure that binary is removed on uninstall if it exists?

Xav83 commented 3 years ago

Awesome, so the fix works, which is a great thing πŸΎπŸ˜„

Yes, it is probably possible to remove the old binary in a script launch automatically during the chocolatey package update. I don't know yet how to do it, so it may take me a bit of time before I have a working solution to do it πŸ˜„ I will update you on this issue when I will have some news about that πŸ˜‰

phraemer commented 3 years ago

Great job! Thanks again.