"You need to have Erlang 20 installed to use this version of bcrypt_elixir" but is already installed
WolfDan opened this issue · comments
As the title says I already have erlang 20 installed in my machine:
C:\Users\bla\Documents\Projects\bla\bla>elixir --version
Erlang/OTP 20 [erts-9.0] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10]
Elixir 1.5.1
But when I run my test get this error:
...11:25:34.638 [error] Process #PID<0.6506.0> raised an exception
** (RuntimeError) You need to have Erlang 20 installed to use this version of bcrypt_elixir.
Either upgrade to Erlang 20 or use version 0.12 of bcrypt_elixir.
(bcrypt_elixir) lib/bcrypt/base.ex:14: Bcrypt.Base.init/0
(kernel) code_server.erl:1333: anonymous fn/1 in :code_server.handle_on_load/5
11:25:34.639 [warn] The on_load function for module Elixir.Bcrypt.Base returned:
{%RuntimeError{message: "You need to have Erlang 20 installed to use this version of bcrypt_elixir.\nEither upgrade to Erlang 20 or use version 0.12 of bcrypt_elixir.\n"},
[{Bcrypt.Base, :init, 0, [file: 'lib/bcrypt/base.ex', line: 14]},
{:code_server, :"-handle_on_load/5-fun-0-", 1,
[file: 'code_server.erl', line: 1333]}]}
1) test Login attemps (MyApp.Account.Test)
test/MyApp_server/account/account_test.exs:8
** (UndefinedFunctionError) function Bcrypt.Base.checkpass_nif/2 is undefined (module Bcrypt.Base is not available)
code: for _ <- 0..4 do
stacktrace:
(bcrypt_elixir) Bcrypt.Base.checkpass_nif('whatever', '$2a$06$k2qYJ5nilg7F/xrJ2kgvMeGeap2gpJcMovobG90J6yHReHF7s0.22')
(bcrypt_elixir) lib/bcrypt.ex:88: Bcrypt.verify_pass/2
(MyApp_server) lib/MyApp_server/account/account.ex:50: MyApp.Account.authenticate/1
test/MyApp_server/account/account_test.exs:12: anonymous fn/2 in MyApp.Account.Test."test Login attemps"/1
(elixir) lib/enum.ex:1841: Enum.reduce_range_inc/4
test/MyApp_server/account/account_test.exs:11: (test)
Finished in 0.09 seconds
4 tests, 1 failure
Randomized with seed 490000
I need to do any adittional step to make it work or?
Greetings
It looks like you are on Windows. Could you check this page, making sure that you have a C compiler installed?
Let me know if that works.
Thanks for pointing this out. I'll update the error message to make it more informative.
@riverrun I forgot to mention that is already compiled, also I run mix test on at the developers command prompt for VS 2017, when compile show this:
Generated poison app
==> elixir_make
Compiling 1 file (.ex)
Generated elixir_make app
==> bcrypt_elixir
Utilidad de mantenimiento de programas de Microsoft (R) versi¾n 14.10.25019.0
(C) Microsoft Corporation. Reservados todos los derechos.
del /Q /F priv
erl -eval "io:format(\"~s~n\", [lists:concat([\"ERTS_INCLUDE_PATH=\", code:root_dir(), \"/erts-\", erlang:system_info(version), \"/include\"])])" -s init stop -noshell > Makefile.auto.win
nmake / /F Makefile.win priv\bcrypt_nif.dll
Utilidad de mantenimiento de programas de Microsoft (R) versi¾n 14.10.25019.0
(C) Microsoft Corporation. Reservados todos los derechos.
if NOT EXIST "priv" mkdir "priv"
cl /O2 /EHsc /I"c_src" /I"c:/Program Files/erl9.0/erts-9.0/include" /LD /MD /Fepriv\bcrypt_nif.dll c_src\bcrypt_nif.c c_src\blowfish.c
Compilador de optimización de C/C++ de Microsoft (R) versión 19.10.25019 para x86
(C) Microsoft Corporation. Reservados todos los derechos.
bcrypt_nif.c
blowfish.c
Generando código...
Microsoft (R) Incremental Linker Version 14.10.25019.0
Copyright (C) Microsoft Corporation. All rights reserved.
/dll
/implib:priv\bcrypt_nif.lib
/out:priv\bcrypt_nif.dll
bcrypt_nif.obj
blowfish.obj
Creando biblioteca priv\bcrypt_nif.lib y objeto priv\bcrypt_nif.exp
Compiling 3 files (.ex)
Generated bcrypt_elixir app
==> comeonin
Compiling 2 files (.ex)
Generated comeonin app
Go into the deps\bcrypt_elixir\lib\bcrypt
folder and in the base.ex file, change the init function to:
def init do
load_nif()
end
Then run MIX_ENV=test mix deps.compile
and mix test
, and let me know what the error message is.
This is the result (Run on developers command prompt for VS 2017):
...13:14:32.306 [warn] The on_load function for module Elixir.Bcrypt.Base returned:
{:error,
{:load_failed,
'Failed to load NIF library c:/Users/Bla/Documents/Projects/MyApp/MyApp_server/_build/test/lib/bcrypt_elixir/priv/bcrypt_nif: \'Unspecified error\''}}
1) test Login attemps (MyApp.Account.Test)
test/MyApp_server/account/account_test.exs:8
** (UndefinedFunctionError) function Bcrypt.Base.checkpass_nif/2 is undefined (module Bcrypt.Base is not available)
code: for _ <- 0..4 do
stacktrace:
(bcrypt_elixir) Bcrypt.Base.checkpass_nif('whatever', '$2a$06$k2qYJ5nilg7F/xrJ2kgvMeGeap2gpJcMovobG90J6yHReHF7s0.22')
(bcrypt_elixir) lib/bcrypt.ex:88: Bcrypt.verify_pass/2
(MyApp_server) lib/MyApp_server/account/account.ex:50: MyApp.Account.authenticate/1
test/MyApp_server/account/account_test.exs:12: anonymous fn/2 in MyApp.Account.Test."test Login attemps"/1
(elixir) lib/enum.ex:1841: Enum.reduce_range_inc/4
test/MyApp_server/account/account_test.exs:11: (test)
Finished in 0.06 seconds
4 tests, 1 failure
Randomized with seed 89000
I was hoping for something a little more informative than "Unspecified error" :(
Try looking at this issue and see if any of the suggestions there work for you.
One further question: have you been able to use comeonin, or bcrypt_elixir, in the past, or is this the first time you have used it?
Well in fact the library itself is compiling, here the result Image link
The error message is when the program is running not when is compiled.
Now I compile it just with the developer command tool, the reason is this:
C:\WINDOWS\system32>"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" amd64
Error in script usage. The correct usage is:
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" [option]
or
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" [option] store
or
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" [option] [version number]
or
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" [option] store [version number]
where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK
:
The store parameter sets environment variables to support
store (rather than desktop) development.
:
For example:
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x86_amd64
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x86_arm store
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x86_amd64 10.0.10240.0
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x86_arm store 10.0.10240.0
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x64 8.1
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat" x64 store 8.1
:
Please make sure either Visual Studio or C++ Build SKU is installed.
No matter if the command is correct always give me this error so I can't run compile on a normal cmd console, maybe compile with Visual dev command line give the running error?
"One further question: have you been able to use comeonin, or bcrypt_elixir, in the past, or is this the first time you have used it?"
Is the first time using comeonin ^^'
Can you find the vcvarsall.bat
file and tell me which directory it is in?
As mention on the previous message is on
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC"
One more thing you could try is to delete the _build
directory and try running the tests again.
If that doesn't work, try asking for advice on other forums -- elixirforum.com or stackoverflow.com. I don't have a Windows machine, so it's a bit difficult for me to give you any further advice.
Unfortunately, getting Comeonin to run on Windows is a lot less straightforward than it should be.
Ok, yeah I tried and don't work, I'll keep looking for solution, if I found any I come here and reply and close the issue, thanks for your help ^^
Greetings
Hi, did you manage to solve this problem?
I've been a little busy this week, tomorrow I'll try again and I'll tell you if I managed to work or not ^^/
I made it work!
I updated Visual Studio to the last version, so they moved the file to this path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build
run the command, compile the project from zero (deleting deps and _build) and it works! hope this help to others :D
Glad to hear you got it working and thanks for letting us know how you solved the issue. I'll update the wiki with this info.
The 'new' build tools dont use the vcarsall.bat approach, or rather they do, but they just slap a developer console in the start menu.
Even using this and confirming I have nmake etc in path, I still get the same exact errors as above here.
VS 2017 tools (console)
Elixir 1.8.0, otp 20
Windows 10
Just for the record :)
Let me know if you need me to run any debug stuff.
The nif compiles just fine, I have dlls and everything in the priv of the deps folder.
ANd lastly, I am on the newest version on bcrypt_elixir, but I am using it via comeonin api.
23:45:51.896 [error] Process #PID<0.5980.0> raised an exception
** (RuntimeError) An error occurred when loading Bcrypt.
Make sure you have a C compiler and Erlang 20 installed.
If you are not using Erlang 20, either upgrade to Erlang 20 or
use version 0.12 of bcrypt_elixir.
See the Comeonin wiki for more information.
(bcrypt_elixir) lib/bcrypt/base.ex:17: Bcrypt.Base.init/0
(kernel) code_server.erl:1340: anonymous fn/1 in :code_server.handle_on_load/5
23:45:51.896 [warn] The on_load function for module Elixir.Bcrypt.Base returned:
{%RuntimeError{message: "An error occurred when loading Bcrypt.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse version 0.12 of bcrypt_elixir.\nSee the Comeonin wiki for more information.\n"}, [{Bcrypt.Base, :init, 0, [file: 'lib/bcrypt/base.ex', line: 17]}, {:code_server, :"-handle_on_load/5-fun-0-", 1, [file: 'code_server.erl', line: 1340]}]}
** (UndefinedFunctionError) function Bcrypt.Base.gensalt_nif/3 is undefined (module Bcrypt.Base is not available)
(bcrypt_elixir) Bcrypt.Base.gensalt_nif(<<124, 115, 246, 96, 73, 120, 179, 106, 48, 13, 103, 82, 7, 234, 150, 68>>, 12, 98)
(bcrypt_elixir) lib/bcrypt.ex:86: Bcrypt.hash_pwd_salt/2
(safari) lib/safari/schemas/accounts/user.ex:81: Safari.Accounts.User.encode_password/1
(safari) lib/safari/schemas/accounts/user.ex:70: Safari.Accounts.User.common_validations/1
(safari) lib/safari/service/accounts/user_service.ex:222: Safari.Accounts.UserService.save_user/2
(safari) lib/safari/service/accounts/user_service.ex:202: anonymous fn/2 in Safari.Accounts.UserService.register/1
(ecto_sql) lib/ecto/adapters/sql.ex:784: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection) lib/db_connection.ex:1341: DBConnection.run_transaction/4
C:\Users\olive\Documents\code\safari\api>elixir -v
Erlang/OTP 21 [erts-10.1] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Elixir 1.8.0 (compiled with Erlang/OTP 20)
C:\Users\olive\Documents\code\safari\api>nmake
Microsoft (R) Program Maintenance Utility Version 14.16.27024.1
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
C:\Users\olive\Documents\code\safari\api>
The developer console you mention - does that set all the environment variables (the ones that vcvarsall.bat used to set)?
It does indeed set them.
I wonder if its something vs2017 does differently, because it fails the same on a newly set up computer too.
Do you have any kind of diagnostics you want me to run?
Having this same issue with vs code 2019.
@alexandre-k-korotkov please open a new issue and show me the error output that you are receiving.
@riverrun I managed to get past it. The fix for me was uninstalling visual studio code 2019 and re-installing it again with every single workload. The first time I did not install the C compiler initially, I only did after I realized I needed it. It must not have been setting the env variables properly because of that. 😕
This is the script that worked afterwards:
cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=x64
It was driving me crazy, and the reason I was getting that error was ridiculous. It was because there were blank spaces in my absolute path; those spaces generate issues when bcryp_elixir is being compiled. Just update your absolute path and make sure not to leave any blank space; solved it.