Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Debugger in Visual Studio Code does not work despite being installed

I am trying to run R code in Visual Studio Code and I get the following error

`

Fehler in dyn.load(file, DLLpath = DLLpath, ...) : 
  kann shared object '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/vscDebugger/libs/vscDebugger.so' nicht laden:
  dlopen(/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/vscDebugger/libs/vscDebugger.so, 0x0006): tried: '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/vscDebugger/libs/vscDebugger.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

`

I don't know why that first part of the error message is not in English even though English is the set language but that is not the problem. It just says that it cannot load the object vscDebugger.so.

At the same time a window pops that says "Please install the R package vscDebugger" and it asks me to open launch.json which looks as follows

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "R-Debugger",
            "name": "Launch R-Workspace",
            "request": "launch",
            "debugMode": "workspace",
            "workingDirectory": "${workspaceFolder}"
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-File",
            "request": "launch",
            "debugMode": "file",
            "workingDirectory": "${workspaceFolder}",
            "file": "${file}"
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-Function",
            "request": "launch",
            "debugMode": "function",
            "workingDirectory": "${workspaceFolder}",
            "file": "${file}",
            "mainFunction": "main",
            "allowGlobalDebugging": false
        },
        {
            "type": "R-Debugger",
            "name": "Debug R-Package",
            "request": "launch",
            "debugMode": "workspace",
            "workingDirectory": "${workspaceFolder}",
            "includePackageScopes": true,
            "loadPackages": [
                "."
            ]
        },
        {
            "type": "R-Debugger",
            "request": "attach",
            "name": "Attach to R process",
            "splitOverwrittenOutput": true
        }
    ]
}

At the top it says the version is 0.2.0. But if I run packageVersion('vscDebugger') it returns 0.4.7 as the current version.

All of this is just a mess. Why do i have to install vsc debugger when it is already installed and why are there conflicting versions? Also, the last part of the error message says something about an incompatible architecture of the file. what's that all about? Did I install the wrong thing? I am on macOS version 12.6 and my R version is 4.2.1

I already tried uninstalling all the visual studio code extensions related to R and I reinstalled them.

like image 658
Lilanarus Avatar asked Oct 31 '25 07:10

Lilanarus


1 Answers

Same problem occurred to me.

After hours and hours of deep diving through different stack overflow problems, and trying different solutions, I could find the good one for my computer. Don't know if it will work in yours.

These are the steps I followed in order to solve it (I suppose you already did the first three steps, but I post them just in case someone comes along and is really lost on the matter):

1. Open in vs code the folder where is located the R file you want to debug (File -> Open Folder... - or by pressing Ctrl+K and right after Ctrl+O)

2. Create the .json debugger file on the "Run and Debug" button in the left tab of the vs code. It will create a .json file for debugging your R file in the folder you selected in step 1 (image attached).

Step 2: Creating .json debugger file

3. Go to your program and start debugging.

Step 3: Start Debugging


Don't freak out here please

Most probably you are here because this is the step that's not working for you. An emergent window appears and tells you: vscdebugger is not installed or something like that, and gives you the option to open the .json file you just created on step 2.

Also, on the debug console will appear a message telling you something like: install r.debugger.updateRPackage in your computer, you can do it by pressing ctrl+shift+p. So, this is going to be next step:


4. Try to install r.debugger.updateRPackage on the command palette (click ctrl+shift+p)

Step 4: installing r.debugger.updateRPackage

The computer will open a terminal task to install it. If it works, you are done, congrats :). If not - like me - it is because an Error Code occurred during the installation, and it's due to, the task is not getting permissions to overwrite on the folder where it wants to install the vscdebugger package.

Therefore, if step 4 is not working for you. Please, try the following:

5. Check if the you have downloaded jsonlite and R6 packages. Those should be on your library folder inside your R folder. In my case, this is the path: C:\Users\myuser\AppData\Local\Programs\R\R-4.2.2\library but it can be on a different directory in your case. Usually, programs are installed in C:\Program Files. So you should have something like: C:\Program Files\R\R-4.2.2\library. Check there if you have jsonlite and R6 folder.

If you don't have them, install them writing the following command on the R Interactive Terminal: install.packages(c("jsonlite","R6")). The computer may tell you that it has no permissions to install them on the library folder, but it gives you the opportunity to do it on another folder. If this happens, download them on another folder and, then, pass them to the library folder.

Step 5: install.packages command

6. Download the famous vscdebugger package from this url: https://github.com/ManuelHentschel/vscDebugger/releases/tag/v0.5.2 and paste the folder into the library folder where you also have the jsonlite and R6 packages.

Step 6: zip to download

7. Try debugging again (step 3). Now, it should work!!!!

like image 160
Jordi Rabassa Avatar answered Nov 02 '25 22:11

Jordi Rabassa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!