J3RN / inf-elixir

An Emacs plugin for interacting with an Elixir REPL
GNU General Public License v3.0
45 stars 10 forks source link

Set the default-directory of comint buffers #10

Closed akirak closed 3 years ago

akirak commented 3 years ago

I use Nix, nix-direnv, and direnv-mode to configure project-specific dependencies. I am currently working on my project that depends on a library that contains Rust NIF, so I have configured Nix and direnv to ensure cargo is available in my project.

When I tried to open a REPL session for the project using inf-elixir-project, it failed due to cargo missing. On the other hand, mix compile successfully runs on terminal.

Apparently, iex does not load the local environment from direnv when inf-elixir starts the session. I think this can be done by setting default-directory of the comint buffer, which is implemented in this PR. It seems to be working in my environment, and inf-elixir now handles the cargo dependency!

Hope this is useful.

J3RN commented 3 years ago

What strikes me as odd about this issue is that I thought default-directory would be set, as it's set in a let binding inside inf-elixir-project. I can easily imagine inf-elixir having an odd default-directory since we never explicitly set one, but inf-elixir-project should have the root of the project as it's default-directory already.

If you could do me a favor, what I want to know is the value of default-directory without your changes:

  1. right above or below the line you changed
  2. inside a REPL buffer started with inf-elixir-project
akirak commented 3 years ago

As you point out in the above comment, default-directory seems to be correctly set to the project root, and it is working without the change now. I don't know why, but maybe it was due to a temporary situation in my environment. I'll close this issue for now. Thank you for your comment.