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

.Rprofile never gets to run if "workingDirectory" is not set to ${workspaceFolder} #182

Open
EricBataller opened this issue Mar 13, 2024 · 1 comment

Comments

@EricBataller
Copy link

Hi there

In the configuration.md documentation, section 3.1 (Launch Requests) says the following:

"workingDirectory": An absolute path to the desired work directory. Defaults to the workspace folder. The R process is always launched in the workspace folder (reading the .Rprofile there) and then changes directory.

From this fragment, I would expect R-debugger to:

  1. Start always on the workspace folder ${workspaceFolder}.
  2. Run the .Rprofile in the workspace folder (if any).
  3. Switch working directory to that specified by the argument "workingDirectory" in the respective R-debugger configuration the user is running from launch.json file.

However, it seems like .Rprofile never gets to run if "workingDirectory" is not set to ${workspaceFolder}.

To Reproduce
For a dummy example, let the following be our project structure:

my_root                                # Our workspace directory
  ├── .vscode   
  │       └── launch.json    
  ├── .Rprofile       
  └── subdirectory
           └── bye_world.R 

Let .Rprofile be:

Sys.setenv("MESSAGE" = "hello world!")

Let bye_world.R be:

print(Sys.getenv("MESSAGE"))
print('bye world!')

If we let launch.json be:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "R-Debugger",
            "name": "Debug R-File",
            "request": "launch",
            "debugMode": "file",
            "workingDirectory": "${workspaceFolder}",
            "file": "${file}"
        }

    ]
}

and then we proceed to launch R-debugger from file bye_world.R, the debugger will first run .Rprofile and then proceed with bye_world.R, just to obtain the expected output:

[1] "hello world!"
[1] "bye world!"

However, if we let launch.json be:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "R-Debugger",
            "name": "Debug R-File",
            "request": "launch",
            "debugMode": "file",
            "workingDirectory": "${workspaceFolder}/subdirectory",
            "file": "${file}"
        }

    ]
}

One would still expect R-debugger to run the .Rprofile, but that's not the case, as revealed by the output obtained by running the debugger from file bye_world.R, where we can see that MESSAGE variable never gets defined:

[1] ""
[1] "bye world!"

Is this the expected behaviour (and thus the documentation in configuration.md is a bit misleading), or should the debugger run .Rprofile despite the "workingDirectory" specified?

Desktop:

  • R Version: 4.2.2
  • vscDebugger Version: 0.5.2
  • vscode-r-debugger Version: 0.5.4
@ManuelHentschel
Copy link
Owner

Thanks for opening this issue and the detailed info. This is the intended behaviour. The documentation in configuration.md was outdated, sorry about that. eb4ebeb updates the documentation accordingly.

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