-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
positron.r.interpreters.exclude
setting to exclude R installati…
…on paths (#6472) ### Summary - addresses #6205 - adds a new setting `positron.r.interpreters.exclude` which allows the user to specify R installation binary paths or directories containing R installations that should be excluded from the UI in Positron #### Settings UI <img width="783" alt="image" src="https://github.com/user-attachments/assets/af5a1fb3-6f2a-49a9-b2a8-24ba4023cef0" /> #### Settings JSON ```json "positron.r.interpreters.exclude": [ "/opt/local" ] ``` #### R Language Pack Output ```js ... 2025-02-25 10:11:26.178 [info] User-specified R binaries: [ "/opt/local/R/4.3-arm64/Resources/bin/R" ] ... 2025-02-25 10:11:26.178 [info] Candidate R binary at /opt/local/R/4.3-arm64/Resources/bin/R 2025-02-25 10:11:26.178 [info] User-specified R installation paths to exclude: [ "/opt/local" ] 2025-02-25 10:11:26.178 [info] User has excluded R installation at /opt/local/R/4.3-arm64/Resources/bin/R 2025-02-25 10:11:26.178 [info] R installation discovered: { "usable": false, "supported": true, "reasonDiscovered": [ "User-specified location", "Found in a conventional location for R binaries installed on a server" ], "reasonRejected": "Installation path was excluded via settings", "binpath": "/opt/local/R/4.3-arm64/Resources/bin/R", "homepath": "/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources", "semVersion": { "options": {}, "loose": false, "includePrerelease": false, "raw": "4.3.3", "major": 4, "minor": 3, "patch": 3, "prerelease": [], "build": [], "version": "4.3.3" }, "version": "4.3.3", "arch": "arm64", "current": false, "orthogonal": true } ... 2025-02-25 10:11:26.178 [info] Filtering out /opt/local/R/4.3-arm64/Resources/bin/R, reason: Installation path was excluded via settings. 2025-02-25 10:11:26.178 [warning] Some discovered R installations are unusable by Positron. 2025-02-25 10:11:26.178 [warning] Learn more about R discovery at https://positron.posit.co/r-installations ``` ### Release Notes #### New Features - New setting to exclude R installation paths from the UI (#6205) #### Bug Fixes - N/A ### QA Notes - please test with and without the `positron.r.customBinaries` and `positron.r.customRootFolders` settings which allow "includes" to be specified - see https://positron.posit.co/r-installations.html#customizing-r-discovery for more info on these options - Positron will need to be restarted upon changing the settings so that discovery can re-run with the settings applied - excluding interpreters via `positron.r.interpreters.exclude` will take precedence over includes with `positron.r.customBinaries` or `positron.r.customRootFolders` - Relative paths specified in the options are ignored
- Loading branch information
1 parent
eb508f9
commit 2a5c332
Showing
9 changed files
with
150 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as path from 'path'; | ||
import * as os from 'os'; | ||
|
||
/** | ||
* Returns true if given file path exists within the given parent directory, false otherwise. | ||
* Copied from the function of the same name in extensions/positron-python/src/client/pythonEnvironments/common/externalDependencies.ts. | ||
* @param filePath File path to check for | ||
* @param parentPath The potential parent path to check for | ||
*/ | ||
export function isParentPath(filePath: string, parentPath: string): boolean { | ||
if (!parentPath.endsWith(path.sep)) { | ||
parentPath += path.sep; | ||
} | ||
if (!filePath.endsWith(path.sep)) { | ||
filePath += path.sep; | ||
} | ||
return normCasePath(filePath).startsWith(normCasePath(parentPath)); | ||
} | ||
|
||
/** | ||
* Adapted from the function of the same name in extensions/positron-python/src/client/pythonEnvironments/common/externalDependencies.ts. | ||
*/ | ||
export function normCasePath(filePath: string): string { | ||
return os.platform() === 'win32' ? path.normalize(filePath).toUpperCase() : path.normalize(filePath); | ||
} | ||
|
||
/** | ||
* Copied from the function of the same name in extensions/positron-python/src/client/pythonEnvironments/common/externalDependencies.ts. | ||
*/ | ||
export function arePathsSame(path1: string, path2: string): boolean { | ||
return normCasePath(path1) === normCasePath(path2); | ||
} | ||
|
||
/** | ||
* Copied from the function of the same name in extensions/positron-python/src/client/common/helpers.ts. | ||
*/ | ||
export function untildify(path: string): string { | ||
return path.replace(/^~($|\/|\\)/, `${os.homedir()}$1`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters