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

isAvailable() returns TRUE in Positron #302

Closed
vincentarelbundock opened this issue Jul 4, 2024 · 4 comments
Closed

isAvailable() returns TRUE in Positron #302

vincentarelbundock opened this issue Jul 4, 2024 · 4 comments

Comments

@vincentarelbundock
Copy link

The documentation for rstudioapi::isAvailable() says:

Check if RStudio is running.

But that function returns TRUE when called in Positron.

Screenshot 2024-07-04 at 8 00 30 PM
@gadenbuie
Copy link
Member

The docs for rstudioapi::isAvailable() were accurate back when rstudioapi was only useful in RStudio, but it now has counterpart uses in both VS Code and Positron. A more up-to-date description of isAvailable() would be "Check if running in an R session with access to an IDE with rstudioapi support."

For availability of specific functions, I recommend using rstudioapi::hasFun() to test if the IDE supports the function you want to use.

Here's the output of both functions in Positron:

rstudioapi::isAvailable()
#> [1] TRUE
rstudioapi::hasFun("viewer")
#> [1] FALSE

Whereas in RStudio...

rstudioapi::hasFun("viewer")
#> [1] TRUE

@vincentarelbundock
Copy link
Author

Thanks a lot for the clarification and for the suggestion. Very useful!

I'll leave this issue open in case you need a reminder to update the docs, but feel free to close if you think that is more appropriate.

@kylebutts
Copy link

Should rstudioapi::hasFun("viewer") return TRUE since positron has getOption("viewer")?

@gadenbuie
Copy link
Member

Should rstudioapi::hasFun("viewer") return TRUE since positron has getOption("viewer")?

I think that's a good sign that it will eventually return TRUE, but until rstudio::viewer() is wired up in Positron, rstudioapi::hasFun("viewer") should return FALSE to help avoid the error seen in the linked post.

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

No branches or pull requests

4 participants