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

JsonSchema error for rust-analyzer configuration schema #1741

Closed
3 tasks done
yanis-fourel opened this issue Jun 24, 2024 · 3 comments · Fixed by #1757
Closed
3 tasks done

JsonSchema error for rust-analyzer configuration schema #1741

yanis-fourel opened this issue Jun 24, 2024 · 3 comments · Fixed by #1757

Comments

@yanis-fourel
Copy link

I've searched open issues for similar requests

  • Yes

I've manually reviewed logs to find potential errors

  • Yes

I've recently downloaded the latest plugin version of mason.nvim

  • Yes

Problem description

Expanding the "LSP server configuration schema" for rust-analyzer gives the following error

Error executing vim.schedule lua callback: .../lazy/mason.nvim/lua/mason/ui/components/json-schema.lua:119: attempt to concatenate local 'key' (a n
il value)
stack traceback:
        .../lazy/mason.nvim/lua/mason/ui/components/json-schema.lua:119: in function <.../lazy/mason.nvim/lua/mason/ui/components/json-schema.lua:4
7>
        vim/shared.lua: in function 'map'
        .../lazy/mason.nvim/lua/mason/ui/components/json-schema.lua:112: in function 'JsonSchema'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:112: in function 'When'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:106: in function 'When'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:91: in function 'When'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:172: in function 'list_item_renderer'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:14: in function 'PackageListContainer'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:201: in function 'Installed'
        ...mason.nvim/lua/mason/ui/components/main/package_list.lua:369: in function 'PackageList'
        ...im/lazy/mason.nvim/lua/mason/ui/components/main/init.lua:9: in function 'Main'
        ...cal/share/nvim/lazy/mason.nvim/lua/mason/ui/instance.lua:140: in function 'When'
        ...cal/share/nvim/lazy/mason.nvim/lua/mason/ui/instance.lua:137: in function 'renderer'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:496: in function 'debounced_fn'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:21: in function <...share/nvim/lazy/mason.nvim/lua/mason-core/ui/display.lua:20
>

By adding a vim.print(shema) on the line right before the error happens, this is the last messages that got printed:

...
{
  default = false,
  markdownDescription = "Whether to show the main part of the rendered rustc output of a diagnostic message.",
  type = "boolean"
}
{
  default = false,
  markdownDescription = "Whether to show diagnostics using the original rustc error code. If this is false, all rustc diagnostics will have the cod
e 'rustc(Click for full compiler diagnostics)'",
  type = "boolean"
}
{
  title = "$generated-start"
}

and then the error message.

by adding a

if key ~= nil  then
  label = ...
else
  label = "<no key>"
end

Then there is no more error, and here is the displayed Json schema:

      ↓ LSP server configuration schema (press enter to collapse)
        This is a read-only overview of the settings this server accepts. Note that some settings might not apply to neovim.

        → rust-analyzer.cargoRunner                        
        → rust-analyzer.discoverProjectRunner              
        → rust-analyzer.restartServerOnConfigChange         default: false
        → rust-analyzer.showDependenciesExplorer            default: true
        → rust-analyzer.showRequestFailedErrorNotification  default: true
        → rust-analyzer.showUnlinkedFileNotification        default: true
        → rust-analyzer.testExplorer                        default: false
        → rust-analyzer.runnables.extraEnv       
        → rust-analyzer.runnables.problemMatcher  default: ["$rustc"]
        → rust-analyzer.statusBar.clickAction  default: "openLogs"
        → rust-analyzer.server.extraEnv 
        → rust-analyzer.server.path     
        → rust-analyzer.trace.extension  default: false
        → rust-analyzer.trace.server     default: "off"
        → rust-analyzer.debug.engine          default: "auto"
        → rust-analyzer.debug.engineSettings  default: {}
        → rust-analyzer.debug.openDebugPane   default: false
        → rust-analyzer.debug.sourceFileMap   default: {"\/rustc\/<id>":"${env:USERPROFILE}\/.rustup\/toolchains\/<toolchain-id>\/lib\/rustlib\/src\/rust"}
        → rust-analyzer.typing.continueCommentsOnNewline  default: true
        → rust-analyzer.diagnostics.previewRustcOutput  default: false
        → rust-analyzer.diagnostics.useRustcErrorCode   default: false
        <no key>
        → rust-analyzer.assist.emitMustUse  default: false
        → rust-analyzer.assist.expressionFillDefault  default: "todo"
        → rust-analyzer.assist.termSearch.fuel  default: 400
        → rust-analyzer.cachePriming.enable  default: true
        → rust-analyzer.cachePriming.numThreads  default: "physical"
        → rust-analyzer.cargo.allTargets  default: true
        → rust-analyzer.cargo.autoreload  default: true
        → rust-analyzer.cargo.buildScripts.enable  default: true
        → rust-analyzer.cargo.buildScripts.invocationLocation  default: "workspace"
        → rust-analyzer.cargo.buildScripts.invocationStrategy  default: "per_workspace"
        → rust-analyzer.cargo.buildScripts.overrideCommand 
        → rust-analyzer.cargo.buildScripts.rebuildOnSave  default: true
        → rust-analyzer.cargo.buildScripts.useRustcWrapper  default: true
        → rust-analyzer.cargo.cfgs  default: []
        → rust-analyzer.cargo.extraArgs  default: []
        → rust-analyzer.cargo.extraEnv  default: {}
        → rust-analyzer.cargo.features  default: []
        → rust-analyzer.cargo.noDefaultFeatures  default: false
        → rust-analyzer.cargo.sysroot  default: "discover"
        → rust-analyzer.cargo.sysrootQueryMetadata  default: false
        → rust-analyzer.cargo.sysrootSrc 
        → rust-analyzer.cargo.target 
        → rust-analyzer.cargo.targetDir 
        → rust-analyzer.checkOnSave  default: true
        → rust-analyzer.check.allTargets 
        → rust-analyzer.check.command  default: "check"
        → rust-analyzer.check.extraArgs  default: []
        → rust-analyzer.check.extraEnv  default: {}
        → rust-analyzer.check.features 
        → rust-analyzer.check.ignore  default: []
        → rust-analyzer.check.invocationLocation  default: "workspace"
        → rust-analyzer.check.invocationStrategy  default: "per_workspace"
        → rust-analyzer.check.noDefaultFeatures 
        → rust-analyzer.check.overrideCommand 
        → rust-analyzer.check.targets 
        → rust-analyzer.check.workspace  default: true
        → rust-analyzer.completion.autoimport.enable  default: true
        → rust-analyzer.completion.autoself.enable  default: true
        → rust-analyzer.completion.callable.snippets  default: "fill_arguments"
        → rust-analyzer.completion.fullFunctionSignatures.enable  default: false
        → rust-analyzer.completion.limit 
        → rust-analyzer.completion.postfix.enable  default: true
        → rust-analyzer.completion.privateEditable.enable  default: false
        → rust-analyzer.completion.snippets.custom  default: {"Ok":{"postfix":"ok","description":"Wrap the expression in a `Result::Ok`","body":"Ok(${receiver})","scope":"expr"},"Some":{"postfix":"some","description":"Wrap the expression in an `Option::Some`","body":"Some(${receiver})","scope":"expr"},"Arc::new":{"scope":"expr","description":"Put the expression into an `Arc`","body":"Arc::new(${receiver})","postfix":"arc","requires":"std::sync::Arc"},"Err":{"postfix":"err","description":"Wrap the expression in a `Result::Err`","body":"Err(${receiver})","scope":"expr"},"Rc::new":{"scope":"expr","description":"Put the expression into an `Rc`","body":"Rc::new(${receiver})","postfix":"rc","requires":"std::rc::Rc"},"Box::pin":{"scope":"expr","description":"Put the expression into a pinned `Box`","body":"Box::pin(${receiver})","postfix":"pinbox","requires":"std::boxed::Box"}}
        → rust-analyzer.completion.termSearch.enable  default: false
        → rust-analyzer.completion.termSearch.fuel  default: 200
        → rust-analyzer.diagnostics.disabled  default: []
        → rust-analyzer.diagnostics.enable  default: true
        → rust-analyzer.diagnostics.experimental.enable  default: false
        → rust-analyzer.diagnostics.remapPrefix  default: {}
        → rust-analyzer.diagnostics.styleLints.enable  default: false
        → rust-analyzer.diagnostics.warningsAsHint  default: []
        → rust-analyzer.diagnostics.warningsAsInfo  default: []
        → rust-analyzer.files.excludeDirs  default: []
        → rust-analyzer.files.watcher  default: "client"
        → rust-analyzer.highlightRelated.breakPoints.enable  default: true
        → rust-analyzer.highlightRelated.closureCaptures.enable  default: true
        → rust-analyzer.highlightRelated.exitPoints.enable  default: true
        → rust-analyzer.highlightRelated.references.enable  default: true
        → rust-analyzer.highlightRelated.yieldPoints.enable  default: true
        → rust-analyzer.hover.actions.debug.enable  default: true
        → rust-analyzer.hover.actions.enable  default: true
        → rust-analyzer.hover.actions.gotoTypeDef.enable  default: true
        → rust-analyzer.hover.actions.implementations.enable  default: true
        → rust-analyzer.hover.actions.references.enable  default: false
        → rust-analyzer.hover.actions.run.enable  default: true
        → rust-analyzer.hover.documentation.enable  default: true
        → rust-analyzer.hover.documentation.keywords.enable  default: true
        → rust-analyzer.hover.links.enable  default: true
        → rust-analyzer.hover.memoryLayout.alignment  default: "hexadecimal"
        → rust-analyzer.hover.memoryLayout.enable  default: true
        → rust-analyzer.hover.memoryLayout.niches  default: false
        → rust-analyzer.hover.memoryLayout.offset  default: "hexadecimal"
        → rust-analyzer.hover.memoryLayout.size  default: "both"
        → rust-analyzer.hover.show.enumVariants  default: 5
        → rust-analyzer.hover.show.fields  default: 5
        → rust-analyzer.hover.show.traitAssocItems 
        → rust-analyzer.imports.granularity.enforce  default: false
        → rust-analyzer.imports.granularity.group  default: "crate"
        → rust-analyzer.imports.group.enable  default: true
        → rust-analyzer.imports.merge.glob  default: true
        → rust-analyzer.imports.preferNoStd  default: false
        → rust-analyzer.imports.preferPrelude  default: false
        → rust-analyzer.imports.prefix  default: "plain"
        → rust-analyzer.inlayHints.bindingModeHints.enable  default: false
        → rust-analyzer.inlayHints.chainingHints.enable  default: true
        → rust-analyzer.inlayHints.closingBraceHints.enable  default: true
        → rust-analyzer.inlayHints.closingBraceHints.minLines  default: 25
        → rust-analyzer.inlayHints.closureCaptureHints.enable  default: false
        → rust-analyzer.inlayHints.closureReturnTypeHints.enable  default: "never"
        → rust-analyzer.inlayHints.closureStyle  default: "impl_fn"
        → rust-analyzer.inlayHints.discriminantHints.enable  default: "never"
        → rust-analyzer.inlayHints.expressionAdjustmentHints.enable  default: "never"
        → rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe  default: false
        → rust-analyzer.inlayHints.expressionAdjustmentHints.mode  default: "prefix"
        → rust-analyzer.inlayHints.implicitDrops.enable  default: false
        → rust-analyzer.inlayHints.lifetimeElisionHints.enable  default: "never"
        → rust-analyzer.inlayHints.lifetimeElisionHints.useParameterNames  default: false
        → rust-analyzer.inlayHints.maxLength  default: 25
        → rust-analyzer.inlayHints.parameterHints.enable  default: true
        → rust-analyzer.inlayHints.rangeExclusiveHints.enable  default: false
        → rust-analyzer.inlayHints.reborrowHints.enable  default: "never"
        → rust-analyzer.inlayHints.renderColons  default: true
        → rust-analyzer.inlayHints.typeHints.enable  default: true
        → rust-analyzer.inlayHints.typeHints.hideClosureInitialization  default: false
        → rust-analyzer.inlayHints.typeHints.hideNamedConstructor  default: false
        → rust-analyzer.interpret.tests  default: false
        → rust-analyzer.joinLines.joinAssignments  default: true
        → rust-analyzer.joinLines.joinElseIf  default: true
        → rust-analyzer.joinLines.removeTrailingComma  default: true
        → rust-analyzer.joinLines.unwrapTrivialBlock  default: true
        → rust-analyzer.lens.debug.enable  default: true
        → rust-analyzer.lens.enable  default: true
        → rust-analyzer.lens.forceCustomCommands  default: true
        → rust-analyzer.lens.implementations.enable  default: true
        → rust-analyzer.lens.location  default: "above_name"
        → rust-analyzer.lens.references.adt.enable  default: false
        → rust-analyzer.lens.references.enumVariant.enable  default: false
        → rust-analyzer.lens.references.method.enable  default: false
        → rust-analyzer.lens.references.trait.enable  default: false
        → rust-analyzer.lens.run.enable  default: true
        → rust-analyzer.linkedProjects  default: []
        → rust-analyzer.lru.capacity 
        → rust-analyzer.lru.query.capacities  default: {}
        → rust-analyzer.notifications.cargoTomlNotFound  default: true
        → rust-analyzer.notifications.unindexedProject  default: false
        → rust-analyzer.numThreads 
        → rust-analyzer.procMacro.attributes.enable  default: true
        → rust-analyzer.procMacro.enable  default: true
        → rust-analyzer.procMacro.ignored  default: {}
        → rust-analyzer.procMacro.server 
        → rust-analyzer.references.excludeImports  default: false
        → rust-analyzer.references.excludeTests  default: false
        → rust-analyzer.runnables.command 
        → rust-analyzer.runnables.extraArgs  default: []
        → rust-analyzer.runnables.extraTestBinaryArgs  default: ["--show-output"]
        → rust-analyzer.rustc.source 
        → rust-analyzer.rustfmt.extraArgs  default: []
        → rust-analyzer.rustfmt.overrideCommand 
        → rust-analyzer.rustfmt.rangeFormatting.enable  default: false
        → rust-analyzer.semanticHighlighting.doc.comment.inject.enable  default: true
        → rust-analyzer.semanticHighlighting.nonStandardTokens  default: true
        → rust-analyzer.semanticHighlighting.operator.enable  default: true
        → rust-analyzer.semanticHighlighting.operator.specialization.enable  default: false
        → rust-analyzer.semanticHighlighting.punctuation.enable  default: false
        → rust-analyzer.semanticHighlighting.punctuation.separate.macro.bang  default: false
        → rust-analyzer.semanticHighlighting.punctuation.specialization.enable  default: false
        → rust-analyzer.semanticHighlighting.strings.enable  default: true
        → rust-analyzer.signatureInfo.detail  default: "full"
        → rust-analyzer.signatureInfo.documentation.enable  default: true
        → rust-analyzer.typing.autoClosingAngleBrackets.enable  default: false
        → rust-analyzer.workspace.symbol.search.kind  default: "only_types"
        → rust-analyzer.workspace.symbol.search.limit  default: 128
        → rust-analyzer.workspace.symbol.search.scope  default: "workspace"
        <no key>

