I have the following error when saving an elixir file with visual studio code
No mixfile found in project. To use a subdirectory, set
elixirLS.projectDir
in your settings
I have thus updated the User/settings.json (In windows) file such as
{
"elixirLS.projectDir": "C:\\CodeTraining\\Elixir-intro"
}
But I still get the error
Any idea ?
By the way, I have the same error when using Ubuntu.
ElixirLS requires mix
project, it does not work properly with plain files. So start with creating the project
mix new intro
cd intro
code .
Now in intro
folder ElixirLS would be happy. You still can create random elixir files and/or scripts there to play with.
Since I landed here searching for an answer to this but for Vim, I'm gonna share what will fix the error on Vim
The error is caused by the language client incorrectly setting the project root based on the first file that you opened. For example, if you open mix.exs
first, this is printed to the Vim output:
LanguageClient project root: /Users/joe/Downloads/test
However, if you open something else (like lib/test.ex
) you get the following:
LanguageClient project root: /Users/joe/Downloads/test/lib
So, in order to fix this, add the following to your .vimrc
:
let g:LanguageClient_rootMarkers = {
\ 'elixir': ['mix.exs'],
\ }
Or if you use coc.nvim
, add this to your .vimrc
instead
autocmd FileType elixir let b:coc_root_patterns = ['mix.exs']
This will correctly set the project root based on the location of mix.exs
for the purposes of ElixirLS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With