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

Wrong behavior for (relative) file paths #4204

Closed
hauselin opened this issue Aug 1, 2024 · 2 comments
Closed

Wrong behavior for (relative) file paths #4204

hauselin opened this issue Aug 1, 2024 · 2 comments

Comments

@hauselin
Copy link

hauselin commented Aug 1, 2024

System details:

Positron and OS details:

Positron Version: 2024.07.0 (Universal) build 125
Code - OSS Version: 1.91.0
Commit: cae4905
Date: 2024-08-01T00:27:06.019Z (13 hrs ago)
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.4.0

Interpreter details:

R4.4.0

Describe the issue:

Currently, for any given console, the working directory getwd() is always a project's root directory, no matter where the source code lives within the project. VSCode doesn't behave like this.

Steps to reproduce the issue:

Create a folder with this common project structure:

project
—— README.md
—— .gitignore
—— venv
—— src (source code)
———— script.R
—— data (where data lives)
———— xyz.csv
  1. Open the project folder from Positron. Working directory is now set to project.
  2. Open script.R by clicking on it on the left explorer panel.
  3. Run read.csv(../data/xyz.csv) from inside script.R and you'll get the file path error where it expects read.csv(data/xyz.csv)

Expected or desired behavior:

In VSCode, file paths are always relative to the directory the current file/script lives in (src in the example above), not the project (root directory). In the example above, read.csv(../data/xyz.csv) should work instead of read.csv(data/xyz.csv)

@juliasilge
Copy link
Contributor

Thanks for this feedback! This is in fact currently working as intended, at least as we currently envision the console's working directory, but we are interested in hearing more about folks' use cases. There are some related questions in #3156 specifically for code cells, but just for the console itself, we don't think it's going to be reasonable to use the path to any given file to set the working directory. You can always see the current working directory in the console UI (you can think of it much like a terminal in that it has a working directory and you would need to change that explicitly):

working-dir

You can think of this as behaving like RStudio's console, and we would often recommend that you use the here package to solve frustrations with file paths.

@hauselin
Copy link
Author

hauselin commented Aug 1, 2024

Good to know. Thanks for clarifying!

@hauselin hauselin closed this as completed Aug 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants