Skip to content

[Feature] Pick up nix environment in tasks #55

Open
@bcardiff

Description

@bcardiff

Describe the bug

I attempted a minimalist example to run the hello program provided by nix from a task and the task is not found after loading / hitting the environment. I'm probably doing something wrong here, but if I load the nix environment before opening vscode from the same terminal things work. Thanks in advance.

To Reproduce
Steps to reproduce the behavior:

# file: default.nix
{ pkgs ? import <nixpkgs> {}}:

pkgs.mkShell {
  nativeBuildInputs = [ pkgs.hello ];
}
// file: .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "hello",
            "type": "shell",
            "command": "hello"
        }
    ]
}
  1. Start vs code
  2. Open the project folder
  3. Select the environment
  4. Reload the environment
  5. Click on Terminal menu
  6. Click on Run Task ... option
  7. Select hello
  8. Select continue without scanning task output

The output in the terminal shows that it can't find hello

> Executing task: hello <

zsh:1: command not found: hello
The terminal process "/bin/zsh '-c', 'hello'" failed to launch (exit code: 127).

Terminal will be reused by tasks, press any key to close it.

Expected behavior

The following is the expected output, but I can only get it if vscode is started from a terminal with the nix environment loaded already. Which is precisely what I am looking to not do with this extension.

> Executing task: hello <

Hello, world!

Terminal will be reused by tasks, press any key to close it.

Environment:

  • OS: macOS 10.15.7 Catalina
  • Version: 1.54.3 (Universal)
  • Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
  • Electron: 11.3.0
  • Chrome: 87.0.4280.141
  • Node.js: 12.18.3
  • V8: 8.7.220.31-electron.0
  • OS: Darwin x64 19.6.0

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions