jswny

jswny

OpenAI Codex (cloud) Elixir support

Has anyone managed to get Codex (the cloud version, as seen here) to work for Elixir?

I tried to setup the dependencies but mix deps.get always gives the following error:

{:failed_connect, [{:to_address, {~c"proxy", 8080}}, {:inet, [:inet], :econnrefused}]}
Failed to fetch record for plug from registry (using cache instead)

I’ve tried these but none seem to work:

export HEX_CACERTS_PATH="$CODEX_PROXY_CERT"
export HEX_UNSAFE_HTTPS="1"

My setup script that does work is this:

sudo add-apt-repository -y ppa:rabbitmq/rabbitmq-erlang
sudo apt update -y
sudo apt install -y git elixir erlang
mix archive.install github hexpm/hex branch latest --force

Installing things with Git seems fine, even mix can install deps that are pinned to a Github commit

The Docker image that runs has HTTP_PROXY and HTTPS_PROXY both set to http://proxy:8080

Most Liked

DavidVII

DavidVII

For the sake of comparing notes, here’s my experience trying to get mix deps.get working in a Codex environment. It looks like I’m hitting a proxy wall too.

Based on Codex’s documentation on internet access and proxies, here’s what I tried after installing Elixir via asdf:

  1. Set all the recommended proxy and cert env vars:

    export http_proxy="http://proxy:8080"
    export https_proxy="http://proxy:8080"
    export SSL_CERT_FILE="$CODEX_PROXY_CERT"
    export REQUESTS_CA_BUNDLE="$CODEX_PROXY_CERT"
    export HEX_CACERTS_PATH="$CODEX_PROXY_CERT"
    export HEX_HTTP_CONCURRENCY=1
    
  2. Installed Hex manually (since mix local.hex --force fails with a 503):

    mix archive.install github hexpm/hex --branch latest --force
    
  3. Ran mix deps.get and got this repeated error:

    upstream connect error or disconnect/reset before headers. reset reason: connection termination
    

It looks like repo.hex.pm is getting blocked entirely, or the TLS handshake is being dropped by the proxy. Even with HEX_CACERTS_PATH pointing to the Codex proxy cert, the connection fails before it completes.

I noticed the docs say:

Environments are pre-configured to work with common tools and package managers

So I’m guessing Hex just isn’t allowed yet the way pip, npm, and others are.

Would love to get this working. Happy to test more or compare setups.

FWIW here’s my full script up until I try doing mix local.hex --force

#!/usr/bin/env bash
# bootstrap_asdf_prebuilt.sh – pulls binary OTP builds, so no C tool-chain needed
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive

