purpose of box:::path_tests$rstudio_path, and behavior in RStudio/Posit
- Dominant language
- R
- Stars
- 979
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
### Error description
Say I have an R script
```r
setwd("/home/btyner/branches/r_main")
f <- box::file()
message("file is ", f)
```
If I run the script by manually `source()`ing it, `f` is `"/home/btyner/branches/r_main"`. However, if I instead click the "Source" button from RStudio Desktop or Posit Workbench, `f` is a different directory. It seems the different behavior is due to `box:::path_tests$rstudio_path` (equivalently `box:::rstudio_path`) which makes use of the RStudio API and alters its behavior accordingly.
The difference in behavior is also observed for `box::use()`. In other words, this pattern
```r
setwd("/home/btyner/branches/r_main")
box::use(./Foo/Bar[...])
```
will behave differently depending on the **method** the user chooses for sourcing.
I imagine many users believe that clicking the "Source" button is equivalent to manually running `source()`, since that is what is echoed on the screen upon clicking the button.
In any case, I assume the behavior observed is actually as designed, and that this is not a bug, but I am wondering what is the benefit of this? I did see some documentation under `help(topic = "path", package = "box")` but it doesn't really make clear that the "Source" button is special in this regard.
Thank you for considering.
### R version
```plain text
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 5.3
year 2026
month 03
day 11
svn rev 89597
language R
version.string R version 4.5.3 (2026-03-11 ucrt)
nickname Reassured Reassurer
```
### ‘box’ version
1.2.1
Contributor guide
Research direction
Start with help(topic = "path", package = "box"), then inspect box:::path_tests$rstudio_path and box:::rstudio_path to understand how RStudio or Posit changes path resolution. Compare box::file() and box::use() when run via source() and the Source button. Done means the documentation clearly explains the behavior and its purpose.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100