Repository: metacall/core (language: rust)

Issue:
MSVC GitHub Action failing to install NodeJS
## 🐛 Bug Report

```
rd : Cannot find path 'D:\a\core\core\runtimes\nodejs\node-v14.18.2-win-x64' because it does not exist.
At D:\a\core\core\tools\metacall-environment.ps1:261 char:2
+     rd "$RuntimeDir\node-v$NodeVersion-win-x64"
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\a\core\core\...14.18.2-win-x64:String) [Remove-Item], ItemNotFoundEx 
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
```

https://github.com/metacall/core/actions/runs/3176691428/jobs/5176286153



Discussion / hints:
@paramsiddharth 
Also the build fails without exiting:
`Failure in build with exit code: 1`

It should exit and not continue.
@viferga I don't think that's a failure... It's the output of `rd -Recurse -Force dirname` in PowerShell, equivalent to `rm -rf dirname` in *NIX. It still shows this warning message if the directory doesn't exist, but it is actually successful, because we don't want the directory to be there, which is exactly why we are attempting to delete it. `rm -rf` doesn't show the warning. That's the only difference.
> Also the build fails without exiting: `Failure in build with exit code: 1`
> 
> It should exit and not continue.

@viferga What do you mean when you say it "continues" even after failing?
> > Also the build fails without exiting: `Failure in build with exit code: 1`
> > It should exit and not continue.
> 
> @viferga What do you mean when you say it "continues" even after failing?

It starts the next step without failing immediately, or I am getting it wrong?

> @viferga I don't think that's a failure... It's the output of `rd -Recurse -Force dirname` in PowerShell, equivalent to `rm -rf dirname` in *NIX. It still shows this warning message if the directory doesn't exist, but it is actually successful, because we don't want the directory to be there, which is exactly why we are attempting to delete it. `rm -rf` doesn't show the warning. That's the only difference.

Ok, fine then, it may be cool to make it silent if possible to avoid confusion.
> > > Also the build fails without exiting: `Failure in build with exit code: 1`
> > > It should exit and not continue.
> > 
> > 
> > @viferga What do you mean when you say it "continues" even after failing?
> 
> It starts the next step without failing immediately, or I am getting it wrong?

@viferga It is actually this:

![image](https://user-images.githubusercontent.com/30315706/193668977-d426071e-616a-43df-9793-479277e71eae.png)

Those are some "post" job steps automatically added by the CI.
> > @viferga I don't think that's a failure... It's the output of `rd -Recurse -Force dirname` in PowerShell, equivalent to `rm -rf dirname` in *NIX. It still shows this warning message if the directory doesn't exist, but it is actually successful, because we don't want the directory to be there, which is exactly why we are attempting to delete it. `rm -rf` doesn't show the warning. That's the only difference.
> 
> Ok, fine then, it may be cool to make it silent if possible to avoid confusion.

@viferga OK, Vicente! I'll go ahead and do it.
Great, closing. PR the silent error of that command whenever you can.

Fix patch:
diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1
index fb7ce5849..9a2001e5f 100644
--- a/tools/metacall-environment.ps1
+++ b/tools/metacall-environment.ps1
@@ -273,7 +273,7 @@ function sub-nodejs {
 	# Install runtime
 	Expand-Archive -Path "node.zip" -DestinationPath $RuntimeDir
 	robocopy /move /e "$RuntimeDir\node-v$NodeVersion-win-x64" "$RuntimeDir" /NFL /NDL /NJH /NJS /NC /NS /NP
-	rd "$RuntimeDir\node-v$NodeVersion-win-x64"
+	rd -Recurse -Force "$RuntimeDir\node-v$NodeVersion-win-x64"
 
 	Add-to-Path $RuntimeDir
 


Test patch: