Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running emacs/ELP with multiple kerl versions causes code to be compiled with the wrong version of OTP #68

Open
baronbosse opened this issue Dec 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@baronbosse
Copy link

Describe the bug

I need to edit 2 different project, and project A needs otp 25, and project B needs otp 27. In order for project B to compile correctly emacs is started in a terminal with kerl switched to otp-27.

But as soon as a file in project A is opened ELP seems to compile them again and overwrite the beam files with OTP-27 compiled versions of the same beam file. And it is very confusing to why all of a sudden tests start failing and so forth.

To Reproduce**

  1. Create a project that depends on for instance jsonformat
  2. Compile and run some tests for this project with otp-25.
  3. In a separate terminal, activate otp 27 with . ~/.kerl/27.1.2/activate
  4. In this other terminal open emacs with ELP as an IDE, now running otp 27.
  5. Open one of the test suites in emacs.

Expected behavior

Running rebar3 ct should work as before opening emacs.

Actual behavior

Errors like these start popping up.

$ rebar3 ct 
===> Verifying dependencies...
=ERROR REPORT==== 9-Dec-2024::13:34:42.439545 ===
Loading of /home/user/project_/_build/default/lib/jsonformat/ebin/jsonformat.beam failed: {features_not_allowed,
                                                                                                      [maybe_expr]}

Context

  • ELP Version (output of elp version): elp 1.1.0+build-2024-11-07
  • Editor used: GNU Emacs 29.3
@baronbosse baronbosse added the bug Something isn't working label Dec 9, 2024
@alanz
Copy link
Member

alanz commented Dec 9, 2024

Have you tried using direnv to configure the otp in the project? emacs will honour that.

@baronbosse
Copy link
Author

I have not. As stated above I'm using kerl for setting otp version per terminal. I would have to switch to asdf if I want to try direnv.

But what was the scary part was the surprise of projects seemingly randomly stopping to work. You run rebar3 ct and all is fine. You edit a file and add some logging and all of a sudden tests fail and rebar3 core dumps. It was very very hard to debug.

@alanz
Copy link
Member

alanz commented Dec 10, 2024

Maybe try something like this https://blog.differentpla.net/blog/2019/01/30/integrating-kerl-direnv/

I am suggesting this because emacs can be direnv-aware, so should pick up the path, regardless of when/where you start emacs. I use

(use-package direnv
 :config
 (direnv-mode))

in my init.el, and it works that way for me, for various .envrc files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants