Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer work in tasks of type shell when specifying a PATH setting under terminal.integrated.env.linux #852

Open
jraygauthier opened this issue Nov 19, 2024 · 0 comments

Comments

@jraygauthier
Copy link

jraygauthier commented Nov 19, 2024

As soon as I add the following snippet to my user settings.json, this direnv extension stops to properly expose environments to tasks of type shell as it previously did:

{
  // ..
  "terminal.integrated.env.linux": {
      "PATH": "/run/current-system/sw/bin",
  },
  // ..
}

As soon as I comment out this setting, it starts to work again.

Here's a tasks.json file to reproduce:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "My task description",
            "type": "shell",
            "command": "my-direnv-provided-exe",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Here's the error I get:

 *  Executing task: my-direnv-provided-exe 

/run/current-system/sw/bin/bash: line 1: my-direnv-provided-exe: command not found

 *  The terminal process "/run/current-system/sw/bin/bash '-c', 'my-direnv-provided-exe'" failed to launch (exit code: 127). 
 *  Terminal will be reused by tasks, press any key to close it.

Here's the expected behavior:

 *  Executing task: my-direnv-provided-exe 

Hello from 'my-direnv-provided-exe'!
 *  Terminal will be reused by tasks, press any key to close it.

You can use an .envrc such as:

PATH="$PATH:$PWD/bin"

And a my-direnv-provided-exe script under a bin directory in your workspace:

#!/bin/sh
echo "Hello from 'my-direnv-provided-exe'!"

Don't forget to chmod a+x ./bin/my-direnv-provided-exe.

Note that in order to reproduce you might have to remove ~/.config/Code is order to reproduce as vscode seems to be persisting some cache of a task's environment. Don't forget to add the settings.json snippet again after removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant