Issues installing a new dependency

started learning elixir 2 days ago, and i am having issues trying to install a new dep. In theory i just should write it in mix.exs file and then run in console mix deps.get, right?

when is like this. its ok

defp deps do
[
{:phoenix, “~> 1.6.15”},
{:phoenix_ecto, “~> 4.4”},
{:ecto_sql, “~> 3.6”},
{:postgrex, “>= 0.0.0”},
{:phoenix_live_dashboard, “~> 0.6”},
{:esbuild, “~> 0.4”, runtime: Mix.env() == :dev},
{:swoosh, “~> 1.3”},
{:telemetry_metrics, “~> 0.6”},
{:telemetry_poller, “~> 1.0”},
{:gettext, “~> 0.18”},
{:jason, “~> 1.2”},
{:plug_cowboy, “~> 2.5”}
]
end

when i do this

defp deps do
[
{:phoenix, “~> 1.6.15”},
{:phoenix_ecto, “~> 4.4”},
{:ecto_sql, “~> 3.6”},
{:postgrex, “>= 0.0.0”},
{:phoenix_live_dashboard, “~> 0.6”},
{:esbuild, “~> 0.4”, runtime: Mix.env() == :dev},
{:swoosh, “~> 1.3”},
{:telemetry_metrics, “~> 0.6”},
{:telemetry_poller, “~> 1.0”},
{:gettext, “~> 0.18”},
{:jason, “~> 1.2”},
{:plug_cowboy, “~> 2.5”},
{:argon2_elixir, “~> 3.0”}
]
end

defmodule gets a red underscore

edit: the underscore error remains also when i run mix deps.get. I checked in dep folder and the dependecy is installed.

It is red because the dependency is not yet there…

It disappear after mix deps.get

but when i run mix deps.get the underscore error remains. I checked in dep folder and the dependecy is installed.

You may need to reload your editor.

1 Like

tried to recompile, update, even cleaning and installing again. But i got the same issue.

this is what shows when i run iex -S mix

==> argon2_elixir
could not compile dependency :argon2_elixir, “mix compile” failed. Errors may have been logged above. You can recompile this dependency with “mix deps.compile argon2_elixir”, update it with “mix deps.update argon2_elixir” or clean it with “mix deps.clean argon2_elixir”
==> api_teste
** (Mix) “nmake” not found in the path. If you have set the MAKE environment variable,
please make sure it is correct.

i did =/

You’re on Windows by the looks of things? Have you got the Visual Studio Build Tools installed? If so, you can compile from the development console for your arch, probably x64, which you’ll find in the start menu. There are other options like running vcvarsall.bat, using wsl, using msys shell… but basically you need to have make in your path.

1 Like

If you run iex -S mix does your project compile and load?

argon2_elixir has C code that must be compiled. Looks like you don’t have (or have not setup) Windows’ development tools i.e. Visual Studio.

1 Like

After looking for some answers based in all coments in this post. I am having problems to define nmake as my variable path. I opened variable system path, added to path “C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64” where my nmake.exe is. Now when i try to iex -S mix or compile, i got this message:

$ iex -S mix
==> argon2_elixir

Microsoft (R) Program Maintenance Utility VersÒo 14.34.31933.0
Direitos autorais da Microsoft Corporation. Todos os direitos reservados.
del /Q /F priv
erl -noshell -s init stop -eval “io:setopts(standard_io, [{encoding, unicode}]), io:format("ERTS_INCLUDE_PATH=~ts/erts-~ts/include/", [code:root_dir(), erlang:system_info(version)]).” > Makefile.auto.win
nmake / /F Makefile.win priv\argon2_nif.dll

Microsoft (R) Program Maintenance Utility VersÒo 14.34.31933.0
Direitos autorais da Microsoft Corporation. Todos os direitos reservados.
if NOT EXIST “priv” mkdir “priv”
cl /O2 /EHsc /I"argon2\include" /I"argon2\src" /I"c:/Program Files/Erlang OTP/erts-13.0.4/include/" /LD /MD /Fepriv\argon2_nif.dll argon2\src\argon2.c argon2\src\core.c argon2\src\blake2\blake2b.c argon2\src\thread.c argon2\src\encoding.c argon2\src\ref.c c_src\argon2_nif.c
Microsoft (R) C/C++ Optimizing Compiler Versão 19.34.31933 para x64
Copyright (C) Microsoft Corporation. Todos os direitos reservados.

argon2.c
argon2\src\argon2.c(18): fatal error C1083: Não é possível abrir arquivo incluir: ‘string.h’: No such file or directory
core.c
argon2\src\core.c(20): fatal error C1083: Não é possível abrir arquivo incluir: ‘windows.h’: No such file or directory
blake2b.c
argon2\src\blake2\blake2b.c(18): fatal error C1083: Não é possível abrir arquivo incluir: ‘stdint.h’: No such file or directory
thread.c
c:\Users\Usuário\Desktop\para_colorir\api\deps\argon2_elixir\argon2\src\thread.h(34): fatal error C1083: Não é possível abrir arquivo incluir: ‘process.h’: No such file or directory
encoding.c
argon2\src\encoding.c(18): fatal error C1083: Não é possível abrir arquivo incluir: ‘stdio.h’: No such file or directory
ref.c
argon2\src\ref.c(18): fatal error C1083: Não é possível abrir arquivo incluir: ‘stdint.h’: No such file or directory
argon2_nif.c
c_src\argon2_nif.c(26): fatal error C1083: Não é possível abrir arquivo incluir: ‘stdio.h’: No such file or directory
Gerando Código…
NMAKE : fatal error U1077: ‘“C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.EXE”’ : c¾digo de retorno ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘“C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\nmake.EXE”’ : c¾digo de retorno ‘0x2’
Stop.
could not compile dependency :argon2_elixir, “mix compile” failed. Errors may have been logged above. You can recompile this dependency with “mix deps.compile argon2_elixir”, update it with “mix
deps.update argon2_elixir” or clean it with “mix deps.clean argon2_elixir”
==> api
** (Mix) Could not compile with “nmake” (exit status: 2).
One option is to install a recent version of
Visual C++ Build Tools
either manually or using Chocolatey -
choco install VisualCppBuildTools.

After installing Visual C++ Build Tools, look in the “Program Files (x86)”
directory and search for “Microsoft Visual Studio”. Note down the full path
of the folder with the highest version number. Open the “run” command and
type in the following command (make sure that the path and version number
are correct):

cmd /K "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

This should open up a command prompt with the necessary environment variables
set, and from which you will be able to run the “mix compile”, “mix deps.compile”,
and “mix test” commands.

Another option is to install the Linux compatiblity tools from MSYS2.

After installation start the msys64 bit terminal from the start menu and install the
C/C++ compiler toolchain. E.g.:

pacman -S --noconfirm pacman-mirrors pkg-config
pacman -S --noconfirm --needed base-devel autoconf automake make libtool git
mingw-w64-x86_64-toolchain mingw-w64-x86_64-openssl mingw-w64-x86_64-libtool

This will give you a compilation suite nearly compatible with Unix’ standard tools.

tried to install c++ build tools, but i cant complete instalation cause its says a setup package is damaged or missing, when i mark checkbox to download the package from internet nothing happens

i am so lost guys. No clue how to solve this.

Not sure how much help you’ll get with Spanish errors pasted. :003:

I’d just use WSL if I were you. Having Windows development environment is to me a huge nope. It can be made to work, mind you, but I always found the effort too big to be worth it.

i know my english skills are awful =/ Never tried linux before.

Taking a step back, can you simply change out argon2 for something else? GitHub - riverrun/pbkdf2_elixir: Pbkdf2 password hashing for Elixir doesn’t have any native code and should be easier to use.

2 Likes

Yes, i found earlier this lib pbkdf2 and it compiled. But i am so curious how to solve this problem with nmake cause i had same issue trying bccrypts lib. After that i found pbkdf2. Thank you so much for your effort trying to help me.

I feel like this is a fallacy that is perpetuated by those that don’t actually use multiple operating systems. I’ve been developing on Windows since day dot and I find it much easier to setup than a Linux one. Down the road, it might be worth moving to Unix land, but getting started is much simpler on Windows. If you want to install via ASDF there are myriad packages to install and environment variables you need to set beforehand. You’ve got to figure out which kerl flags you need to set if you want docs, wx etc. On Windows, you install erlang, elixir, and if you are using libs with C to compile, vs build tools, and away you go.

There are downsides. Figuring out how to build native modules is a common stumbling block, many libraries don’t write tests that work cross platform, most examples are in Unix parlance, and every time you ask for help people will tell you to stop using Windows instead of answering your question :stuck_out_tongue:

1 Like

how friendly is migrate to a new OS? I ve been developing javascript/typescript around a year using react and node. Never had this kind of issues before. Should i migrate to linux before continue studying Elixir? I really would like to fix the problem instead surround it.

It might be a softer onramp to use WSL than fully migrate to Linux.

Use what you’re most comfortable with. I’ll appreciate it if you don’t claim that I am “perpetuating fallacies”.

It’s exactly because I used Windows, Linux and macOS.

All 3 major OS-es can be made to work for a normal dev env where you don’t need to compile exotic stuff. When I needed to stray off the beaten path however, both Windows and macOS became difficult to tune and Linux at least allowed it (even if it sucked big time at places).