You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Open the project folder from Positron. Working directory is now set to project.
Open script.R by clicking on it on the left explorer panel.
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)
The text was updated successfully, but these errors were encountered:
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):
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.
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
folder from Positron. Working directory is now set toproject
.script.R
by clicking on it on the left explorer panel.read.csv(../data/xyz.csv)
from insidescript.R
and you'll get the file path error where it expectsread.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 theproject
(root directory). In the example above,read.csv(../data/xyz.csv)
should work instead ofread.csv(data/xyz.csv)
The text was updated successfully, but these errors were encountered: