Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solargraph gets stuck when saving file #234

Open
ruggieroguida opened this issue Nov 15, 2021 · 8 comments
Open

Solargraph gets stuck when saving file #234

ruggieroguida opened this issue Nov 15, 2021 · 8 comments

Comments

@ruggieroguida
Copy link

OS: Bigsur
vscode version: 1.62.2
Ruby 2.7.1 (with rbenv)
solargraph version: 0.44.0
extension version: v0.23.0

All of a sudden solargraph has stopped working. It is not allowing me to save any file and it gets stuck at

"Saving 'anyfile.rb': Running 'Ruby Solargraph' Formatter (configure)."

The only way to proceed is to click cancel. I literally cannot save any file. It has been working fine for years.

This is the content of .solargraph.yml. No change from the default one

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
formatter:
  rubocop:
    cops: safe
    except: []
    only: []
    extra_args: []
require_paths: []
plugins: []
max_files: 5000

Any suggestion?

@castwide
Copy link
Owner

What are your editor.formatOnSave and editor.formatOnSaveMode options?

If you use format on save for other languages, you can disable it for Ruby only in settings.json, e.g.:

    "[ruby]": {
        "editor.formatOnSave": false
    }

I'll still see if I can reproduce the error and make it work correctly. Do you get an error message and/or backtrace in the debug console (Help -> Toggle Developer Tools)?

@ruggieroguida
Copy link
Author

I deleted the project folder and started again and it worked fine.

I managed to reproduce it though.

My new, working settings.json (workspace) has only one line

{
  "solargraph.formatting": true
}

If I add "editor.formatOnSave": true it happens again.

The only message from the console is

[Extension Host] Config changed. Should lint: 1

when I change settings.json

@castwide
Copy link
Owner

Do you also have the rebornix.Ruby extension installed? I suspect that's what sent the "Should lint: 1" message.

@ruggieroguida
Copy link
Author

Nope. I cannot even find it on the marketplace actually

@castwide
Copy link
Owner

@ruggieroguida
Copy link
Author

Oh :-)

Yes. I do

@seanders
Copy link

seanders commented Nov 29, 2021

Related question that I didn't want to create a new issue for: Is the formatter intended to work with this setting?:

editor.formatOnSaveMode: 'modifications'

Setting info here: https://code.visualstudio.com/docs/getstarted/settings#_default-settings

Solargraph formatting works went it formats the whole file. It seems that rubocop doesn't support 'partial' formatting out of the box. (See: rubocop/rubocop#5477)

@ChristianClassen
Copy link

OS: Bigsur
vscode version: 1.63.2
Ruby 2.7.3
solargraph version: 0.44.3
extension version: v0.23.0

Have the exact same problem with two brand new, identical Ruby on Rails Apps (Rails 7).

  • Solargraph installed via Gemfile
  • Solargraph uses the bundled gem

Result:

  • App 1: Formatting on save works perfectly
  • App 2: Formatting fails, shows the following error message

"Saving 'anyfile.rb': Running 'Ruby Solargraph' Formatter (configure)."

// VSCode -  Ruby Settings
    // Extension: Ruby (Peng Lv)
    "ruby.useBundler": true,
    "ruby.useLanguageServer": false,
    "ruby.format": false,
    "[ruby]": {
        // "editor.defaultFormatter": "rebornix.ruby"
        "editor.defaultFormatter": "castwide.solargraph"
    },
    // Extension: Ruby Solargraph
    "solargraph.logLevel": "info",
    "solargraph.diagnostics": true,
    "solargraph.useBundler": true,
    "solargraph.formatting": true,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants