1

I got a new system running on windows 11 and I'm having issues running the shell script to set up react native windows environment.

Set-ExecutionPolicy Unrestricted -Scope Process -Force; iex (New-Object System.Net.WebClient).DownloadString('https://aka.ms/rnw-deps.ps1') Please I need help resolving this error.

The script can be found at https://aka.ms/rnw-deps.ps1 Error is from lines 68 and 130

Here's a screenshot of the error I'm getting. enter image description here

Uwem
  • 49
  • 4

1 Answers1

0

The script you link to is broken (as of this writing):

Line 98:

Write-Debug No Retail versions of Visual Studio found, trying pre-release...

This line causes a syntax error, due to missing quoting; the correct syntax is:

Write-Debug 'No Retail versions of Visual Studio found, trying pre-release...'

Line 130:

$p = Start-Process -PassThru -Wait  -FilePath $vsInstaller -ArgumentList ("modify --channelId $channelId --productId $productId $addWorkloads --quiet --includeRecommended" -split ' ')

The fact that this line fails indicates that at least one of the referenced variables - $channelId, $productId, $addWorkloads is unexpectedly $null.

As an aside:

  • That an error results from this is a manifestation of a Windows PowerShell bug (which has since been fixed in PowerShell (Core) 7+) - passing an empty array or $null or an array that has at least one $null element to the -ArgumentList property of Start-Process unexpectedly causes an error.

  • There is a separate Start-Process bug - still present as of PowerShell Core 7.2.2 - the workaround for which makes it better to pass all arguments as a single string with embedded "..." quoting (as needed) to -ArgumentList (see this answer):

    $p = Start-Process -PassThru -Wait  -FilePath $vsInstaller -ArgumentList "modify --channelId $channelId --productId $productId $addWorkloads --quiet --includeRecommended"
    
mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 1
    Thank you so much. This fixed it, I raised an issue on GitHub and a commit has been made to remove the bug. The bug on line 130 was due to a previously unfinished install of "visual studio" by chocolatey. Thanks again. – Uwem Apr 07 '22 at 19:26
  • Glad to hear it, @Uwem, thanks for the update. – mklement0 Apr 07 '22 at 19:28