ruby-lsp-rails icon indicating copy to clipboard operation
ruby-lsp-rails copied to clipboard

Ruby LSP Rails prevents dropping the database by keeping an active connection

Open mateusodd opened this issue 1 year ago • 2 comments

Ruby LSP Information

VS Code Version

1.95.3

Ruby LSP Extension Version

0.8.13

Ruby LSP Server Version

0.22.1

Ruby LSP Addons

  • Ruby LSP Rails

Ruby Version

3.3.5

Ruby Version Manager

none

Installed Extensions

Click to expand
  • copilot (1.245.0)
  • copilot-chat (0.22.4)
  • gitlens (16.0.2)
  • ruby-lsp (0.8.13)
  • vscode-eslint (3.0.10)
  • vscode-pull-request-github (0.100.3)

Ruby LSP Settings

Click to expand
Workspace
{
  "rubyVersionManager": {
    "identifier": "none"
  }
}
User
{
  "enableExperimentalFeatures": true,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": false,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "none"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "useLauncher": false,
  "featureFlags": {}
}

Reproduction steps

  1. Open any Rails project with PostgreSQL database.
  2. Run the command bin/rails db:drop in the terminal.
  3. Observe the error message stating that the database cannot be dropped because it is being accessed by another user.

mateusodd avatar Nov 22 '24 19:11 mateusodd

This is expected because the Rails add-on would still have its Rails process active. I'm not sure how we could solve this, as we would need to intercept that command and trigger the LSP to shutdown.

To workaround this for now, you should be able to stop Ruby LSP (Commmand-Shift-P then 'RubyLSP: Stop') before running db:drop.

andyw8 avatar Nov 22 '24 19:11 andyw8

Re-opening this as it affects multiple users and there's currently no good workaround.

vinistock avatar Apr 23 '25 11:04 vinistock

+1 this is annoying, have to force close vscode in order to drop the DB.

SimonBrazell avatar Aug 20 '25 23:08 SimonBrazell

+1 this is annoying, have to force close vscode in order to drop the DB.

See my comment above, you can stop Ruby LSP before running db:drop.

andyw8 avatar Aug 21 '25 00:08 andyw8

Ah right, sorry missed that, thanks @andyw8 🙏

SimonBrazell avatar Aug 21 '25 00:08 SimonBrazell