microsoft / microsoft/vscode-cmake-tools

ELECTRON_RUN_AS_NODE is inherited from the VSCode environment when building a CMake target

Open
#1,545 4 comments 1 reaction 0 assignees View on GitHub
enhancement Feature: build help wanted
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

I have defined a custom CMake target to build our documentation using the Python tool Sphinx. As part of the documentation building process, drawio, an Electron based application, is executed and fails with the following error message: `drawio: bad option --export`. This only occurs when building the CMake target using the CMake Tools VSCode extension. There is no problem when running the target from a terminal, inside or outside of VSCode. Also invoking Sphinx from a VSCode launch/debug configuration is without issues.

I have found that the root cause for this is that Electron applications behave like this when the [ELECTRON_RUN_AS_NODE](https://www.electronjs.org/docs/api/environment-variables#electron_run_as_node) environment variable is set (see https://github.com/electron/electron/issues/18412). VSCode cleans the environment for its terminals and when starting debug sessions. I believe CMake Tools should do the same when building a target, [making sure it doesn't affect VSCode's environment](https://github.com/electron/electron/pull/19742).

### Platform and Versions

- **Operating System**: Ubuntu 18.04
- **CMake Version**: 3.17.4
- **VSCode Version**: 1.51.0
- **CMake Tools Extension Version**: 1.5.2

Contributor guide

Open the contributing guide

Research direction

Start with the CMake Tools path that builds a custom CMake target, reproducing the Sphinx target that invokes drawio under the VSCode extension. Compare its environment with the terminal and launch/debug paths, focusing on ELECTRON_RUN_AS_NODE. Done means the target no longer inherits that variable while VSCode's environment remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, electron, python, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.