Setting Up an Elixir Environment for Phoenix 1.2 Development

Hello everyone,

I need help setting up a development environment to work on a Phoenix 1.2 project. No, I don’t care if it’s out of date and insecure.

I’m taking “The Complete Elixir and Phoenix Bootcamp” and have really been enjoying it so far. Elixir is ludicrously batteries-included and intuitive enough that for most of the tutorial I was able to guess ahead and beat the instructor to solutions. Pattern matching is wicked.

The second half of the course is taught with Phoenix 1.2 and I don’t really know where to start. Elixir web-setup for Windows only lets me install back to version 1.10.0, and I can’t really find a clear answer on which OTP/Elixir version Phoenix 1.2.5 needs.

Suggestions? Help?

That’s wonderful to hear, welcome to the community!

This much at least I can help with. If you go to the Phoenix project on github the 1.2.5 was made on July 27, 2017. That gives us a rough time frame to go look for Elixir tags: Release v1.5.0 · elixir-lang/elixir · GitHub

It looks like Elixir 1.5.0 was released 2 days prior, so that’s probably the version to use.

Compatibility and Deprecations — Elixir v1.12.3 lists Elixir and OTP compatibility: For you it looks like OTP 18-20 should work.

Fair enough, but understand that trying to get specific, 5.5 year old versions of software running on a platform that is relatively niche in the community (windows) may present a lot of trouble. We haven’t even started on getting whatever the javascript build toolchain from 5.5 years ago looked like going :D. WSL2 might help? Not sure.

4 Likes

Hey Ben, thanks for the friendly, detailed, and fast reply!

The Windows machine is just my gaming box, I’ve got Debian/Fedora laptops lying around. I’ll try on those if I have too much trouble. Worst case scenario I’ll just muddle through the tutorial with the latest version of Phoenix.

Checked the Node releases and saw Node.js 8.11.3 released on 2018-06-12. Luckily this is super easy to install with NVM, but getting the rest of the Phoenix build toolchain may be tricky for sure.

Hopefully the following will be enough, will try and tag this question with Windows and report back if things go well. Things seemed to install just fine after running:

nvm install 8.11.3
choco install erlang --version=20.3
choco install elixir --version=1.5.3

Checking versions:

PS C:\Users\Developer> elixir --version
Erlang/OTP 20 [erts-9.3] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10]

Elixir 1.5.3
PS C:\Users\Developer> node -v
v8.11.3

Running mix archive.install hex phoenix 1.2.5 failed, but this worked:

mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez

In the project I had some weirdness getting the npm dependencies installed but this was fixed with npm i -g brunch@2 and running npm install again.

Needed to use Postgres 9, otherwise ecto was throwing errors I couldn’t figure out:

docker run --name <name> -p 5432:5432 
  -e POSTGRES_PASSWORD=<pwd> -d postgres:9

…can’t believe it works lol. Installing things like this on Windows is usually a nightmare, I’ll post back if I have any further issues.

Cheers!

PS C:\Users\Developer\Documents\Elixir\discuss> mix phoenix.server
Compiling 12 files (.ex)
Generated discuss app
[info] Running Discuss.Endpoint with Cowboy using http://localhost:4000
08:48:25 - info: compiled 6 files into 2 files, copied 3 in 1.0 sec
[info] GET /
[debug] Processing by Discuss.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 31ms
1 Like

I am running a dev container with Elixir 1.3.1 (the version used in the course). I got the Phoenix 1.2.5 installed properly by using a Dockerfile.

But I got a dependency issue with expo. When I try to create a DB connection with ecto

When I enter mix ecto.create, I get an error with
warning: the dependency :expo requires Elixir "~> 1.11" but you are running on v1.3.1

could not compile dependency :expo, "mix compile" failed. You can recompile this dependency with "mix deps.compile expo", update it with "mix deps.update expo" or clean it with "mix deps.clean expo" ** (Mix) Encountered compilation errors

Did anyone solve this? How can I get the correct version of expo to compile?

My Dockerfile is as follows.

FROM elixir:1.3.1

WORKDIR /workspaces

# Install Node.js, Hex and the Phoenix framework
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
    && export NVM_DIR="$HOME/.nvm" \
    && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
    && nvm install 6.9.1 \
    && wget https://github.com/phoenixframework/archives/raw/master/phoenix_new-1.2.5.ez \
    && mix archive.install --force phoenix_new-1.2.5.ez \ 
    && mix local.hex --force \
    && rm phoenix_new-1.2.5.ez

EXPOSE 4000
EXPOSE 5432```

Which course? I think I would not use a course that is this old.

As far as your specific error goes: You need to add dependences that are compatible with the (incredibly old) version of Elixir that you are using. This is going to be very hard.

1 Like

This Course by Stephen Grinder.
It’s a best seller on Udemy and shows that it’s recently updated but under the hood, it still uses old Phoenix 1.2 to teach the framework. I didn’t have a problem with the first part of the tutorial. Guy, taught it in an easy-to-understand and hands-on manner but the phoenix part made me pull out my hair.
I had to use docker-compose for dev Containers on VSCode and run an old version of Elixir and Postgres to replicate the environment. Then hex was pulling new dependencies and ecto was giving me issues so I had to copy mix.lock and mix.exs to work along with the tutorials.
Thanks for the idea btw… Didn’t know why I didn’t think of that earlier instead of trying to solve the dependencies myself.