Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Proselint: failed to decode json: Expected value but found invalid token at character 1 #969

Open
2 tasks done
milanglacier opened this issue Jul 25, 2022 · 10 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@milanglacier
Copy link

milanglacier commented Jul 25, 2022

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Issues

  • I have checked existing issues and there are no issues with the same problem.

Neovim Version

0.7.2

Operating System

macOS 12.4

Minimal config

-- this template is borrowed from nvim-lspconfig
local on_windows = vim.loop.os_uname().version:match("Windows")

local function join_paths(...)
    local path_sep = on_windows and "\\" or "/"
    local result = table.concat({ ... }, path_sep)
    return result
end

vim.cmd([[set runtimepath=$VIMRUNTIME]])

local temp_dir
if on_windows then
    temp_dir = vim.loop.os_getenv("TEMP")
else
    temp_dir = "/tmp"
end

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local null_ls_config = function()
    local null_ls = require("null-ls")
    -- add only what you need to reproduce your issue
    null_ls.setup({
        sources = {
                null_ls.builtins.code_actions.proselint.with {
                filetypes = { 'markdown', 'markdown.pandoc', 'tex', 'rmd' },
            },
            null_ls.builtins.diagnostics.proselint.with {
                filetypes = { 'markdown', 'markdown.pandoc', 'tex', 'rmd' },
            },
        },
        debug = true,
    })
end

local function load_plugins()
    -- only add other plugins if they are necessary to reproduce the issue
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            {
                "jose-elias-alvarez/null-ls.nvim",
                requires = { "nvim-lua/plenary.nvim" },
                config = null_ls_config,
            },
        },
        config = {
            package_root = package_root,
            compile_path = compile_path,
        },
    })
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
    load_plugins()
    require("packer").sync()
else
    load_plugins()
    require("packer").sync()
end

proselint version: 0.13.0

Steps to reproduce

  1. open any markdown file, for example test.md
This is test file
let's start to configure it

Type the following test any save the file occasionally, then will get the following error:

[null-ls] failed to run generator: ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:64: failed to decode json: Expected value but found invalid token at character 1

Expected behavior

shouldn't have any warning

Actual behavior

get the following error:

[null-ls] failed to run generator: ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:64: failed to decode json: Expected value but found invalid token at character 1

Debug log

```

[TRACE Mon Jul 25 03:19:42 2022] ...site/pack/packer/opt/null-ls.nvim/lua/null-ls/client.lua:106: starting null-ls client
[TRACE Mon Jul 25 03:19:42 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method initialize
[DEBUG Mon Jul 25 03:19:42 2022] ...site/pack/packer/opt/null-ls.nvim/lua/null-ls/client.lua:161: unable to notify client for method textDocument/didOpen (client not active): {
textDocument = {
uri = "file:///Users/northyear/Desktop/test.md"
}
}
[TRACE Mon Jul 25 03:19:42 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method initialized
[TRACE Mon Jul 25 03:19:42 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didOpen
[TRACE Mon Jul 25 03:19:42 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN
[DEBUG Mon Jul 25 03:19:42 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "proselint" at /Users/northyear/Desktop with args { "--json" }
[TRACE Mon Jul 25 03:19:42 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: nil
[TRACE Mon Jul 25 03:19:42 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: {"data": {"errors": []}, "status": "success"}

[TRACE Mon Jul 25 03:19:42 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:169: received diagnostics from source 2
[TRACE Mon Jul 25 03:19:42 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:170: {}
[TRACE Mon Jul 25 03:19:45 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didChange
[TRACE Mon Jul 25 03:19:45 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS
[DEBUG Mon Jul 25 03:19:45 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "proselint" at /Users/northyear/Desktop with args { "--json" }
[TRACE Mon Jul 25 03:19:45 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: nil
[TRACE Mon Jul 25 03:19:45 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: {"data": {"errors": []}, "status": "success"}

[TRACE Mon Jul 25 03:19:45 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:169: received diagnostics from source 2
[TRACE Mon Jul 25 03:19:45 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:170: {}
[TRACE Mon Jul 25 03:19:46 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:46 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:46 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:46 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:47 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:47 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:47 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:47 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:48 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:48 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:48 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:48 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:49 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:49 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:49 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:52 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:52 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:52 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:52 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:53 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:53 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:53 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:53 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:54 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:54 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:54 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:57 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/completion
[TRACE Mon Jul 25 03:19:57 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_COMPLETION
[DEBUG Mon Jul 25 03:19:57 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[DEBUG Mon Jul 25 03:19:57 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/completion.lua:16: received no completion results from generators
[TRACE Mon Jul 25 03:19:57 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didChange
[TRACE Mon Jul 25 03:19:57 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS
[DEBUG Mon Jul 25 03:19:57 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "proselint" at /Users/northyear/Desktop with args { "--json" }
[TRACE Mon Jul 25 03:19:58 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didChange
[TRACE Mon Jul 25 03:19:58 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS
[DEBUG Mon Jul 25 03:19:58 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "proselint" at /Users/northyear/Desktop with args { "--json" }
[TRACE Mon Jul 25 03:19:58 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: nil
[TRACE Mon Jul 25 03:19:58 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: {"data": {"errors": []}, "status": "success"}

[TRACE Mon Jul 25 03:19:58 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:169: received diagnostics from source 2
[TRACE Mon Jul 25 03:19:58 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:170: {}
[DEBUG Mon Jul 25 03:19:58 2022] ...pack/packer/opt/null-ls.nvim/lua/null-ls/diagnostics.lua:173: buffer changed; ignoring received diagnostics
[TRACE Mon Jul 25 03:19:58 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: nil
[TRACE Mon Jul 25 03:19:58 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.airlinese.misc.check') opening /Users/northyear/.cache/proselint/checks.airlinese.misc.check - will attempt to delete and re-open.
Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.annotations.misc.check') opening /Users/northyear/.cache/proselint/checks.annotations.misc.check - will attempt to delete and re-open.
Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.archaism.misc.check') opening /Users/northyear/.cache/proselint/checks.archaism.misc.check - will attempt to delete and re-open.
Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.cliches.hell.check_repeated_exclamations') opening /Users/northyear/.cache/proselint/checks.cliches.hell.check_repeated_exclamations - will attempt to delete and re-open.
Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.cliches.misc.check_cliches_garner') opening /Users/northyear/.cache/proselint/checks.cliches.misc.check_cliches_garner - will attempt to delete and re-open.
{"data": {"errors": []}, "status": "success"}

[WARN Mon Jul 25 03:19:58 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:78: failed to run generator: ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:64: failed to decode json: Expected value but found invalid token at character 1
[TRACE Mon Jul 25 03:19:59 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didSave
[TRACE Mon Jul 25 03:19:59 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_SAVE
[DEBUG Mon Jul 25 03:19:59 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[TRACE Mon Jul 25 03:20:01 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method textDocument/codeAction
[TRACE Mon Jul 25 03:20:01 2022] .../pack/packer/opt/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_CODE_ACTION
[DEBUG Mon Jul 25 03:20:01 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "proselint" at /Users/northyear/Desktop with args { "--json" }
[TRACE Mon Jul 25 03:20:02 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: nil
[TRACE Mon Jul 25 03:20:02 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: {"data": {"errors": []}, "status": "success"}

[TRACE Mon Jul 25 03:20:02 2022] ...ack/packer/opt/null-ls.nvim/lua/null-ls/code-actions.lua:35: received code actions from generators
[TRACE Mon Jul 25 03:20:02 2022] ...ack/packer/opt/null-ls.nvim/lua/null-ls/code-actions.lua:36: {}
[TRACE Mon Jul 25 03:20:02 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method shutdown
[TRACE Mon Jul 25 03:20:02 2022] ...im/site/pack/packer/opt/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method exit

</details>

### Help

No

### Implementation help

_No response_

### Requirements

- [X] I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
@milanglacier milanglacier added the bug Something isn't working label Jul 25, 2022
@jose-elias-alvarez
Copy link
Owner

jose-elias-alvarez commented Jul 25, 2022

Is there a reliable way to replicate this? I saw the same error the first time I set up proselint according to your instructions but haven't seen it again, even after deleting / messing with the cache folder.

The issue is quite clear: when there's a cache error, proselint outputs a bunch of non-JSON error lines, which causes the JSON parser to choke. We can theoretically work around this here by doing something like this (untested since I haven't been able to reliably replicate the error):

diff --git a/lua/null-ls/builtins/diagnostics/proselint.lua b/lua/null-ls/builtins/diagnostics/proselint.lua
index 1a53fcf..f09eba6 100644
--- a/lua/null-ls/builtins/diagnostics/proselint.lua
+++ b/lua/null-ls/builtins/diagnostics/proselint.lua
@@ -14,19 +14,26 @@ return h.make_builtin({
     generator_opts = {
         command = "proselint",
         args = { "--json" },
-        format = "json",
+        format = "raw",
         to_stdin = true,
         check_exit_code = function(c)
             return c <= 1
         end,
         on_output = function(params)
+            local output = params.output
+            if vim.startswith(output, "Error") then
+                local split = vim.split(output, "\n")
+                output = split[#split - 1]
+            end
+            local decoded = vim.json.decode(output)
+
             local diags = {}
             local sev = {
                 error = 1,
                 warning = 2,
                 suggestion = 4,
             }
-            for _, d in ipairs(params.output.data.errors) do
+            for _, d in ipairs(decoded.data.errors) do
                 table.insert(diags, {
                     row = d.line,
                     col = d.column,

However, I'm tempted to call this an upstream issue, since using the --json flag should not send anything but valid JSON to stdout (stderr would be the more appropriate option from what I've seen other linters do). Otherwise this is going to cause similar issues for integrations.

@milanglacier
Copy link
Author

Is there a reliable way to replicate this? I saw the same error the first time I set up proselint according to your instructions but haven't seen it again, even after deleting / messing with the cache folder.

The issue is quite clear: when there's a cache error, proselint outputs a bunch of non-JSON error lines, which causes the JSON parser to choke. We can theoretically work around this here by doing something like this (untested since I haven't been able to reliably replicate the error):

diff --git a/lua/null-ls/builtins/diagnostics/proselint.lua b/lua/null-ls/builtins/diagnostics/proselint.lua
index 1a53fcf..f09eba6 100644
--- a/lua/null-ls/builtins/diagnostics/proselint.lua
+++ b/lua/null-ls/builtins/diagnostics/proselint.lua
@@ -14,19 +14,26 @@ return h.make_builtin({
     generator_opts = {
         command = "proselint",
         args = { "--json" },
-        format = "json",
+        format = "raw",
         to_stdin = true,
         check_exit_code = function(c)
             return c <= 1
         end,
         on_output = function(params)
+            local output = params.output
+            if vim.startswith(output, "Error") then
+                local split = vim.split(output, "\n")
+                output = split[#split - 1]
+            end
+            local decoded = vim.json.decode(output)
+
             local diags = {}
             local sev = {
                 error = 1,
                 warning = 2,
                 suggestion = 4,
             }
-            for _, d in ipairs(params.output.data.errors) do
+            for _, d in ipairs(decoded.data.errors) do
                 table.insert(diags, {
                     row = d.line,
                     col = d.column,

However, I'm tempted to call this an upstream issue, since using the --json flag should not send anything but valid JSON to stdout (stderr would be the more appropriate option from what I've seen other linters do). Otherwise this is going to cause similar issues for integrations.

Despite those warnings, proselint works, it will still give me diagnostics. The only thing is it yields warnings frequently. I think the warnings are generated very often: just continuously typing new characters and save the file occasionally, it will yield warnings more than less. I find that Especially when trying to create a new list in markdown, it will have higher probability to yield such warning.

@jose-elias-alvarez
Copy link
Owner

Despite those warnings, proselint works, it will still give me diagnostics. The only thing is it yields warnings frequently. I think the warnings are generated very often: just continuously typing new characters and save the file occasionally, it will yield warnings more than less. I find that Especially when trying to create a new list in markdown, it will have higher probability to yield such warning.

Could you open an issue on the proselint repository about this? It would be good to know under what circumstances these warnings are generated and also clarify if there's any interest in fixing this. Fundamentally, it seems wrong to output non-JSON lines when using the --json flag (especially since based on your description these are just warnings and not fatal errors). I'd rather see if there's a possibility of fixing the underlying behavior before resorting to hacks here.

@milanglacier
Copy link
Author

milanglacier commented Jul 25, 2022

Hi! I would be happy to pose such issue to upstream, but I don't know how to replicate in the CLI version:

proselint --json new.md

yields valid outputs:

{"data": {"errors": []}, "status": "success"}

or

{"data": {"errors": [{"check": "annotations.misc", "column": 2, "end": 6, "extent": 4, "line": 1, "message": "Annotation left in text.", "replacements": null, "severity": "warning", "start": 2}]}, "status": "success"}

@jose-elias-alvarez
Copy link
Owner

It should theoretically be the same. All null-ls is doing is the equivalent of this command:

cat new.md | proselint --json

But since I'm not sure under what conditions this error is triggered, it's hard to provide a proper reproduction.

I think the fundamental cause is this line, which uses print and therefore outputs to stdout regardless of whether the --json flag is present. If this used stderr instead (which, again, is how I've seen other linters do it) the issue would be solved.

I think it's worth opening an issue with what we know. While we don't have a 100% reliable method to replicate it, the code path and nature of the issue is pretty clear. Otherwise there's not much I can do here right now, since fixing it would also require me to be able to reliably replicate the issue.

@milanglacier
Copy link
Author

Ok, I propose such issue to the upstream ampersor/proselint#1307.

Have no idea why such resource would be unavailable.

Error ([Errno 35] Resource temporarily unavailable: '/Users/northyear/.cache/proselint/checks.misc.capitalization.check') opening /Users/northyear/.cache/proselint/checks.misc.capitalization.check - will attempt to delete and re-open.

@milanglacier
Copy link
Author

milanglacier commented Jul 26, 2022

I find that if proselint is installed by the python installed by homebrew, then it will continuously give me such warning, i.e it can not open the file in ~/.cache/proselint folder.
However, if I install proselint via a venv in my home and not use the python installed by homebrew (in fact the python from miniforge) and then it works fine and no warning.

@aedwardg
Copy link

I'm seeing the exact same error with haml-lint.
Running haml-lint filename --reporter json works fine, but the default null-ls settings give this error when opening up a haml file:

[null-ls] failed to run generator: ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:64: failed to decode json: Expected value but found invalid token at character 1

@jose-elias-alvarez
Copy link
Owner

@aedwardg Could you open a separate issue so I can reproduce and investigate?

@aedwardg
Copy link

@jose-elias-alvarez, see #1144

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants