Skip to content
DetachHeadPublic

About

A VSCode extension for adding project-specific directories to `PATH` that works with other extensions.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

VSenv

A VSCode extension for adding project-specific directories to PATH that works with other extensions.

Important

This extension is currently experimental and is subject to breaking changes. In fact it may break entirely because it relies on a VSCode bug. See below for more info.

Installation

What is this?

The problem

Most VSCode extensions for language servers and other command-line tools either expect that tool to be installed globally, or come bundled with their own version.

This means if your project pins a specific version that's installed as a dev dependency instead of globally, the extension will either need to be explicitly configured to point to your project's version, or it might just not work at all.

The issue is even worse when those tools are installed in a python environment, because for some insane reason, the scripts directory is different depending on your OS. This means many extensions need to be configured using disgusting polyglot scripts if you want to be able to commit a .vscode/settings.json file that works for all contributors.

The solution

This extension loads (hopefully) before your other extensions do. It then modifies the PATH variable visible to those extensions with any directories specified in its config.

Usage

Configure additional directories to add to the PATH variable in .vscode/settings.json:

{
  "vsenv.paths": [
    // relative paths are resolved relative to the workspace root
    "./node_modules/.bin",
  ],
}

Tip

If your project requires VSenv, you should add it as a recommended extension so that other contributors are prompted to install it:

// .vscode/extensions.json

{
  "recommendations": ["detachhead.vsenv"],
}

Python environment detection

As mentioned above, Python environments have a different scripts path on Windows and Unix-like operating systems.

VSenv solves this by automatically detecting your Python environment using either the Python or Python Environments. If an environment is detected, it's automatically added to the PATH along with any additional paths specified in vsenv.paths.

Disclaimer

I don't know for sure how reliable this is. It seems to work with every extension I've tried, but it may not work for you if the other extension gets loaded first.

It also relies on behavior in VSCode that may or may not be intentional, so it's possible that a future VSCode update may break this extension.

About

A VSCode extension for adding project-specific directories to `PATH` that works with other extensions.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages