Skip to content

Use the cd option in Mix.Shell #12410

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

Merged
merged 1 commit into from
Feb 16, 2023
Merged

Conversation

scohen
Copy link
Contributor

@scohen scohen commented Feb 16, 2023

While writing an experimental language server, I was firing up a separate VM to host the project. From this VM, i would get consistent crashes when trying to invoke Mix.Task.run("deps.compile") when it tried to compile telemetry, which is a rebar3 project. The reason was that the language server vm sets the current directory away from the project after the project is bootstrapped, and again during the compilation process. The global nature of File.cd! meant the command was being run from the incorrect directory, which led compilation to fail.

This is a far edge case, but it seems to me that using the cd: option to Mix.Shell should be much safer than relying on the race-prone File.cd!.

This change drops the use of File.cd! when invoking Mix.shell in favor of passing the cd option to the shell invocation.
File.cd! is known to have race conditions, unlike the cd option in Mix.shell.

This change drops the use of File.cd! when invoking Mix.shell in favor
of passing the cd option to the shell invocation.
File.cd! is known to have race conditions, unlike the cd option in Mix.shell.
@scohen scohen changed the title Use the cd option in the mix shell Use the cd option in Mix.Shell Feb 16, 2023
@josevalim josevalim merged commit fca7d2a into elixir-lang:main Feb 16, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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

Successfully merging this pull request may close these issues.

2 participants