Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Errors in PowerShell Code in Flutter Setup Guide for China (#11329)
### Page Source Code Location `src/_includes/docs/community/china/os-settings.md` https://docs.flutter.dev/community/china ### Problem Description The code in the documentation is attempting to set environment variables for Flutter but contains errors that lead to unexpected behavior. #### Incorrect Code ```powershell newPath = $pwd.PATH + "/flutter/bin",$env:PATH -join ";" [System.Environment]::SetEnvironmentVariable('Path',$newPath,User) [System.Environment]::SetEnvironmentVariable('PUB_HOSTED_URL','https://pub.flutter-io.cn',User) [System.Environment]::SetEnvironmentVariable('FLUTTER_STORAGE_BASE_URL','https://storage.flutter-io.cn',User) ``` #### Issues Identified: 1. **Incorrect Path Concatenation**: The variable `newPath` concatenates using a comma, which results in incorrect setting of the PATH environment variable. - **Expected `newPath` (example)**: `C:\Users\User\flutter\bin;C:\Windows` - **Actual Value of `newPath`**: `C:\Users\User/flutter/bin C:\Windows` 2. **Missing Quotes for 'User'**: The `User` parameter in `SetEnvironmentVariable` method calls is not enclosed in quotes, leading to runtime exceptions. ```plaintext + [System.Environment]::SetEnvironmentVariable('Path',$newPath,User) + ~ Missing expression after ','. At line:1 char:62 + [System.Environment]::SetEnvironmentVariable('Path',$newPath,User) + ~~~~ Unexpected token 'User' in expression or statement. At line:1 char:66 + [System.Environment]::SetEnvironmentVariable('Path',$newPath,User) + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingExpressionAfterToken ``` Co-authored-by: Brett Morgan <[email protected]>
- Loading branch information