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

Add support for vscDebugger #22

Open
bersbersbers opened this issue Apr 21, 2021 · 11 comments
Open

Add support for vscDebugger #22

bersbersbers opened this issue Apr 21, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@bersbersbers
Copy link

whereami::thisfile() returns NULL when debugging code using https://github.com/ManuelHentschel/vscDebugger.

I see a couple of options:

  1. Relax the check at

    if (identical(args(sys.function(i)), args(base::source))) {

  2. Include this check:

if (exists(".vsc.getSession")) {
    .vsc.getSession()$file
}
@yonicd
Copy link
Owner

yonicd commented Apr 21, 2021

thanks for opening this issue. i will try to get to it this week.

@yonicd yonicd added the enhancement New feature or request label Apr 21, 2021
@yonicd
Copy link
Owner

yonicd commented Apr 21, 2021

what is the expected result? if i add .vsc.getSession()$file i get main.R in the debug console

@bersbersbers
Copy link
Author

bersbersbers commented Apr 21, 2021

what is the expected result? if i add .vsc.getSession()$file i get main.R in the debug console

It depends on the context, I guess. In interactive R.exe, I get this:

> .vsc.getSession()$file
Error in .vsc.getSession() : could not find function ".vsc.getSession"
> library(vscDebugger)
> .vsc.getSession()$file
[1] ""

which is expected, I guess. The same is true in plain Rscript.exe:

C:\Users\bers>echo library(vscDebugger);print(.vsc.getSession()$file) > test.R && Rscript test.R
[1] ""

because we are not using vscDebugger for debugging.

By contrast, when debugging, in VS Code using https://github.com/ManuelHentschel/VSCode-R-Debugger, D:\testing.R which contains only

print(.vsc.getSession()$file)

the output is (correctly)

[1] "D:\\testing.R"

image

@ColinFay
Copy link
Contributor

Was coming here to post that we need VSCode support :)

whereami::whereami()

is empty when run from VSCode.

@ColinFay
Copy link
Contributor

Note: on modern version of the R VSCode extension, there are wrappers around rstudioapi, so you can do rstudioapi::getActiveDocumentContext()$path inside VSCode

@yonicd
Copy link
Owner

yonicd commented Oct 26, 2021

are we sure it isnt working?
Screen Shot 2021-10-25 at 8 17 58 PM

Screen Shot 2021-10-25 at 8 23 33 PM

@bersbersbers
Copy link
Author

bersbersbers commented Oct 26, 2021

Yes, we are sure it's not working ;) because this issue is about whereami::thisfile(), not whereami::whereami():

image

Or am I wrong in expecting that whereami::thisfile() should return something useful here?

@bersbersbers
Copy link
Author

bersbersbers commented Oct 26, 2021

Here's something else which is weird:

image

While .whereami and .thisfile have the same body, they behave differently.

@yonicd
Copy link
Owner

yonicd commented Oct 27, 2021

not sure why you are using whereami::thisfile the function itself should return NULL since it doesn't answer any of the checks that it is intended to look at.

whereami::whereami is the right choice when running interactively, and even then if it is not interactive under the hood it is falling back to thisfile.

@yonicd
Copy link
Owner

yonicd commented Oct 27, 2021

what is the usecase of print(whereami)? there is already a function for this called whereami::cat_where

@bersbersbers
Copy link
Author

not sure why you are using whereami::thisfile

Because whereami::whereami does not return a filename, but some object that I would have to extract the filename from.

the function itself should return NULL since it doesn't answer any of the checks that it is intended to look at.

That is good to know - it wasn't clear from the reference manual.

whereami::whereami is the right choice when running interactively

I am not working interactively, unfortunarely.

and even then if it is not interactive under the hood it is falling back to thisfile.

True, but not completely, as shown above in my first example above.

what is the usecase of print(whereami)? there is already a function for this called whereami::cat_where

This is only an example to simulate what happens when the return value is captured in a variable. I usually do something like setwd(dirname(whereami::thisfile())).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants