Closed AndrewDryga closed 1 month ago
Which editor are you using, and how are you importing the project?
@scohen I'm using VSCode, just did code ./firezone
(that's the path to the repo I've linked above) and changed the Project Dir
to elixir/
.
Gotcha, I'll investigate.
Hi there! Same issue here:
Detected Elixir through asdf: /Users/ricardo/.asdf/installs/elixir/1.15.7-otp-26/bin/elixir
warning: redefining module MyProject.MixProject (current version defined in memory)
/Users/ricardo/projects/my_project/mix.exs:1: MyProject.MixProject (module)
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
lib/tailwind.ex:72:14
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
lib/tailwind.ex:86:16
== Compilation error in file lib/bcrypt/base.ex ==
** (UndefinedFunctionError) function Bcrypt.Base.__info__/1 is undefined (function not available)
Bcrypt.Base.__info__(:functions)
(lx_remote_control 0.5.0) lib/lexical/remote_control/compilation/tracer.ex:30: LXical.RemoteControl.Compilation.Tracer.extract_module_updated/3
(lx_remote_control 0.5.0) lib/lexical/remote_control/compilation/tracer.ex:10: LXical.RemoteControl.Compilation.Tracer.trace/2
(elixir 1.15.7) src/elixir_env.erl:30: :elixir_env."-trace/2-lc$^0/1-0-"/3
(elixir 1.15.7) src/elixir_env.erl:30: :elixir_env.trace/2
could not compile dependency :bcrypt_elixir, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile bcrypt_elixir --force", update it with "mix deps.update bcrypt_elixir" or clean it with "mix deps.clean bcrypt_elixir"
Apparently, it does not find Bcrypt
.
@bigardone unless you have a non-traditional project structure, or you're reading a file in mix.exs
, yours is likely a different issue
@bigardone I tried a simple project with {:bcrypt, "> 0.0.0"}
in my mix.exs, and it compiles correctly, can you share the elixir and erlang version as well as your editor?
Hi @scohen, thanks for the response 🙌🏼
The dependency I'm using is {:bcrypt_elixir, "~> 3.0"}
...
Here's a test project featuring the issue https://github.com/bigardone/lexical-issue
And here are the versions I'm using:
elixir 1.16.2-otp-26
erlang 26.1.2
Editor-wise, I'm using Neovim
Should I open a new issue?
@bigardone yes, please open a new issue.
@bigardone with the addition of a .tool-versions file, I was able to get your example project to compile
@AndrewDryga I'm not familiar with vscode and couldn't find anything about how to set the Project Dir. Would you mind popping into our discord or providing a minimal project with vscode config that shows the issue?
@scohen After reinstalling Erlang, it started working again 🙌🏼
@scohen I would love to help, which discord server should I join?
Here is how you change this setting:
Lexical: Project Dir
settings and change itWe only have to do this because we have multi-language mono repo and all Elixir stuff is not in the git root but in elixir/
.
@AndrewDryga this is our server
Thanks for the instructions, I'll investigate now.
@AndrewDryga This is actually a sympathetic bug between your app, the elixir compiler and lexical.
When lexical builds your project, it emits a series of messages, and these messages need to have a common prefix so that the editor displays them correctly. The prefix is "Building <your project>"
.
The <your project>
part is defined by calling Project.display_name(project)
which in turn queries the project config.
Now here's where it gets fun. The message is created in a compile tracer, and the elixir compiler changes directories when compiling dependencies. This is where you get the crash, as the relative path doesn't exist in your dependencies.
The fix is simple enough, make the path absolute, static, and based off your mix.exs's path
defmodule Firezone.MixProject do
@version "VERSION" |> File.read!() |> String.trim()
def project do
[name: :firezone,
apps_path: "apps",
version: @version
...
After making the above change, I was able to compile your app just fine.
@scohen hm, this is a tricky one: fixing it for our project is easy but I feel like it can backfire Lexical later once that File.read!/1
is in a dependency developer can't control.
Using relative file paths in your mix.exs is a bad practice if you want things to behave consistently. The mix project config can be loaded whenever, and by whomever, assuming that this loading always happens inside the current directory is an incorrect assumption.
Fixing this in lexical would involve some kind of caching, which would mean that updating your project config would require a restart of the language server.
Hello guys, I'm trying Lexical out and hitting an issue because we use
File.read!/1
inside ourmix.exs
:The full source code can be found here: https://github.com/firezone/firezone (in
elixir
folder).