Giter VIP home page Giter VIP logo

Comments (13)

astoff avatar astoff commented on July 17, 2024

How does it fail? Note that the interactive command only sets the buffer env of the current buffer, not the entire project.

from buffer-env.

jgarte avatar jgarte commented on July 17, 2024

Hi,

It fails silently. That is, no pip installed packages are available in my current buffer from the virtualenv that I set up.

The package I usually test this out with is jedi-language-server.

I call eglot and eglot does not find the said language server.

When I try with pyvenv, it works fine.

I'm aware of the issue with having to use inheritenv in conjunction with buffer-env in order for environments to propagate across buffers (comint, etc).

from buffer-env.

jgarte avatar jgarte commented on July 17, 2024

In the meantime I stopped using buffer-env, but let me know if you'd like me to reproduce anything in particular.

If you share a config or steps for me to try, that might be the best approach to testing this and seeing where the problem may be.

Do virtualenv's work for you currently? What is your workflow? How do you have buffer-env set up to use Python virtualenv's?

from buffer-env.

astoff avatar astoff commented on July 17, 2024

Okay, Eglot is a bit complicated since it starts a process asynchronously, but nonetheless it works fine for me (no need for any inheritenv advices). A simple test you can do is, after updating the environment, is M-! env RET. If you see the right PATH, then buffer-env is working.

All I have in my config is this:

(add-hook 'hack-local-variables-hook 'buffer-env-update)
(setq buffer-env-script-name '(".envrc" ".venv/bin/activate"))
;; Plus the inheritenv advice around `python-shell-make-comint'.

from buffer-env.

quotuva avatar quotuva commented on July 17, 2024

I have seemingly the same problem, which can be fixed by changing the (sit-for 0) line to (sit-for 1).

from buffer-env.

jgarte avatar jgarte commented on July 17, 2024

@quotuva

That sounds like a plausible cause.

I'll do some more testing this week with your change to see if it also fixes it for me.

from buffer-env.

jgarte avatar jgarte commented on July 17, 2024

Okay, Eglot is a bit complicated since it starts a process asynchronously, but nonetheless it works fine for me (no need for any inheritenv advices). A simple test you can do is, after updating the environment, is M-! env RET. If you see the right PATH, then buffer-env is working.

All I have in my config is this:

(add-hook 'hack-local-variables-hook 'buffer-env-update)
(setq buffer-env-script-name '(".envrc" ".venv/bin/activate"))
;; Plus the inheritenv advice around `python-shell-make-comint'.

@astoff This didn't work for me.

from buffer-env.

astoff avatar astoff commented on July 17, 2024

@quotuva Can you reproduce this with emacs -q and using a minimal .envrc file? Also, which OS are you on?

(One more thing you could try: keep (sit-for 1) in buffer-env.el but add sleep 5 in your .envrc file.)

from buffer-env.

quotuva avatar quotuva commented on July 17, 2024

Can you reproduce this with emacs -q

I can't. :D

The only explanation I can think of is that using all the packages slows down the system to cause this.

add sleep 5 in your .envrc file

I don't use direnv. I simply add .venv/bin/activate to buffer-env-script-name.

EDIT:

Also, which OS are you on?

Ubuntu 22

EDIT2:

Just FYI: When this happens, the vars local variable is nil because the temporary buffer is empty. But the process-live-p part does not happen.

from buffer-env.

astoff avatar astoff commented on July 17, 2024

the vars local variable is nil because the temporary buffer is empty

Okay, I should add an error message in this case. But I still don't get why your temp buffer ends up empty.

I don't use direnv. I simply add .venv/bin/activate to buffer-env-script-name.

It's still a shell script, you could add a long sleep to check if buffer-env is actually waiting for the process to end (I'm staring at the code and can't see how this could go wrong)

from buffer-env.

quotuva avatar quotuva commented on July 17, 2024

But I still don't get why your temp buffer ends up empty.

I'm just guessing: The process exit status is 0, but Emacs hasn't updated the buffer yet. I don't know if that's impossible.

It's still a shell script, you could add a long sleep

Yes, I did that and it works fine then.

from buffer-env.

astoff avatar astoff commented on July 17, 2024

I guess you're right, see "this loop contains a bug" here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Accepting-Output.html

What if you replace this:

buffer-env/buffer-env.el

Lines 215 to 216 in e015220

(sit-for 0)
(when (process-live-p proc)

by this:

                           (sit-for 0)
                           (if (not (process-live-p proc)) (accept-process-output proc 1)

from buffer-env.

quotuva avatar quotuva commented on July 17, 2024

What if you replace this:
...
by this:

Works! Thank you! I hope @jgarte can also confirm (if this is indeed his problem).

from buffer-env.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.