Search code examples
ruby-on-railsrubyvisual-studio-codevscode-debugger

How do I add environment variables to launch.json in VSCode for a rails


I am using ruby-debug-ide and debase for debugging in vs code in that when i start debugging by default server is started in development environment, how to debug in a different environment like test/qa? how to configure this launch.json

My launch.json file

{
// 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": [
    {
        "name": "Rails server",
        "type": "Ruby",
        "request": "launch",
        "program": "${workspaceRoot}/bin/rails",
        "args": [
            "server"
        ],
        "showDebuggerOutput": true,
        "env": {
            "PATH": "/Users/giri.shankar/.rvm/gems/ruby-2.6.3@codeforkout/bin:/Users/giri.shankar/.rvm/gems/ruby-2.6.3@global/bin:/Users/giri.shankar/.rvm/rubies/ruby-2.6.3/bin:/Users/giri.shankar/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
            "GEM_HOME": "/Users/giri.shankar/.rvm/gems/ruby-2.6.3@codeforkout",
            "GEM_PATH": "/Users/giri.shankar/.rvm/gems/ruby-2.6.3@codeforkout:/Users/giri.shankar/.rvm/gems/ruby-2.6.3@global",
            "RUBY_VERSION": "ruby-2.6.3"
        }
    }
]

}


Solution

  • For time being i changed the default environment to qa by adding the below line in boot.rb, so now whenever i run rails s qa environment is booted by default

    ENV["RACK_ENV"] = "qa"