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

Cargo linter runs correctly, but I see no errors #2525

Closed
kozross opened this issue May 22, 2019 · 12 comments
Closed

Cargo linter runs correctly, but I see no errors #2525

kozross opened this issue May 22, 2019 · 12 comments
Labels

Comments

@kozross
Copy link

kozross commented May 22, 2019

Information

VIM version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 29 2019 04:53:42)
Included patches: 1-1234

Operating System: Windows 10 version 1703

What went wrong

This appears to be similar to #2488, but I am unsure.

Whenever I lint a project made with cargo new, ALEInfo shows that the cargo check ran, and gave the expected output, but I see nothing in the location list, and in fact, no indication of any errors at all.

Reproducing the bug

  1. cargo new experiment
  2. cd experiment
  3. vim src/main.rs
  4. Make some obvious error, then save.
  5. Observe that you're seeing no indication of anything being amiss.
  6. :ALEInfo and scroll to the bottom.
  7. Observe the results you wished you could have seen.

:ALEInfo

 Current Filetype: rust
Available Linters: ['cargo', 'rls', 'rustc']
  Enabled Linters: ['cargo']
 Suggested Fixers: 
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'rustfmt' - Fix Rust files with Rustfmt.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_rust_cargo_avoid_whole_workspace = 1
let g:ale_rust_cargo_check_all_targets = 0
let g:ale_rust_cargo_check_examples = 0
let g:ale_rust_cargo_check_tests = 0
let g:ale_rust_cargo_clippy_options = ''
let g:ale_rust_cargo_default_feature_behavior = 'default'
let g:ale_rust_cargo_include_features = ''
let g:ale_rust_cargo_use_check = 1
let g:ale_rust_cargo_use_clippy = 0
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 'never'
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {'rust': ['cargo']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) cargo
(finished - exit code 0) ['/usr/bin/bash', '-c', '''cargo'' --version']

<<<OUTPUT STARTS>>>
cargo 1.34.0 (6789d8a0a 2019-04-01)
<<<OUTPUT ENDS>>>

(finished - exit code 101) ['/usr/bin/bash', '-c', 'cd ''/home/em162098/experiment'' && cargo check --frozen --message-format=json -q']

<<<OUTPUT STARTS>>>
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"cannot find macro `pintln!` in this scope","code":null,"level":"error","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":22,"line_start":2,"line_end":2,"column_start":5,"column_end":11,"is_primary":true,"text":[{"text":"    pintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":11}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"you could try the macro","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":22,"line_start":2,"line_end":2,"column_start":5,"column_end":11,"is_primary":true,"text":[{"text":"    pintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":11}],"label":null,"suggested_replacement":"println","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: cannot find macro `pintln!` in this scope\n --> src\\main.rs:2:5\n  |\n2 |     pintln!(\"Hello, world!\");\n  |     ^^^^^^ help: you could try the macro: `println`\n\n"}}
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}}

To learn more, run the command again with --verbose.
<<<OUTPUT ENDS>>>
@doums
Copy link

doums commented May 24, 2019

$ rustup component add rls

source

@w0rp
Copy link
Member

w0rp commented May 29, 2019

rls has nothing to do with Cargo.

The problem here is that Cargo is being run from Bash, returning Windows with backslashes, when the editor has forward slashes. What's the output of :echo has('win32') and :echo has('unix'). If both are somehow true, that might make this hard to fix. Which environment is Vim being run in?

@kozross
Copy link
Author

kozross commented Jun 5, 2019

:echo has('win32') gives 0, while :echo has('unix') gives 1. The environment is an MSYS2 shell, with vim installed from pacman.

@RyanSquared
Copy link
Member

I'm guessing you can't install cargo from pacman? The issue here being Cargo knows it's on Windows and produces output for that environment, but Vim thinks it's on a UNIX compatible, and detects input for that.

@kozross
Copy link
Author

kozross commented Jun 5, 2019

@RyanSquared I tried that too. I get a very similar result from following all these steps.


 Current Filetype: rust
Available Linters: ['cargo', 'rls', 'rustc']
  Enabled Linters: ['cargo']
 Suggested Fixers: 
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'rustfmt' - Fix Rust files with Rustfmt.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_rust_cargo_avoid_whole_workspace = 1
let g:ale_rust_cargo_check_all_targets = 0
let g:ale_rust_cargo_check_examples = 0
let g:ale_rust_cargo_check_tests = 0
let g:ale_rust_cargo_clippy_options = ''
let g:ale_rust_cargo_default_feature_behavior = 'default'
let g:ale_rust_cargo_include_features = ''
let g:ale_rust_cargo_use_check = 1
let g:ale_rust_cargo_use_clippy = 0
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) cargo
(finished - exit code 0) ['/usr/bin/bash', '-c', '''cargo'' --version']

<<<OUTPUT STARTS>>>
cargo 1.35.0
<<<OUTPUT ENDS>>>

(finished - exit code 101) ['/usr/bin/bash', '-c', 'cd ''/home/em162098/experiment'' && cargo check --frozen --message-format=json -q']

<<<OUTPUT STARTS>>>
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"cannot find macro `priiintln!` in this scope","code":null,"level":"error","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":25,"line_start":2,"line_end":2,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    priiintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"you could try the macro","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":25,"line_start":2,"line_end":2,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    priiintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":"println","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: cannot find macro `priiintln!` in this scope\n --> src\\main.rs:2:5\n  |\n2 |     priiintln!(\"Hello, world!\");\n  |     ^^^^^^^^^ help: you could try the macro: `println`\n\n"}}
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}}

To learn more, run the command again with --verbose.
<<<OUTPUT ENDS>>>

(finished - exit code 101) ['/usr/bin/bash', '-c', 'cd ''/home/em162098/experiment'' && cargo check --frozen --message-format=json -q']

<<<OUTPUT STARTS>>>
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"cannot find macro `priiintln!` in this scope","code":null,"level":"error","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":25,"line_start":2,"line_end":2,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    priiintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"you could try the macro","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":16,"byte_end":25,"line_start":2,"line_end":2,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":"    priiintln!(\"Hello, world!\");","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":"println","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: cannot find macro `priiintln!` in this scope\n --> src\\main.rs:2:5\n  |\n2 |     priiintln!(\"Hello, world!\");\n  |     ^^^^^^^^^ help: you could try the macro: `println`\n\n"}}
{"reason":"compiler-message","package_id":"experiment 0.1.0 (path+file:///C:/msys64/home/em162098/experiment)","target":{"kind":["bin"],"crate_types":["bin"],"name":"experiment","src_path":"C:\\msys64\\home\\em162098\\experiment\\src\\main.rs","edition":"2018"},"message":{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}}

To learn more, run the command again with --verbose.
<<<OUTPUT ENDS>>>

@RyanSquared
Copy link
Member

Right, so it's still giving out a filename with backslashes - src\main.rs and I'm not sure how to - or whether it would even be appropriate to - handle those kinds of things. I think you'd need Vim installed specifically for Windows (rather than a UNIX-like environment) for this to work properly.

@kozross
Copy link
Author

kozross commented Jun 5, 2019

@RyanSquared So you're basically saying that vim on MSYS2 shell is unusable with ALE? I'm not saying it's anyone's fault, but that seems kinda painful.

@RyanSquared
Copy link
Member

I'm saying that Vim thinks you're in UNIX. Cargo thinks you're in Windows. I'm not sure who would be appropriate to blame given both are partially correct. I'd look into why Cargo thinks you're in a Windows environment and see if that can be changed.

@w0rp
Copy link
Member

w0rp commented Jun 5, 2019

I think I'll just have to make ALE replace backslashes in filenames on Unix with forward slashes. I doubt anyone actually puts backslashes in their filenames for source files, so I don't expect it to be an issue.

@w0rp w0rp added the bug label Jun 5, 2019
@w0rp w0rp closed this as completed in 7b78f2b Jun 5, 2019
@w0rp
Copy link
Member

w0rp commented Jun 5, 2019

I've pushed a commit now to handle convert back slashes to forward slashes in a Unix environment, even though back slashes are actually valid characters in Unix. That should fix your issue. Let me know if you still have problems.

Later on, we might want to handle paths like C:\foo\bar as something like /drive/c/foo/bar, depending on the environment and where the drives are mounted.

@doums
Copy link

doums commented Jun 5, 2019

If I may, it's a bad decision. Even if very few users use backslash in the name of their files, this may happen for some reasons. With your last commit you will break all file paths in Linux containing backslash. All this on behalf of this particular issue (one user that is in Windows 10, under a "MSYS2 shell"..). It's not logic at all.

@w0rp
Copy link
Member

w0rp commented Jun 5, 2019

I'm okay with breaking support for all Linux paths containing a backslash. I sincerely doubt anyone seriously commits code with backslashes in their filenames.

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

No branches or pull requests

4 participants