Search code examples
jsonrubyvisual-studio-codelaunch

Visual Studio Code (Ruby) uncaught exception - cannot load such file


I started coding in ruby in visual studio code and I am having problems loading my file. When my file name is named main.rb which I find in launch.json under configurations "program": "${workspaceRoot}/main.rb" it loads just fine but when I change my file name to example.rb the only way I am able to run the code is if I change main.rb to example.rb in launch.json

I am sure that I am doing something wrong but I am having a tough time finding any answers on the internet to resolve this issue.


Solution

  • Open your launch.json file and change it like this (only the value of the key "program" is changing):

    Before:
    {
    "name": "Debug Local File",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "program": "${workspaceRoot}/main.rb"
    }

    After:
    {
    "name": "Debug Local File",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "program": "${file}"
    }