Skip to content

Commit a991e89

Browse files
authored
Use devtools::install() instead of pak (#13643)
Closes #11875 Closes #1733 @:r-pkg-development When working in an R package, the *R: Install R Package and Restart R* gesture now defaults to [`devtools::install(build = FALSE)`](https://devtools.r-lib.org/reference/install.html), instead of `pak::local_install(upgrade = FALSE)`. The rationale for this switch is laid out in the issue. This also affects the `positron.r.localPackageInstallMethod` configuration point, where `devtools` replaces `pak`. ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - *R: Install R Package and Restart R* now defaults to `devtools::install(build = FALSE)`, instead of `pak::local_install(upgrade = FALSE)`. The values of the `positron.r.localPackageInstallMethod` setting can now be `"devtools"` or `"base"`. #### Bug Fixes - N/A ### Validation Steps * Open a workspace in Positron that is also an R package. * Make sure you've got devtools >= 2.5.2. * Make sure you don't have `positron.r.localPackageInstallMethod` configured in `settings.json`. * Do *R: Install R Package and Restart R*. In the terminal that fulfills this, you should see invocation of `devtools::install(build = FALSE)`: ``` Executing task: '/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/bin/R' --quiet --no-restore --no-save -e 'devtools::install(build = FALSE)' ``` ### For discussion: Should we put a minimum version on devtools, in order to get new, desirable behaviour of `devtools::install()`? It seems too strong a requirement and yet people will not have the experience we really want for them if they have older devtools. It feels like the "devtools vs. base" question is bigger than just how to wire up *R: Install R Package and Restart R*. Are we going to deal with this more holistically? Recall that RStudio has a project-level setting for "Use devtools package functions if available". Here are all the package dev commands: | Command | Display name | Backed by | |---|---|---| | `r.packageLoad` | Load R Package | `devtools::load_all()` — hardcoded | | `r.packageBuild` | Build R Package | `devtools::build()` — hardcoded | | `r.packageInstall` | Install R Package and Restart R | `devtools::install(build = FALSE)` or `R CMD INSTALL` — configurable (this PR) | | `r.packageTest` | Test R Package in Terminal | `devtools::test()` — hardcoded (task) | | `r.packageTestExplorer` | Test R Package in Test Explorer | runs testthat via test explorer, which also uses devtools/testthat | | `r.packageCheck` | Check R Package | `devtools::check()` — hardcoded (task) | | `r.packageDocument` | Document R Package | `devtools::document()` — hardcoded | Are we going to offer devtools vs base for others? In the abstract, it feels like we should. But here in reality it doesn't really make sense. Making this sort of thing clearcut and easier is precisely why devtools & friends exist! Only a couple of these even have a clearcut definition for a base implementation. Related: the idea of making it possible for an advanced and opinionated user to take full control of these gestures: #3242.
1 parent 3ffd594 commit a991e89

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

extensions/positron-r/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@
244244
"positron.r.localPackageInstallMethod": {
245245
"scope": "window",
246246
"type": "string",
247-
"enum": ["pak", "base"],
248-
"default": "pak",
247+
"enum": ["devtools", "base"],
248+
"default": "devtools",
249249
"markdownDescription": "%r.configuration.localPackageInstallMethod.description%"
250250
}
251251
}

extensions/positron-r/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"r.configuration.symbols.includeAssignmentsInBlocks.description": "Controls whether assigned objects inside `{}` blocks are included as document symbols, in addition to top-level assignments. Reopen files or restart the server for the setting to take effect.",
8383
"r.configuration.workspaceSymbols.includeCommentSections.description": "Controls whether comment sections like `# My section ---` are included as workspace symbols.",
8484
"r.configuration.autoConvertFilePaths.description": "Automatically convert file paths when pasting files from file manager into R scripts. Converts backslashes (\\) to forward slashes (/), adds quotes, and formats multiple files as R vectors.",
85-
"r.configuration.localPackageInstallMethod.description": "How to install the local R package project. When set to `pak`, uses `pak::local_install()`. When set to `base`, uses `R CMD INSTALL`.",
85+
"r.configuration.localPackageInstallMethod.description": "How to install the local R package project. When set to `devtools`, uses `devtools::install(build = FALSE)`. When set to `base`, uses `R CMD INSTALL`.",
8686
"r.configuration.defaultRepositories.description": "The default repositories to use for R package installation, if no repository is otherwise specified in R startup scripts (restart Positron to apply).\n\nThe default repositories will be set as the `repos` option in R.",
8787
"r.configuration.defaultRepositories.auto.description": "Automatically choose a default repository, or use a repos.conf file if it exists.",
8888
"r.configuration.defaultRepositories.rstudio.description": "Use the RStudio CRAN mirror (cran.rstudio.com)",

extensions/positron-r/src/tasks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function providePackageTasks(context: vscode.ExtensionContext): Pro
2828
);
2929
}
3030

31-
type InstallMethod = 'pak' | 'base';
31+
type InstallMethod = 'devtools' | 'base';
3232

3333
function getPackageInstallTask(installMethod: InstallMethod) {
3434
if (installMethod === 'base') {
@@ -43,8 +43,8 @@ function getPackageInstallTask(installMethod: InstallMethod) {
4343
return {
4444
task: 'r.task.packageInstall',
4545
message: vscode.l10n.t('{taskName}', { taskName: 'Install R package' }),
46-
rcode: 'pak::local_install(upgrade = FALSE)',
47-
package: 'pak',
46+
rcode: 'devtools::install(build = FALSE)',
47+
package: 'devtools',
4848
envVars: null
4949
};
5050
}
@@ -56,7 +56,7 @@ export async function getRPackageTasks(editorFilePath?: string): Promise<vscode.
5656
const binpath = RSessionManager.instance.getLastBinpath();
5757

5858
const config = vscode.workspace.getConfiguration('positron.r');
59-
const installMethod = config.get<InstallMethod>('localPackageInstallMethod', 'pak');
59+
const installMethod = config.get<InstallMethod>('localPackageInstallMethod', 'devtools');
6060

6161
const taskData = [
6262
{

test/e2e/tests/r-pkg-development/r-pkg-development.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test.describe('R Package Development', { tag: [tags.R_PKG_DEVELOPMENT, tags.ARK]
8383
await app.workbench.console.waitForConsoleContents('"testfun"');
8484

8585
// Reset setting to default
86-
await settings.set({ 'positron.r.localPackageInstallMethod': 'pak' });
86+
await settings.set({ 'positron.r.localPackageInstallMethod': 'devtools' });
8787
});
8888
});
8989
});

0 commit comments

Comments
 (0)