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

Mix Format: File triggers a full recompile #69

Open
ocolot opened this issue Mar 18, 2024 · 9 comments
Open

Mix Format: File triggers a full recompile #69

ocolot opened this issue Mar 18, 2024 · 9 comments

Comments

@ocolot
Copy link

ocolot commented Mar 18, 2024

Using Sublime Text 4169 on macOS 14.4 and asdf (elixir 1.16.1-otp-26, erlang 26.2.2), formatting a file triggers a full app recompile (and crash the web server started with mix phx.server in parallel). I guess the compilation in Sublime and in iTerm2 do not share the same compilation environment.

How to make sure Elixir Syntax uses the same compilation process as my default terminal?

Thanks

@princemaple
Copy link
Collaborator

Can you paste some logs? In what way does it crash the running process?

@ocolot
Copy link
Author

ocolot commented Mar 18, 2024 via email

@princemaple
Copy link
Collaborator

If you did just format one of the config files, it's required to restart the app by phoenix. If you formatted some other files and saw this, then it's a bug.

@ocolot
Copy link
Author

ocolot commented Mar 18, 2024 via email

@princemaple
Copy link
Collaborator

Does it always happen or only the first time?

@ocolot
Copy link
Author

ocolot commented Mar 19, 2024 via email

@azizk
Copy link
Collaborator

azizk commented Mar 19, 2024

Yeah, I think the issue is that Sublime and iTerm2 don't share the same environment. The Phoenix server is (most likely) compiled and started by the asdf-installed version of Elixir. I don't know about macOS, but you should be able to start Sublime from that iTerm2 shell to give it the same environment. I hope that's an acceptable workaround for now.

I don't know what the proper solution would be yet. Maybe it is to make the mix_format palette command aware of the .tool-versions file or of asdf and run mix accordingly. Or maybe it's adding settings to the command so the user can configure mix_format for each project individually.

There's something related that I noticed: I'm not using asdf, but when I run the tests from the CLI and then from Sublime it still compiles everything again, even though the Elixir version is the same. Quite annoying! I wish I had fun investigating this, but at the moment I'm busy with other things that are more fun. 😅

@princemaple
Copy link
Collaborator

Another option is use LSP and LSP-elixir, so that you use the language server to format the code, instead of using the current app environment, which triggers recompilation.

@ocolot
Copy link
Author

ocolot commented Mar 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants