docs icon indicating copy to clipboard operation
docs copied to clipboard

Clarify that env vars are at least somewhat case insensitive on Windows

Open jsoref opened this issue 2 years ago • 12 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable

What part(s) of the article would you like to see updated?

The names of environment variables are case-sensitive, and you can include punctuation.

This is true on Linux (and macOS).

However, my understanding is that this is at least partially untrue on Windows: https://github.com/actions/runner/blob/cb19da9638790019f6e7be193cd4282311992b12/src/Runner.Worker/ActionCommandManager.cs#L158-L162

I say partially, because I haven't extensively tested the code paths.

Additional information

No response

jsoref avatar Aug 09 '22 19:08 jsoref

👋 @jsoref Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

cmwilson21 avatar Aug 10 '22 16:08 cmwilson21

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Aug 22 '22 07:08 github-actions[bot]

This probably needs some engineering clarification; environment variables on Windows platforms are not case-sensitive, but I'm not sure that when those environment variables are used by any Actions components (e.g. setting them in $env:GITHUB_ENV) whether there might be cases where they are.

lucascosti avatar Aug 23 '22 01:08 lucascosti

Technically environment variables in cmd are case-preserving:

set X=1 && set y=2 && echo Unset %x% %Y%.
echo Set %X% %y%. && set x=3 && echo %X% && set|find "X=" && set|find "y=" && echo --- && set|find "x=" && set |find "Y=" && echo ===

image

And the same applies for PowerShell:

$Env:TestOne=1
$Env:TestTWO=2
$Env:TestONE
$Env:Testtwo
$Env:TestOnE=3
$Env:TestOne

image

But yes, it'd be good to get engineering input. I can only speak to the general bits that I can read or test and not anything beyond that.

jsoref avatar Aug 23 '22 01:08 jsoref

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Sep 20 '22 20:09 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Dec 19 '22 16:12 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jan 17 '23 16:01 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Feb 15 '23 16:02 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Mar 16 '23 16:03 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Apr 17 '23 16:04 github-actions[bot]

@cmwilson21 ...

jsoref avatar Jun 25 '23 02:06 jsoref

Reopened! Sorry about that!

cmwilson21 avatar Jun 26 '23 14:06 cmwilson21

I got Engineering to look into this.

After testing various runner OSes, the feedback is that, practically speaking, environment variables are case sensitive on Linux and Mac, and case insensitive on Windows runners.

If you choose to use Powershell as your shell on Linux or Mac environment variables are still case sensitive (i.e. this doesn't break the above rule). See the note here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.3#long-description

We should, therefore, update the documentation where we currently say that "environment variables are case-sensitive", as this is not true for Windows.

Engineering made a couple of points that we should include when updating the docs:

  • To avoid issues it's good practice to treat environment variables as case sensitive irrespective of the behavior of the operating system and shell you are using. We should make this point when talking about case sensitivity of environment variables.

  • In a couple of Markdown files:

    • https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-a-proxy-server-with-self-hosted-runners#configuring-a-proxy-server-using-environment-variables
    • https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-workflow-command

    and in this reusable:

    • https://github.com/github/docs/blob/main/data/reusables/actions/actions-secrets-and-variables-naming.md?plain=1

    we use the phrase "not case-sensitive" - we should change this to "case insensitive".

BTW: we don't need to hyphenate "case sensitive" where it's not being used as an adjective.

hubwriter avatar Jul 18 '23 16:07 hubwriter