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

Warning Message Appears When Reloading a Module #363

Closed
thothal opened this issue May 2, 2024 · 0 comments
Closed

Warning Message Appears When Reloading a Module #363

thothal opened this issue May 2, 2024 · 0 comments

Comments

@thothal
Copy link

thothal commented May 2, 2024

Error description

Assume the following modules:

dbg/a.R

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

dbg/b.R

box::use(dbg/a)
#' Title
#' @export
b <- function() {
  print("I am b and call a")
  a$a()
}

dbg/c.R

box::use(dbg/a)
box::use(dbg/b)

#' Title
#' @export
c <- function() {
  print("I am c and call a and b")
  a$a()
  b$b()
}

When trying to reload module c you get the following error:

box::use(dbg/c)
box::reload(c)
# Warning message:
# In rm(list = info$source_path, envir = loaded_mods) :
#   object '<path stripped>\\dbg\\a.R' not found

Issue lies within box:::deregister_mod where we try to remove the module. Because it is loaded twice (once via dbg/b and once via dbg/c) the second attempt to delete it will eventually raise the warning, which I consider spurious.

Easy fix would be to muffle it or to include some chekc to see whether the module is still in loaded_mods.

R version

_                                
platform       x86_64-w64-mingw32               
arch           x86_64                           
os             mingw32                          
crt            ucrt                             
system         x86_64, mingw32                  
status                                          
major          4                                
minor          2.2                              
year           2022                             
month          10                               
day            31                               
svn rev        83211                            
language       R                                
version.string R version 4.2.2 (2022-10-31 ucrt)
nickname       Innocent and Trusting

‘box’ version

1.2.0

@klmr klmr closed this as completed in ee04593 Jun 30, 2024
klmr added a commit that referenced this issue Jun 30, 2024
Fixes #363.

Squashed commit of the following:

commit 9e02d8840f6b832e8bf9a870cc8787fe44925c88
Author: Konrad Rudolph <[email protected]>
Date:   Sat Jun 29 18:51:36 2024 +0200

    Check before dereginstering a module

    A module may have already been deregistered if it was loaded by two
    modules which are both loaded by the module being unloaded by the user.

commit b7a464c9024e58e42e44ac5cd6ba5c76db248e80
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:13:42 2024 +0200

    Add failing unit test

commit ccf9a10
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:31:49 2024 +0200

    Set dev version number

commit b88b59b069b63a2facdbbaf7f364afa5b2063858
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:43:17 2024 +0200

    Document changes
radbasa pushed a commit to Appsilon/box that referenced this issue Jul 1, 2024
Fixes klmr#363.

Squashed commit of the following:

commit 9e02d8840f6b832e8bf9a870cc8787fe44925c88
Author: Konrad Rudolph <[email protected]>
Date:   Sat Jun 29 18:51:36 2024 +0200

    Check before dereginstering a module

    A module may have already been deregistered if it was loaded by two
    modules which are both loaded by the module being unloaded by the user.

commit b7a464c9024e58e42e44ac5cd6ba5c76db248e80
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:13:42 2024 +0200

    Add failing unit test

commit ccf9a10
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:31:49 2024 +0200

    Set dev version number

commit b88b59b069b63a2facdbbaf7f364afa5b2063858
Author: Konrad Rudolph <[email protected]>
Date:   Sun Jun 30 23:43:17 2024 +0200

    Document changes
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

1 participant