1

Hi I am trying to configure VS Code under WSL to run Ruby code. I have already installed Ruby extension and VSCode Ruby in my VS Code. I also installed ruby from official page. But when I try to run puts ("Hello world!!") it doesn't execute and doesn't show output. Thanks for your answers and advices.

EDIT : My tasks.json file now looks like this

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "start",
            "type": "shell",
            "command": "ruby ${file}",
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": []
        }
    ]
}

But there is still problem it won't build or even run my code

1

1 Answer 1

1

You could configure a task and use the current file variable. Open Tasks: Open Workspace Tasks and than configure the following one in the tasks section:

"tasks": [
    {
        "label": "start",
        "type": "shell",
        "command": "ruby ${file}",
        "options": {
            "cwd": "${fileDirname}"
        }
        "problemMatcher": []
    }
]

Most of the time I use the internal terminal to run my code. I create a bin file and execute my code.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi I just created new json file by configure default build task and paste there your code but I got End of file expected and Incorrect type. Expected "object" I dontt know if it is what you ment
Seems like you replaced the whole file content with my code. You should only replace the tasks section in the file. Give it another try
I put it into json file but it didn't help. Or should I put it into same file as my test code puts("Hello world!") is?
What IDE do you use for Ruby if I may ask ?
VScode. But to run my code I mainly use shell commands directly
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.