Use the cd option in Mix.Shell #12410
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 compiletelemetry
, 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 ofFile.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 toMix.Shell
should be much safer than relying on the race-proneFile.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.