-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message when using orderly interactively.
It is quite easy and common for users to open up a file in RStudio and start running commands from it interactively, using Ctrl-Enter, without setting their working directory to match that file. When that happens, orderly would throw an unhelpful error, saying only `Failed to detect orderly path: /path/to/workspace` without any mention of working directories, or that the path should be a report directory (as opposed to eg. the top-level orderly workspace). The error message is changed to look along the lines of: ``` ! Working directory /path/to/workspace is not a valid orderly report. ``` This should be more helpful, by making it clear what is incorrect (the working directory), and what was expected (an orderly report). Additionally, if running in RStudio and the current active editor is a file in what looks like an orderly report, it will augment the error message with a suggestion of what `setwd` command to run: ``` ! Working directory /path/to/workspace is not a valid orderly report. ℹ Use `setwd("/path/to/workspace/src/my-report")` to set the working directory to the report currently open in RStudio. ``` Finally, even if the working directory is a valid report, but it does not match the directory of the currently active editor (eg. the user has switched from one report to another), orderly commands will succeed as before, but will show a warning to the user: ``` Working directory /path/to/workspace/src/my-report does not match the report currently open in RStudio. ℹ Use `setwd("/path/to/workspace/src/other-report")` to switch working directories. ``` Frustratingly, while RStudio supports "click-to-run" snippets of code in its output, it restricts the syntax of these and in particular does not allow methods from the base package, such as `setwd`. Instead the user has to copy-paste the suggestion into the command prompt themselves. See rstudio/rstudio#11273 and rstudio/rstudio#11434. The restriction is pretty arbitrary and we could easily workaround it by re-exporting the `setwd` function in the orderly2 package if we really wanted to.
- Loading branch information
Showing
5 changed files
with
105 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ Imports: | |
jsonlite, | ||
openssl, | ||
rlang, | ||
rstudioapi, | ||
withr, | ||
yaml | ||
Suggests: | ||
|
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