Expected behavior

Show the server configuration json schema without error

Steps to reproduce

  1. Install mason (commit: 37a336b)
  2. Install rust-analyzer ( installed version 2024-06-17 )
  3. Launch nvim
  4. :Mason
  5. Expand rust-analyzer
  6. Expand LSP server configuration schema (press enter to expand)

Affected packages

rust-analyzer

Neovim version (>= 0.7)

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478

Operating system/version

Linux xxx 6.9.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 16 Jun 2024 19:06:37 +0000 x86_64 GNU/Linux

Healthcheck

mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers: 
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-06-24-fatal-soy` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send`
- WARNING wget: not available
  - ADVICE:
    - spawn: wget failed with exit code - and signal -. wget is not executable
- OK curl: `curl 8.8.0 (x86_64-pc-linux-gnu) libcurl/8.8.0 OpenSSL/3.3.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.62.1 nghttp3/1.4.0`
- OK gzip: `gzip 1.13`
- OK tar: `tar (GNU tar) 1.35`
- OK bash: `GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- WARNING Ruby: not available
  - ADVICE:
    - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING RubyGem: not available
  - ADVICE:
    - spawn: gem failed with exit code - and signal -. gem is not executable
- OK Go: `go version go1.22.4 linux/amd64`
- OK cargo: `cargo 1.79.0`
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK node: `v22.3.0`
- OK python: `Python 3.12.4`
- WARNING pip: not available
  - ADVICE:
    - spawn: python3 failed with exit code 1 and signal 0. /usr/bin/python3: No module named pip
      
- OK java: `openjdk version "21.0.3" 2024-04-16`
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code 1 and signal 0. Error: Unable to load main class com.sun.tools.javac.Main in module jdk.compiler
      	java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-21-openjdk/lib/libnio.so: /usr/lib/jvm/java-21-openjdk/lib/libnio.so: undefined symbol: reuseport_available
      Runtime.exit(1) logging failed: Could not initialize class jdk.internal.module.SystemModuleFinders$SystemImage
      
- OK python venv: `Ok`
- OK npm: `10.8.1`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 12. Remaining: 48. Limit: 60. Reset: Mon 24 Jun 2024 05:12:57 PM CST.
  Install and authenticate via gh-cli to increase rate limit.

Screenshots or recordings

No response

@berkantkockaya
Copy link

Hi, the issue involves a JsonSchema error for the rust-analyzer configuration schema in the mason.nvim plugin. To solve it:

1.	Identify the source of the error in json-schema.lua at line 119, where a nil value is being concatenated.
2.	Add a conditional check to handle the nil value by setting a default label if key is nil.
3.	Test the modified code to ensure it displays the configuration schema correctly without errors.

@chaozwn
Copy link

chaozwn commented Jul 9, 2024

Has the issue been fixed?

@chaozwn
Copy link

chaozwn commented Jul 10, 2024

Lock the version for now to avoid this problem and require mason to update the code.

opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "rust_analyzer@2024-05-27" })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

3 participants