Skip to content

Commit

Permalink
Support Linux on EnvMixin to handle fish_user_paths being prepended t…
Browse files Browse the repository at this point in the history
…o the PATH after the shell integration
  • Loading branch information
davidmartos96 committed Oct 10, 2024
1 parent 8109d63 commit df9a3e8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/vs/platform/terminal/node/terminalEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as os from 'os';
import { FileAccess } from '../../../base/common/network.js';
import { getCaseInsensitive } from '../../../base/common/objects.js';
import * as path from '../../../base/common/path.js';
import { IProcessEnvironment, isMacintosh, isWindows } from '../../../base/common/platform.js';
import { IProcessEnvironment, isLinux, isMacintosh, isWindows } from '../../../base/common/platform.js';
import * as process from '../../../base/common/process.js';
import { format } from '../../../base/common/strings.js';
import { isString } from '../../../base/common/types.js';
Expand Down Expand Up @@ -284,16 +284,20 @@ export function getShellIntegrationInjection(
}

/**
* On macOS the profile calls path_helper which adds a bunch of standard bin directories to the
* beginning of the PATH. This causes significant problems for the environment variable
* There are a few situations where some directories are added to the beginning of the PATH.
* 1. On macOS when the profile calls path_helper.
* 2. On fish when it automatically prepends "$fish_user_paths" to the PATH at the end of the
* shell configuration, even after the VSCode shell integration.
*
* This causes significant problems for the environment variable
* collection API as the custom paths added to the end will now be somewhere in the middle of
* the PATH. To combat this, VSCODE_PATH_PREFIX is used to re-apply any prefix after the profile
* has run. This will cause duplication in the PATH but should fix the issue.
*
* See #99878 for more information.
*/
function addEnvMixinPathPrefix(options: ITerminalProcessOptions, envMixin: IProcessEnvironment): void {
if (isMacintosh && options.environmentVariableCollections) {
if ((isMacintosh || isLinux) && options.environmentVariableCollections) {
// Deserialize and merge
const deserialized = deserializeEnvironmentVariableCollections(options.environmentVariableCollections);
const merged = new MergedEnvironmentVariableCollection(deserialized);
Expand Down

0 comments on commit df9a3e8

Please sign in to comment.