Re: NVDA Add-ons Community Directive: do NOT override system environment variables by assigning new strings


 

Hi,

A better community directive title should be:

Directive: do not override system environment variables without preserving old values

A really elegant alternative is not using system path environment variable – manually locate the path to the executable you want.

Cheers,

Joseph

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Joseph Lee via groups.io
Sent: Thursday, January 21, 2021 11:15 AM
To: nvda-addons@nvda-addons.groups.io
Subject: [nvda-addons] NVDA Add-ons Community Directive: do NOT override system environment variables by assigning new strings

 

Hi all,

The following NVDA Add-ons community directive applies to ALL add-ons going forward and will be applied when reviewing add-ons:

You can query system environment variables by doing:

import os

os.environ[variableString]

 

A crucial environment variable is system path (os.environ[“path”]). This variable is used by operating systems (in this case, Windows) to search listed directories for executables. The variable is not really a string – it is a list of strings separated by a semicolon.

If an add-on wants to add new paths to environment variables:

# Don’t do this:

os.environ[“path”] = newStr

 

# Alternative 1:

Os.environ[“path”] += “;” + pathStr

 

# Alternative 2:

environPath = os.environ[“path”].split(“;”)

environPath.append(newPath)

os.environ[“path”] = “;”.join(environPath)

 

# Improved alternative 2:

newPath = somePath

environPath = os.environ[“path”].split(“;”)

if newPath not in environPath:

environPath.append(newPath)

  os.environ[“path”] = “;”.join(environPath)

 

Any add-on that overrides environment variables without preserving old values will break add-ons that opens executables for their features.

 

Community directive: going forward, if an add-on is found to have modified system environment variables without preserving existing values will be flagged and authors will be asked to release a fix as soon as possible. Or, for that matter, do NOT ever (EVER) modify environment variables just for convenience (especially system path variable, as it will break NVDA, add-ons, and quite possibly Windows). This directive takes effect immediately.

 

The above directive applies to all add-ons, including those outside community add-ons website.

 

Affected add-ons:

  • Acapela TTS 1.6.5 (based on investigations by an add-on author).
  • Others that directly edit environment path variable without preserving existing values.

 

Next steps:

  1. Existing add-ons on community add-ons website should be examined by authors to see if the above community directive should be applied.
  2. New add-ons or add-ons currently under review (including ones with pending review requests) will be subject to the directive before review (including pending review) begins.
  3. Developers of add-ons hosted outside community add-ons website will be asked to modify their add-ons if the above community directive should be applied to their add-ons.
  4. The NVDA Add-ons community urges developers of Acapela TTS add-on to release a fix as soon as possible.

 

Cheers,

Joseph

Join nvda-addons@nvda-addons.groups.io to automatically receive all group messages.