How to specify the elixir version of the instance to SSH into?

so right after I SSH into the deployed instance, I got below error

ssh xxxx-abc@ssh.oregon.render.com
iex -S mix

returned

** (Mix) You're trying to run :my_app on Elixir v1.9.4 but it has declared in its mix.exs file it supports only Elixir ~> 1.12

Render’s default elixir is 1.9 and my deployed app is running on 1.12 by specifying ELIXIR_VERSION=1.12.1 in my environment variable.
But how can I spin up the ssh instance with the correct elixir version?

Just to clarify: You have a Render service that is successfully running with Elixir 1.12, but when you SSH into the instance it’s defaulting to Elixir 1.9?

Yes correct! The deployed app is successfully running elixir 1.12 but when I SSH into the instance I couldn’t bring up the console due to above error

I can confirm the same behavior. I have ELIXIR_VERSION env var set to 1.13.3. You can check it on service srv-c2d4kb3onmlahlpdbb60

When using the Shell tab in the web UI:

which iex
# /opt/render/project/elixirs/1.13.3/bin/iex

echo $PATH
# /opt/render/project/elixirs/1.13.3/bin:/opt/render/project/erlangs/24.2.1/bin:/usr/local/cargo/bin:/opt/render/project/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

When using ssh:

which iex
# /usr/local/bin/iex

echo $PATH
# /usr/local/cargo/bin:/opt/render/project/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/render-ssh/session/bin

It looks like Render runs a command behind the scenes to detect the version when starting or connecting to your service from most contexts, but it doesn’t run when connecting via SSH. Can you try running:

ELIXIR_ENV_FILE=/home/render/elixir-env.sh; [ -f "$ELIXIR_ENV_FILE" ] && source "$ELIXIR_ENV_FILE"; after connecting?

I’ll share this with the team to see how we can support this without needing to run the command manually.

1 Like

That worked, thanks.

ELIXIR_ENV_FILE=/home/render/elixir-env.sh; [ -f "$ELIXIR_ENV_FILE" ] && source "$ELIXIR_ENV_FILE";
# ==> Detected Erlang 24.2.1
# ==> Detected Elixir 1.13.3

~/project/src$ which iex
# /opt/render/project/elixirs/1.13.3/bin/iex
1 Like

Yes this script worked - thanks! And yes it would be great if this can be done automatically rather than manually load every time.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.