elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

Error - Cannot format file from current directory (Currently in deps/telemetry/deps/mimerl)")

Open anildigital opened this issue 5 years ago • 7 comments
trafficstars

If I change and save too fast. I see this error

Environment

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.7.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] Elixir 1.10.3 (compiled with Erlang/OTP 21)

  • Operating system: macOS Catalina 10.5.4

  • Editor or IDE name (e.g. Emacs/VSCode): Emacs 27.0.91

  • LSP Client name: elixir-lsp elixir-ls

Logs

Saving file /Users/anil/Code/elixir/web_projects/myapp/lib/myapp_web/controllers/page_controller.ex...
Error: (error "Cannot format file from current directory (Currently in deps/telemetry/deps/mimerl)")
Error: (error "Cannot format file from current directory (Currently in deps/telemetry)")
Skipping build because cwd changed from /Users/anil/Code/elixir/web_projects/myapp to /Users/anil/Code/elixir/web_projects/myapp/deps/telemetry

anildigital avatar May 18 '20 20:05 anildigital

My thinking on how to handle this is to try to get the build lock, but if that takes more than 1 second or so, then just save the file without formatting.

axelson avatar May 26 '20 01:05 axelson

It's also happening to me, but instead of changing the cwd to deps it's changing to a random app inside the umbrella.

brenomaia avatar Jun 17 '20 21:06 brenomaia

I found it sometimes after build is done. This is trace output from vim-lsp:

Thu Jul 16 22:55:21 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "==> lfc_server", "type": 4}}}]
Thu Jul 16 22:55:21 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "Compiling 25 files (.erl)", "type":
4}}}]
Thu Jul 16 22:55:26 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "Generated lfc_server app", "type": 4
}}}]
Thu Jul 16 22:55:34 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "Compile took 327155 milliseconds", "
type": 3}}}]
Thu Jul 16 22:55:34 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "[ElixirLS WorkspaceSymbols] Indexing
...", "type": 3}}}]
Thu Jul 16 22:55:34 2020:["<---", 3, "elixir-ls", {"response": {"method": "window/logMessage", "jsonrpc": "2.0", "params": {"message": "Skipping build because cwd changed f
rom /Users/thanabodee/src/git.myhost.com/myorg/theproject/myproject to /Users/thanabodee/src/git.myhost.com/myorg/theproject/lfc_server/dep
s/cowboy", "type": 4}}}]

It's seems like the build is broken some how and does not change directory back to project dir.

wingyplus avatar Jul 16 '20 16:07 wingyplus

Anyone know how is this handled in VS Code? I have not seen such error there.

anildigital avatar Aug 21 '20 02:08 anildigital

I found that the formatter will return this error when ElixirLS are still compiling the source. If your source contains small dependencies. I guess that we cannot get formatter opt during mix still compiling.

wingyplus avatar Aug 24 '20 04:08 wingyplus

Not sure if it is related, but I can see this message in my ElixirLS - server log of VSCode too.

Request textDocument/formatting failed.
  Message: Cannot format file from current directory (Currently in .)

Steps to reproduce:

  1. open new tab
  2. change language mode to Elixir
  3. write unformatted Elixir code, for example: defmodule Bla do def x, do: nil end (do not save!)
  4. run command "Format document"

I am not sure if formatting should work for unsaved file too, but I would assume yes. Correct me if I am wrong, please.

stefanluptak avatar May 11 '22 11:05 stefanluptak

@stefanluptak this looks like a separate issue

lukaszsamson avatar May 11 '22 16:05 lukaszsamson

Addressed in https://github.com/elixir-lsp/elixir-ls/pull/890 Requires elixir 1.15

lukaszsamson avatar Jun 03 '23 14:06 lukaszsamson