https://pantsbuild.org/ logo
#general
Title
# general
a

astonishing-london-2419

09/16/2021, 8:19 PM
Hi! Editor question: has somebody managed to get a good vim config to work with pants? I run all the ide functions (pylint, etc) on vim so I need to start the editor in an environment that knows about third party deps, the libraries, etc. If I create a virtualenv, then I can’t really run any pants command from there, so I was wondering if I was missing something
h

hundreds-father-404

09/16/2021, 8:40 PM
Hi! It doesn't address vim in particular, but have you seen https://www.pantsbuild.org/docs/setting-up-an-ide?
a

astonishing-london-2419

09/16/2021, 8:44 PM
yup, I tried to do that, but vim is a bit dumber than VSCode… If I create a virtualenv and run from it, pants complains, so I need to have a terminal without virtualenv for pants and another one for vim with the virtualenc
which is a bit annoying
but if by accident I run a pants command inside the virtualenv, it all stops working
h

hundreds-father-404

09/16/2021, 9:20 PM
Hm, what do you mean it stops working?
a

astonishing-london-2419

09/16/2021, 9:26 PM
Copy code
$ ./pants dependencies --type=3rdparty ::
22:51:37.74 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
    return self._perform_run(goals)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body
    return self.graph_session.run_goal_rules(
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules
    exit_code = self.scheduler_session.run_goal_rule(
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 533, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 501, in _raise_on_error
    raise ExecutionError(

Exception message: 1 Exception encountered:

  Exception: While expanding link "venv/bin/python": Failed to read link "/Users/albert/Arxiu/Work/Projects/Ongoing/python-apps-pants/venv/bin/python3": Absolute symlink: "/Users/albert/Arxiu/Work/Projects/Ongoing/python-apps-pants/venv/bin/python3"
things like that
h

hundreds-father-404

09/16/2021, 9:26 PM
Oh, you should be able to set
pants_ignore
so that Pants doesn't look inside those
Copy code
[GLOBAL]
pants_ignore.add = ["venv/"]
a

astonishing-london-2419

09/16/2021, 9:27 PM
ooh, thanks!
❤️ 1
b

busy-vase-39202

09/16/2021, 9:43 PM
So does it work for you now? If you had to do any special config for vim, that'd be a great addition for the docs. There's a "suggest edits" button near the top right.
a

astonishing-london-2419

09/16/2021, 9:47 PM
I haven’t found anything that works super well yet
vim runs the linters basically on the command line, so I am figuring out the equivalent to VScode “Sources”
but editing the pythonpath is not terrible I guess 🤷
b

busy-vase-39202

09/16/2021, 10:02 PM
Is using Jupyter Notebook an option for some of your need? https://www.pantsbuild.org/docs/jupyter It's not a substitute for an IDE, obviously.
a

astonishing-london-2419

09/16/2021, 10:06 PM
unfortunately not, but I found something that works now and could be automated with some extra tooling
I’ll play around with it
🤞 1
and if I see it works in the coming weeks, I’ll try to make an edit with the info
b

busy-vase-39202

09/16/2021, 11:29 PM
Thank you!
c

clean-city-64472

09/17/2021, 2:43 PM
I use neovim. For pylint I have my config in tox.ini which I believe gets picked up by both pants and neomake plugin. I am fairly happy with my setup and haven't had any need to let neovim actually run pants. That being said I don't have any smart completion plugins installed so I haven't had to wrestle wit that.
a

astonishing-london-2419

09/17/2021, 2:49 PM
mmm, and how do you handle dependencies?
c

clean-city-64472

09/17/2021, 2:54 PM
Based on how I have my vim configured I don't need to
I'm guessing you need that for better code completion?
a

astonishing-london-2419

09/17/2021, 2:58 PM
yeah, basically I check also whether things can be imported, etc, and this needs the deps. I thought pylint would need this too?
c

clean-city-64472

09/17/2021, 3:10 PM
i'm using flake8 so maybe it's different
sorry should have clarified that
i run pants on a vm so I keep a separate pane open in my terminal that has a session on the vm - I have some aliases there to quickly run pants commands as well as a pre-commit hook that runs
./pants lint --changed-since=HEAD || exit 1
a

astonishing-london-2419

09/17/2021, 3:14 PM
ah, that’s why
ok
7 Views