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

Time:10-22

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"
        }
    }
]

}

CodePudding user response:

You just have to add -e test to the rails server command:

{
    ...

    "args": [
        "rails server -e test"
    ]
}

CodePudding user response:

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"

  • Related