Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The export.ps1 script used undefined variable: $IsWindows (IDFGH-6141) #7820

Closed
cmumford opened this issue Nov 3, 2021 · 5 comments
Closed
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@cmumford
Copy link
Contributor

cmumford commented Nov 3, 2021

Environment

  • Development Kit: N/A
  • Kit version (for WroverKit/PicoKit/DevKitC): N/A
  • Module or chip used: N/A
  • IDF version (run git describe --tags to find it): v4.3.1
  • Build System: N/A
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): N/A
  • Operating System: Windows 10
  • (Windows only) environment type: PowerShell
  • Using an IDE?: no
  • Power Supply: N/A

Problem Description

$IsWindows is used, but never defined.

Steps to reproduce

  1. Install IDE.
  2. Enable strict debugging: Set-PSDebug -strict
  3. ./export.ps1
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 3, 2021
@github-actions github-actions bot changed the title The export.ps1 script used undefined variable: $IsWindows The export.ps1 script used undefined variable: $IsWindows (IDFGH-6141) Nov 3, 2021
@dobairoland
Copy link
Collaborator

dobairoland commented Nov 3, 2021

Hi @cmumford. Thanks for the report. Do you know the proper solution for this? IsWindows should been defined on other platform to $False:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1#iswindows

Shouldn't this be a PowerShell issue? It should not complain about his own internal variable.

@cmumford
Copy link
Contributor Author

cmumford commented Nov 3, 2021

Good point. I didn't know that was built-in. I wonder if I only get that error when I execute the script from another. I'm loading it like this:

function SetupESP() {
    if (Test-Path ~\esp\esp-idf\export.ps1 -PathType Leaf) {
        ~\esp\esp-idf\export.ps1
    } else {
        Write-Warning "No ESP-IDF environment to export"
    }
}

@dobairoland
Copy link
Collaborator

@cmumford I think this issue is caused by old version of PowerShell. The link given above is for 7.1. The variable is missing for version 5.1.

I can reproduce this in PowerShell 5.1. Just execute $IsWindows. It won't print anything. If you repeat this after setting the debug flag then it will produce the same error as export.ps1.

@cmumford
Copy link
Contributor Author

cmumford commented Nov 9, 2021

Yes, here's my version:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1320

I think I'll submit a PR to set $IsWindows to true if not defined. I think that PowerShell 6.x shipped on non-windows platforms so this won't be technically correct.

@cmumford
Copy link
Contributor Author

cmumford commented Nov 9, 2021

Actually it is defined in "PowerShell Core 6 and PowerShell 7", so maybe were OK here.

cmumford added a commit to cmumford/esp-idf that referenced this issue Nov 9, 2021
The `$IsWindows` PowerShell variable was added in PowerShell Core 6 and
PowerShell 7, and is not present in earlier PowerShell versions. Set to
true if undefined. This fixes espressif#7820.

The first version to run on non-Windows platforms was PowerShell Core
6.0[^1] which means that IsWindows is guaranteed to be defined on all
non-Windows systems. So, if undefined this indicates a Windows platform.

[^1]: https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.2#release-history
@espressif-bot espressif-bot added Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Nov 9, 2021
espressif-bot pushed a commit that referenced this issue Nov 20, 2021
The `$IsWindows` PowerShell variable was added in PowerShell Core 6 and
PowerShell 7, and is not present in earlier PowerShell versions. Set to
true if undefined. This fixes #7820.

The first version to run on non-Windows platforms was PowerShell Core
6.0[^1] which means that IsWindows is guaranteed to be defined on all
non-Windows systems. So, if undefined this indicates a Windows platform.

[^1]: https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.2#release-history

Closes #7858

Closes #7820
espressif-bot pushed a commit that referenced this issue Nov 24, 2021
The `$IsWindows` PowerShell variable was added in PowerShell Core 6 and
PowerShell 7, and is not present in earlier PowerShell versions. Set to
true if undefined. This fixes #7820.

The first version to run on non-Windows platforms was PowerShell Core
6.0[^1] which means that IsWindows is guaranteed to be defined on all
non-Windows systems. So, if undefined this indicates a Windows platform.

[^1]: https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.2#release-history

Closes #7858

Closes #7820
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants