简体   繁体   中英

rebar eunit can't find include lib in erlang:latest docker container

I'm new to docker and erlang. I've installed docker and VSCode on my windows machine and I want to learn to develop erlang in the container, so I created Dockerfile:

FROM erlang:latest

WORKDIR /project

COPY . .

and .devcontainer directory with devcontainer.json file:

{
    "name": "Erlang dev container",
    "context": ".",
    "dockerFile": "Dockerfile",
    "settings": { 
        "terminal.integrated.shell.linux": "/bin/bash"
    },
    "extensions": []
}

After I opened my project folder in container I can issue bash commands and I can start erl but when I try to ask rebar to test my code with

rebar eunit

or

rebar3 eunit

I get error:

can't find include lib "eunit/lib/eunit.hrl"

What did I do wrong? Is the erlang:latest image supposed to be used for erlang development? How to fix it?

In order to use eunit , when I run erlang programs in the shell (not using docker), I use the following -include_lib directive:

-include_lib("eunit/include/eunit.hrl").

You seem to be using a different path:

 eunit/lib/eunit.hrl

in container I can issue bash commands

Then use bash commands to search for the file eunit.hrl .

You can always just copy the file eunit.hrl and put it in the src directory of your rebar project, then in your module use:

-include("eunit.hrl")

I'm new to docker and erlang.

If worst comes to worst, don't worry about eunit. There is a lot to learn about erlang before you will need a testing framework.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM