Ale: Using ALE with docker, Linting "remotely" -- Is it possible?

Created on 7 Dec 2017  路  5Comments  路  Source: dense-analysis/ale

Did not find any mention to configuring ALE to work with a docker container. Has anyone done that?
I have a ruby project and tried changing the rubocop binary to something like docker exec <machine> <linter> (the command works fine when executed manually), and this is what I got:

Current Filetype: ruby                                                                                                                                                                                            
Available Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby']                                                                                                                                 
  Enabled Linters: ['rubocop']                                                                                                                                                                                     
 Linter Variables:                                                                                                                                                                                                 
let g:ale_ruby_rubocop_executable = 'rd-docker e web rubocop'                                                                                                                                                      
let g:ale_ruby_rubocop_options = ''                                                                                                                                                                                
 Global Variables:                                                                                                                                                                                                 
let g:ale_echo_cursor = 1                                                                                                                                                                                          
let g:ale_echo_msg_error_str = 'Error'                                                                                                                                                                             
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'                                                                                                                                                           
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_keep_list_window_open = 0                                                                                                                                                                                
let g:ale_lint_delay = 200                                                                                                                                                                                         
let g:ale_lint_on_enter = 1                                                                                                                                                                                        
let g:ale_lint_on_save = 1                                                                                                                                                                                         
let g:ale_lint_on_text_changed = 'always'                                                                                                                                                                          
let g:ale_linter_aliases = {}                                                                                                                                                                                      
let g:ale_linters = {'jsx': ['eslint'], 'ruby': ['rubocop'], 'javascript': ['eslint']}                                                                                                                             
let g:ale_open_list = 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_offset = 1000000                                                                                                                                                                                    
let g:ale_sign_warning = '--'                                                                                                                                                                                      
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']                                                                                                                                               
let g:ale_warn_about_trailing_whitespace = 1                                                                                                                                                                       
  Command History:                                                                                                                                                                                                 
(executable check - failure) rd-docker e web rubocop                                                                                                                                                               
(executable check - failure) rd-docker e web rubocop 

Most helpful comment

I wrote up a blog post regarding how ALE + Docker can work together pretty well, if anyone comes across this issue and is curious (linking it here because this is one of the issues that comes up when searching for ALE/Docker):

https://rymc.io/blog/2019/vim-ale-docker-per-project-linting/

If there's a better solution I'm all ears~

All 5 comments

There's one guy who uses Docker in a fork, but I wouldn't know. It depends what is or isn't in docker. If your executables are in docker, but your source code can be anywhere, maybe it will work. If you have just about everything in Docker, maybe you should run Vim itself from Docker too.

I think this is effectively a duplicate of #1115.

I wrote up a blog post regarding how ALE + Docker can work together pretty well, if anyone comes across this issue and is curious (linking it here because this is one of the issues that comes up when searching for ALE/Docker):

https://rymc.io/blog/2019/vim-ale-docker-per-project-linting/

If there's a better solution I'm all ears~

Better Docker support must include settings for converting paths back and forth between paths in Docker and paths in your host system, because Docker images have their own separate filesystem.

Hmm, your comment made me go dig deeper into why my solution works okay. It makes sense, in practice - the file is fed into the command that Docker ultimately receives, so something like flake8 works fine given it's operating on a line-fed file. Path conversion does matter for project-wide tooling, though.

When I have time I'll see if I can come up with a more usable solution. Thanks for the heads up!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amerov picture amerov  路  4Comments

aressler38 picture aressler38  路  3Comments

ianchanning picture ianchanning  路  3Comments

alexlafroscia picture alexlafroscia  路  4Comments

ilyakopy picture ilyakopy  路  4Comments