Skip to content

Completions for environment variables differ between platforms #3227

Closed

Description

@rjmholt

When using both the console host and an editor like VSCode, completions are provided for
environment variables that differ across platforms. In the case of VSCode, I know it tries to
make recommendations for scripts that help them work cross-platform, and this seems to
fit in that category. Of course, plenty of environment variables are just not cross-platform, but
for things like $env:PSModulePath that come with PowerShell, it would make sense.

Given that Linux requires variable names that Windows tolerates but no vice-versa, perhaps we
should prefer those?

I wouldn't necessarily characterise this as a bug, but it might help obviate some bugs if changed. See #2937 and #2677. I know I have personally run into this when tests I wrote failed because I used
$env:PSModulePath, my reasoning being that the completion of a variable name would be the
canonical name for the variable.

Steps to reproduce

In a PowerShell terminal or editor with completions enter the input:

$env:PSM<Tab>

Expected behavior

The same completed variable name across platforms.

Actual behavior

On Windows:

$env:PSModulePath

On Linux:

$env:PSMODULEPATH

Environment data

> $PSVersionTable

Name                           Value                                                                                                 
----                           -----                                                                                                 
GitCommitId                    v6.0.0-alpha.16-28-g136213d6b4767370f0b6340ffbefa130fdc55327                                          
WSManStackVersion              3.0                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                               
PSEdition                      Core                                                                                                  
BuildVersion                   3.0.0.0                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                   
SerializationVersion           1.1.0.1                                                                                               
PSVersion                      6.0.0-alpha                                                                                           
CLRVersion                                                                                                                           

Activity

  1. added
    WG-Engine
    on Mar 1, 2017
  2. added this to the milestone on Mar 1, 2017
  3. SteveL-MSFT commented on Mar 1, 2017

    @SteveL-MSFT
    Member

    This is an easy fix, but like many things Env are case sensitive on Linux. It seems that by convention, they tend to use all uppercase. For script portability (although perhaps they shouldn't modify psmodulepath), we should consider having consistency with Windows.

  4. added
    Review - Committee
    on Mar 1, 2017
  5. SteveL-MSFT commented on Mar 2, 2017

    @SteveL-MSFT
    Member

    @PowerShell/powershell-committee discussed this and decided to maintain compatibility for existing scripts, it would be best to keep the mixed casing and change it in PSCore6 on Linux.

  6. added
    Committee-Reviewed
    Breaking-Change
    and removed
    Review - Committee
    on Mar 2, 2017
  7. iSazonov commented on Mar 9, 2017

    @iSazonov
    Collaborator

    Existing scripts is Windows scripts and it is case-insensitive: we are free to use PSModulepath, PSmodulepath, psmodulepath, PsMoDuLePaTh and so on.
    If the conclusion was "to maintain compatibility for existing scripts" all above must work on Unix too.

  8. SteveL-MSFT commented on Mar 9, 2017

    @SteveL-MSFT
    Member

    Ilya (@iSazonov) you are correct that on Windows, env vars are case-insensitive, but we are only optimizing for the tab-complete case which we expect is the majority of use.

  9. iSazonov commented on Mar 9, 2017

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) Yes, I see your fix. But it seems the issue was originally broadly: Windows user type PSModulePath in other case and catch failure on Unix.

  10. SteveL-MSFT commented on Mar 9, 2017

    @SteveL-MSFT
    Member

    Ilya (@iSazonov) we are trying to find a balance between interop, app-compat, and conforming to Unix/Linux norms and this is what the committee decided fit that balance. If there is customer feedback that we need to do more here, we are open to listening.

  11. iSazonov commented on Mar 9, 2017

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) Thanks for clarify!

  12. iSazonov commented on Mar 16, 2017

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) It seems the PR is not full solution. Maybe reopen the Issue?

    it seems the issue was originally broadly: Windows user type PSModulePath in other case and catch failure on Unix.

  13. SteveL-MSFT commented on Mar 16, 2017

    @SteveL-MSFT
    Member

    Ilya (@iSazonov) the @PowerShell/powershell-committee decision is to only address the scenario of using tab-complete to author a script (most likely profile script) that uses $env:PSModulePath and have that consistent across platforms. The general problem is no different from calling PowerShell console host on Windows which won't work as the file system is generally case sensitive on Linux so it has to be powershell.

  14. iSazonov commented on Mar 17, 2017

    @iSazonov
    Collaborator

    If you generalize so much the problem then I agree to close the Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Breaking-ChangeCommittee-ReviewedResolution-FixedWG-Engine

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions