How does nRF Connect for VS Code determine the shell for default "Build" and "Flash" tasks?

I installed west and other additional Python dependencies in a Python virtual environment. Therefore, when I run the "Build" task from the Actions View, the task failed with an error message:

/bin/sh: west: command not found

I know that the integrated terminal can activate the Python virtual environment when sourcing a shell configuration file, and therefore I can run west build in the integrated terminal successfully.

Eventually, I do want the tasks in the Actions View to successfully run west as well. And to do this without forgoing the virtual environment, I believe I need to better understand how nRF Connect for VS Code determines the shell for tasks in the Actions View.

I'm on macOS 13.3.1 using nRF Connect for VS Code 2023.4.148. It looks like the tasks in the Actions View use /bin/sh as their shell.

As far as I'm aware, setting "terminal.integrated.automationProfile.osx".path in settings.json or "options.shell" in tasks.json does not change the shell for tasks in the Actions View. Nor does setting "nrf-connect.west.env" in settings.json help. "nrf-connect.taskBindings" will overwrite the default tasks in the Actions View.

Any clarification on how nRF Connect for VS Code determines the shell for tasks in the Actions View is appreciated.

Parents
  • Hi,

    The nRF Connect for VS Code extension queries Bash for its environment by executing the ~/.bashrc file. Adding the path of west and other dependencies to ~./basrc should solve the issue. See West environment on macOS and Linux for more information.

    You can also add environment variables to nrf-connect.west.env, so another solution is to set paths and environment variables not picked up by the extension in nrf-connect.west.env. See our documentation about this here: nrf-connect.west.env.

    "nrf-connect.west.env": {
        "$base": "terminal",
        "CUSTOM_ENV_VAR": "custom value",
        "OTHER_ENV_VAR": "another value",
    }

    Best regards,
    Marte

  • I tried setting the $PATH environment variable in .bashrc, as well as in "nrf-connect.west.env" from settings.json. Running the "Build" task from the Actions View still fails after performing either procedure with an error message:

    /bin/sh: west: command not found

    I initially thought that nRF Connect for VS Code would, by default, use my default shell on my macOS computer, which is /bin/zsh. It does for the nRF Connect terminal profile, but not for tasks in the Actions View (seems that they default to /bin/sh). Is there a way to change the shell for tasks in the Actions View?

Reply
  • I tried setting the $PATH environment variable in .bashrc, as well as in "nrf-connect.west.env" from settings.json. Running the "Build" task from the Actions View still fails after performing either procedure with an error message:

    /bin/sh: west: command not found

    I initially thought that nRF Connect for VS Code would, by default, use my default shell on my macOS computer, which is /bin/zsh. It does for the nRF Connect terminal profile, but not for tasks in the Actions View (seems that they default to /bin/sh). Is there a way to change the shell for tasks in the Actions View?

Children
Related