rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

rebar3 gives "Rebar dependency inets could not be loaded for reason no such file"

Open meppu opened this issue 1 year ago • 9 comments

I was trying to setup Dockerfile for my application but this application also creates some Erlang scripts at runtime with Rebar3. The issue is when i execute rebar3 new escript <name> at runtime, it gives me following error:

===> Rebar dependency inets could not be loaded for reason {"no such file or directory "inets.app""}

But the thing is I can use rebar3 in Docker:

image

But not in application:

image image

This is the current part of the Dockerfile (Elixir image is based on Erlang image):

FROM docker.io/elixir:1.14 AS builder

WORKDIR /app

COPY . .

RUN rebar3 get-deps
RUN rebar3 compile
RUN rebar3 as prod release

FROM docker.io/elixir:1.14

RUN mix local.hex --force
RUN mix local.rebar --force

COPY --from=builder /app/_build/prod/rel/example /release/example

ENTRYPOINT [ "/release/example/bin/example" ]

I tried installing erlang-dev, erlang-inets etc... And they didn't work.

meppu avatar May 16 '23 14:05 meppu

Yep, this error is coming from https://github.com/erlang/rebar3/blob/cc0c1a944b08f94e735673d6a386e263a89171e1/apps/rebar/src/rebar3.erl#L399-L416 where we have an explicit check to know if your install contains all the required and visible apps for rebar3 to run.

This means that whatever install you have with the apps either isn't configuring the lib to be in the path, or isn't containing them.

Did this ever work before or is this a first time thing?

ferd avatar May 16 '23 18:05 ferd

"It works on my machine" 😂

But as i said it also works on container when i use podman/docker exec. The problem is it doesn't work when i use it with erlang:open_port while it is running on container.

And i useElixir container, based on official Erlang container. So there should be no issues (since i can compile my project with it) but i also made a containerfile based on debian sid (unstable) repositories but it still gives same error.

FROM docker.io/elixir:1.14 AS builder

WORKDIR /app

COPY . .

RUN rebar3 get-deps
RUN rebar3 compile
RUN rebar3 as prod release

FROM docker.io/debian:unstable

# Install Deps
RUN apt-get update && apt-get install -y wget
RUN wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

RUN apt-get install -y libodbc1 libsctp1

# Install Elixir + Erlang
RUN apt-get install -y elixir erlang rebar3 erlang-inets

# Prepare Mix
RUN mix local.hex --force
RUN mix local.rebar --force

# Copy Release
COPY --from=builder /app/_build/prod/rel/erland /release/erland

ENTRYPOINT [ "/release/erland/bin/erland" ]

The issue is when i run it with erlang:open_port while it is running in container, rebar3 is failing for any command.

Also setting DEBUG=1 environments doesn't give any information about it.

meppu avatar May 16 '23 18:05 meppu

The issue is likely the use of the debian erlang package. Better to use an Erlang docker image, asdf/kerl or the Erlang Solutions debian repos.

tsloughter avatar May 16 '23 18:05 tsloughter

The issue is likely the use of the debian erlang package. Better to use an Erlang docker image, asdf/kerl or the Erlang Solutions debian repos.

Erlang docker image is also not working.

meppu avatar May 16 '23 18:05 meppu

Ill publish an example rebar3 app to show issue now.

meppu avatar May 16 '23 18:05 meppu

Well, for some reason when i add inets to the applications, it worked. But i have no idea why it is working now. Can someone explain me what is related between inets and erlang:open_port?

meppu avatar May 16 '23 18:05 meppu

Oh so if it's building fine that's one thing.

But when you build a release, Rebar3 makes sure to only include the apps you need and request. So if you were somehow:

  1. building a release
  2. building the elixir app
  3. then calling rebar3 using the Erlang from the release built in step 1

then you would find yourself in a situation where you're using a minimal release's Erlang where inets was purposefully omitted by the tooling. So specifying inets to be there as well will make it work again, but you might still not be using the global install you thought you did?

ferd avatar May 17 '23 00:05 ferd

Yeah it still gives erl_include error when i need to run renar3 release inside of erlang app via open_port. But i also want to know why when i run rebar3 it doesn't uses the global installation.

Is there any way to just run shell command without these issues? I also need to get output information real-time.

meppu avatar May 17 '23 06:05 meppu

I'm not quite sure. The escript rebar3 runs will use whatever Erlang is closest in path based on the priorities.

If the error you see with rebar3 also happens with the basic 'erl' command, you know that's the problem. If it does not happen with 'erl' then something quite odd is going on.

ferd avatar May 21 '23 00:05 ferd