# 1. Runtime-only libs (<< 10 MB total)
apt-get update -qq
apt-get install -y --no-install-recommends libssl3 zlib1g libncurses6
rm -rf /var/lib/apt/lists/*

# 2. asdf (same as before, but no gcc/make)
git clone -q https://github.com/asdf-vm/asdf.git /opt/asdf --branch v0.14.1
echo '. /opt/asdf/asdf.sh' >> /etc/bash.bashrc
. /opt/asdf/asdf.sh

# 3. **Pre-built** plugin for Erlang
asdf plugin add erlang https://github.com/michallepicki/asdf-erlang-prebuilt-ubuntu-24.04.git || true
asdf plugin add elixir
asdf plugin add nodejs

# 4. Honour your .tool-versions file
asdf install
asdf reshim

echo "🔥 OTP and Elixir installed"

export http_proxy="http://proxy:8080"
export https_proxy="http://proxy:8080"
export SSL_CERT_FILE="$CODEX_PROXY_CERT"
export REQUESTS_CA_BUNDLE="$CODEX_PROXY_CERT"
export HEX_CACERTS_PATH="$CODEX_PROXY_CERT"
export HEX_HTTP_CONCURRENCY=1
iamyojimbo

iamyojimbo

The underlying bug has been fixed in OTP and Elixir will work in Codex Cloud with the latest Erlang patches.

We patched erlang/otp httpc module. It has been released in OTP 28.1, 27.3.4.3 and 26.2.5.15. mix deps.get now works as expected since httpc no longer sends the te header for default GET requests.

Thanks @Damirados for the sample using Mise en Place. This works:

# make sure mise + its shims are on PATH now and later
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
echo 'export PATH=$HOME/.local/share/mise/shims:$PATH' >> ~/.bashrc
echo 'export HEX_CACERTS_PATH=$CODEX_PROXY_CERT' >> ~/.bashrc
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/share/mise/shims:$PATH
export HEX_CACERTS_PATH=$CODEX_PROXY_CERT

mise use --global erlang@28.1
mise use --global elixir@1.18.4-otp-28

mix deps.get
mix deps.compile
mix compile
vkryukov

vkryukov

Success! After spending a few hours with ChatGPT o3, I have finally managed to cast an incantation that seems to work! Some of the steps might be not necessary, and I might play with the script some more to experiment what can be safely removed.

TL;DR of the two critical steps:

  • Need to compile Erlang with the right certificates (just using the binaries doesn’t seem to work). That’s unfortunate, as compiling Erlang takes the most amount of time (be patient!)
  • Need to use a different Hex proxy jsDeliver from Mirrors | Hex; the official one doesn’t seem to work

Here is the script - let me know if it works for you, and how we can eliminate the unnecessary settings.

gleb

gleb

I asked our engineer Savvas to look into this. He is still working on it and will post more details later. But here the brief explanation of what is broken and how to work around it.

Here is the setup script that should work for now:

# OpenAI Codex setup script for Elixir projects
go install github.com/asdf-vm/asdf/cmd/asdf@v0.18.0
asdf plugin add erlang https://github.com/michallepicki/asdf-erlang-prebuilt-ubuntu-24.04.git || true
asdf plugin add elixir
asdf install erlang 28.0.2
asdf set --home erlang 28.0.2
asdf install elixir 1.18.4-otp-28
asdf set --home elixir 1.18.4-otp-28
echo 'export PATH=$HOME/.asdf/shims:$PATH' >> ~/.bashrc
echo 'export HEX_CACERTS_PATH=$CODEX_PROXY_CERT' >> ~/.bashrc
export PATH=$HOME/.asdf/shims:$PATH
export HEX_CACERTS_PATH=$CODEX_PROXY_CERT
# use hex fork with a workaround for httpc bug https://github.com/erlang/otp/issues/10065
mix archive.install --force github 650health/hex branch latest
# mix local.rebar doesn't work on Codex likely because it's not respecting HEX_CACERTS_PATH env var.
# TODO investigate this further
# install rebar manually as a temporary workaround
curl -L -o rebar3 https://s3.amazonaws.com/rebar3/rebar3
chmod +x ./rebar3
./rebar3 local install
export PATH=/root/.cache/rebar3/bin:$PATH
mix local.rebar rebar3 $(which rebar3)

mix deps.get
mix deps.compile
mix compile
DavidVII

DavidVII

I made some tweaks to it for my setup, but that worked! Thank you :slight_smile:

Where Next?

Popular in Dev Env & Tools Top

AstonJ
While on the theme of routers: Is your computer's internet connection wired or wireless? (Poll) Which router do you use? How do you se...
New
aziz
I’m happy to finally present to you the best Sublime Text package for Elixir, templates and more! :partying_face: :confetti_ball: Elixi...
New
JoeZMar
After the keyboard thread has convinced me to purchase a UHK I wanted to make one about the mouse. Switching to a programmable keyboard h...
New
AstonJ
Inspired by @jdiago’s post containing this slide: I thought it would be interesting discussing what independent languages like Elixir...
#ai
New
kayoj
Hello I have been testing different environments for Elixir development &amp; noticed something odd. When I run the Elixir formatter loc...
#ai
New
borag
I shared an Elixir Architect skill for Claude Code which proves that Elixir is the best LLM friendly language (@josevalim ) https://git...
New
AstonJ
Following on from this post in Do you use LittleSnitch or the equivalent on your OS? I think it might be worth us creating this thread so...
New
pinksynth
Hey everybody. I was wondering if anybody here has used Panic’s Nova editor. It came out recently and I saw there was no Elixir Formatte...
New
evnp
How do you all feel about the use of AI tools for building Elixir/Phoenix projects, with respect to these topics? Longform context below....
New
dimitarvp
It would also be the reason for me to seriously hurt myself. :003: I’ve spent way too much time tinkering. I’ll be the first to agree th...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement