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

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

Closed
anildigital opened this issue May 18, 2020 · 8 comments
Labels
bug Something isn't working work in progress

Comments

@anildigital
Copy link

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
@axelson
Copy link
Member

axelson commented May 26, 2020

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.

@brenomaia
Copy link

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

@wingyplus
Copy link
Contributor

wingyplus commented Jul 16, 2020

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.

@anildigital
Copy link
Author

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

@wingyplus
Copy link
Contributor

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.

@stefanluptak
Copy link

stefanluptak commented May 11, 2022

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.

@lukaszsamson
Copy link
Collaborator

@stefanluptak this looks like a separate issue

@lukaszsamson
Copy link
Collaborator

Addressed in #890
Requires elixir 1.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress
Projects
None yet
Development

No branches or pull requests

6 participants