Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local module sourcing occasionally fails with RStudio run #365

Open
caldwellst opened this issue May 28, 2024 · 1 comment
Open

Local module sourcing occasionally fails with RStudio run #365

caldwellst opened this issue May 28, 2024 · 1 comment

Comments

@caldwellst
Copy link

caldwellst commented May 28, 2024

Error description

When interactively developing in RStudio, I often might run selections of code by running line by line or highlighting a section to run with cmd + enter or the Run button. This occasionally generates errors when running box::use(local/module), even though the relative sourcing is correct. Below is an example with two modules a and b in the same directory:

a.R

#' Title
#' @export
a <- function() {
  print("I am a")
}

b.R

box::use(./a)

a$a()

If I open up b.R and highlight the code and run, it is successful:

image

However, if I leave the same code block highlighted, restart my R session, and click run without re-highlighting the code, it fails, indicating that it is unable to load module a in my current project directory.

image

However, clicking back on the b.R script and running line by line or re-highlighting will successfully run. With more complex modules with multiple imports, running code line by line can generate the same error, where it seems the RStudio pathing has lost track of the source file and defaults to project directory or base directory, depending if in a project environment or not.

I can explore a more complex reprex if helpful. This is not a critical bug, but something other colleagues have noticed so flagging here.

R version

_                           
platform       x86_64-apple-darwin20       
arch           x86_64                      
os             darwin20                    
system         x86_64, darwin20            
status                                     
major          4                           
minor          3.3                         
year           2024                        
month          02                          
day            29                          
svn rev        86002                       
language       R                           
version.string R version 4.3.3 (2024-02-29)
nickname       Angel Food Cake

RStudio version

$mode
[1] "desktop"

$version
[1] ‘2023.12.1.402’

$long_version
[1] "2023.12.1+402"

$release_name
[1] "Ocean Storm"

‘box’ version

‘1.2.0’

@klmr
Copy link
Owner

klmr commented Jul 24, 2024

Hi,

Thanks for the detailed error description! Unfortunately I am completely unable to reproduce this issue… I’ve attached a video where I am running your example as closely as I can reproduce it, including using an ‘renv’ environment.

Screen.Recording.2024-07-24.at.18.51.08.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants