wallyfoo

wallyfoo

Apple Silicon Erlang 23.2.1 not compiling bcrypt_elixir properly. I think

I was using asdf to install the latest Apple Silicon compiled versions of Erlang and Elixir to use on a Phoenix project that employs the new gen-auth stuff.

When running elixir 1.11.2-otp-23 + Erlang 23.2.1 for Apple Silicon, bcrypt_elixir fails to compile, noting it needs Erlang 20 or better. The bcrypt.nif never gets created.

When I revert back to my last Intel version of Erlang, 23.0.3, I can rebuild the project and the bcrypt.nif gets created. Keeping Apple or Intel Elixir makes no difference. It comes down to the Erlang base system.

So, what comes next? The maintainer of bcrypt_elixir recommended I post here since it doesn’t seem to be his problem – maybe something with the elixir_make process? I admit I’m still a newbie in this ecosystem, so I’m at a roadblock for where to go to seek the knowledge to get this resolved. I expect I’m not the only person this will affect.

Marked As Solved

wallyfoo

wallyfoo

This where I admit I’m an idiot and post the solution for others who didn’t already figure this out.

This was a VSCode problem. Everything was working as intended, but a race condition of a sort was breaking my needed flow.

My VSCode was launched. It’s the intel build, and it’s running the ElixirLS extension (jakebecker version).

I knew I needed to rebuild, so I rm -fr my deps and _build directories.

When VSCode was running in the background, after I deleted the deps directory, it re-fetched the dependencies automatically. The Intel versions, however that works. Rebuilding resulted in the mismatched versions of the bcrypt_nif.so, and Phoenix freaked the hell out when I tried to do any user authentication.

When I completely quit VSCode and built from the terminal after deleting the deps and _build directories, everything fetched and elixir_bcrypt built for the proper architecture.

I didn’t realize that VSCode was using its spawned Intel beam process to correctly fetch those deps according to its architecture. I wanted to share in case someone else has a brain fart like I did. I’ll probably switch to the VSCode insiders arm64 version until the main release gets the Apple Silicon treatment. Or maybe it’s finally time to switch to emacs.

16
Post #4

Also Liked

johnknott

johnknott

I just ran into this, because I switched to iTerm2 and for whatever reason that defaults to launching in x86 mode.

You can change this in the menu: iTerm2 → Preferences → Profiles → General and change “Login Shell” to “Command” and then enter “arch -arm64 $SHELL”. No idea why this isn’t default…

LostKobrakai

LostKobrakai

With bcrypt_elixir you’re not compiling elixir, but C. The error you posted in the github issue on for bcrypt_elixir does indeed suggest there’s some issue with the C related tooling, which may be something elixir_make can adjust for.

Nicd

Nicd

I just ran into this same issue. I build my project in Vagrant but I had left VSCode open looking at the shared folder, so it fetched the host OS NIFs when I was trying to build them inside Vagrant. Learned my lesson, close VSCode when building the release! :slight_smile:

tuddman

tuddman

same issue - with SQLite blowing up with errors on an Apple Silicon (recompiled with elixir 1.13)
Solution for me:

most important part: is to do the following in a vanilla Terminal.app window (not iTerm!)

- rm -rf _build/*
- rm -rf deps/*
- mix deps.get
- mix deps.compile

and poof - compilation errors went away. Can now go back to running iex in an iTerm window no problem.

m1dnight

m1dnight

Okay I managed to get it working by simply completely reinstalling Elixir and Erlang.

brew remove erlang
brew remove elixir 
brew cleanup
brew install elixir

All is well now!

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New

We're in Beta

About us Mission Statement