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

here::i_am() not working with RStudio #106

Closed
KleinWurm opened this issue May 13, 2024 · 2 comments
Closed

here::i_am() not working with RStudio #106

KleinWurm opened this issue May 13, 2024 · 2 comments

Comments

@KleinWurm
Copy link

KleinWurm commented May 13, 2024

I faced this issue while playing around with here::i_am() and found #73 (comment) which is very related but does point the exact same problem.

Problem: here::i_am() returns default RStudio working directory (even when set to ~ in global options).

image

With here 1.0.1, RStudio 2024.04.0+735 and R version 4.3.2.

Example:

Structure of the folder:

 test
    .here
     test_script.R

And the content of test_script.R is:

here::i_am(path = "test_script.R")

Console output when test_script.R is executed from RStudio:

> here::i_am(path = "test_script.R")
Erreur : Could not find associated project in working directory or any parent directory.
- Path in project: test_script.R
- Current working directory: C:/Users/Username/Documents
Please open the project associated with this file and try again.

It shows a similar error if I try

here::i_am(path = ".here")

However, if I run the script from Visual Studio, I get the expected output:

> here::i_am(path = ".here") # also works with "test_script.R" instead of ".here"
here() starts at C:/Users/[path]/test

This suggests an incompatibility of here::i_am() with RStudio.

@krlmlr
Copy link
Member

krlmlr commented May 20, 2024

It works for me when I have opened a project in RStudio. What does getwd() show?

@KleinWurm
Copy link
Author

@krlmlr sorry for my late reply, I tried again with RStudio RStudio 2024.04.1+748 " and R version 4.3.2 and it seems that the here::i_am() function now works in RStudio with the same behavior as in Visual Studio.

From RStudio, I get the same output as from Visual Studio:

> here::i_am(path = "test_script.R") 
here() starts at C:/Users/[path]/test

And getwd() returns C:/Users/[path]/test.

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

2 participants