1

Information

VIM version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 29 2020 00:47:39)
macOS version
Included patches: 1-503, 505-680, 682-2292

Operating System: Catalina 10.15.4

What went wrong

I'm sure this will just be a configuration thing but I've been banging my head against the desk for hours trying to figure this out.

EDIT: Below I first noticed this happening on ALEFix - however I've realised even when I do :grep, asofsdfas is logged to the console... I'm going to keep digging.

If anyone knows a way to see what is being executed by vim that would be useful (ie show commands being run? - q: doesn't reveal anything)


When I run ALEFix on a python file it automatically inserts junk at the top:

asofsdfas
import logging

For me its always the same junk asofsdfas but if I keep saving it keeps inserting it.

Here is my ftplugin/python.vim

" Check Python files with flake8 and pylint.
let b:ale_linters = ['flake8', 'mypy']
" Fix Python files with autopep8 and yapf.
let b:ale_fixers = ['autopep8', 'yapf']

" python syntax
let g:python_highlight_all = 1

If I change to let b:ale_fixers = [] it doesn't occur

If I pip uninstall autopep8 and yapf it doesn't occur

It still occurs if I have either only let b:ale_fixers = ['autopep8'] or let b:ale_fixers = ['yapf']

Please someone help I'm losing my mind

EDIT: Turns out it's also happening on my javascript fixers so isn't specific to this python stuff (but the same behaviour is occurring re: if I change the ale_fixers value)

  • 1
    Sounds like a temporary workaround is not to use ALEFix... odd bug though. (Aside) I’ve been happy with Black since I started using it to format python files on save (via ale). So happy, in fact, that I miss it in other languages. – D. Ben Knoble May 4 at 13:17
  • 1
    Hi Phil, I would suggest making your vimrc file as small as possible and trying to reproduce this bug again. I've used ALE for a while and never had any trouble. Also, check which autopep8 and yapfare used in ALE, try to run them manually. If you end up with no issue then it's probably something in your configuration and not in the plugin. – nobe4 May 4 at 13:45
  • 1
    Thanks for your comments - have updated the question but essentially this is definitely not an ALE issue and something with my vimrc - am going to try to recreate a minimal example as @nobe4 suggested :+1 – Phil Barber May 4 at 14:16
1

My problem here was that I had

set shellcmdflag=-ic

in my vimrc

Removing this solved the issue.

I'm still not entirely sure why

EDIT: Oh my lord I've found it and it's colossally stupid. Thanks to @filbrandon:

When you pass the shell a -i, it will read and execute your initialization file (such as .bashrc for bash.) If you're producing any output from that initialization file, that might explain it. If you run bash -ic 'echo hello' do you actually see anything other than "hello"?

Turns out I had echo asofsdfas in my .bashrc.... I'm using a mac so I only was ever checking my .bash_profile.

Thanks for taking this journey with me and apologies and thank you.

| improve this answer | |
  • 5
    I'm glad you found the issue! But can you please expand on this a bit to make it a better answer? What was this line doing? Why did you have it there in the first place? Did you change it to something else or did you just remove it? Thanks! – filbranden May 4 at 14:38
  • 1
    Very good point - have updated that removing this line solved the issue. I wish I could elaborate more – Phil Barber May 5 at 15:28
  • 1
    When you pass the shell a -i, it will read and execute your initialization file (such as .bashrc for bash.) If you're producing any output from that initialization file, that might explain it. If you run bash -ic 'echo hello' do you actually see anything other than "hello"? Note that producing output from these initialization files is a problem for other commands as well, you should try to avoid that if possible. In any case, yeah the fix is good. (Do you happen to recall why you added this line in the first place?) – filbranden May 5 at 16:23
  • 1
    You are correct! bash -ic 'echo hello' also logs the asofsdfas` junk I was getting before! More digging from me to come – Phil Barber May 6 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.