Thread overview
Re: Dub Error Message "Invalid variable: DUB"
Jun 07, 2020
Russel Winder
Jun 07, 2020
Basile B.
Jun 07, 2020
Russel Winder
Jun 07, 2020
Basile B.
Jun 07, 2020
Andre Pany
June 07, 2020
On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote:
> Hi,
> 
> Why on earth is Dub sending out this error message (Invalid variable: DUB)
> on
> GitLab but not on Travis-CI or locally?
> 
> OK, that was slightly rhetorical, more reasonably, why is dub sending out
> this
> message at all?

I am assuming that the error comes from the line:

preBuildCommands "$DUB run --compiler=$$DC unit-threaded -c gen_ut_main -- -f generated/ut_dub_main.d -d $DUB"

in the unittest configuration as suggested for using unit-threaded. The question is why does the symbol DUB not need to be defined locally or on Travis-CI, but only on GitLab?

|> printenv | grep -i dub
|>

On Travis-CI and locally Dub find where it is, why does it not do this on GitLab? It is at /usr/bin/dub in all cases.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



June 07, 2020
On Sunday, 7 June 2020 at 10:06:14 UTC, Russel Winder wrote:
> On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote:
>> Hi,
>> 
>> Why on earth is Dub sending out this error message (Invalid variable: DUB)
>> on
>> GitLab but not on Travis-CI or locally?
>> 
>> OK, that was slightly rhetorical, more reasonably, why is dub sending out
>> this
>> message at all?
>
> I am assuming that the error comes from the line:
>
> preBuildCommands "$DUB run --compiler=$$DC unit-threaded -c gen_ut_main -- -f generated/ut_dub_main.d -d $DUB"
>
> in the unittest configuration as suggested for using unit-threaded. The question is why does the symbol DUB not need to be defined locally or on Travis-CI, but only on GitLab?
>
> |> printenv | grep -i dub
> |>
>
> On Travis-CI and locally Dub find where it is, why does it not do this on GitLab? It is at /usr/bin/dub in all cases.

What is the docker image that you use ?  If it is an older version maybe that the $DUB env variable is not yet supported by the dub version that's installed (it exists since 2.084.0 according to [1]).

In my .gitalab-ci.yml I use 'dlang2/ldc-ubuntu' [2] or 'dlang2/dmd-ubuntu' [3] which give always recent versions of D.

[1] https://dlang.org/changelog/2.084.0.html
[2] https://hub.docker.com/r/dlang2/ldc-ubuntu
[3] https://hub.docker.com/r/dlang2/dmd-ubuntu
June 07, 2020
On Sun, 2020-06-07 at 10:30 +0000, Basile B. via Digitalmars-d-learn wrote: […]
> What is the docker image that you use ?  If it is an older version maybe that the $DUB env variable is not yet supported by the dub version that's installed (it exists since 2.084.0 according to [1]).

I am using ubuntu:focal. ubuntu:bionic has ldc 1.8 which is far too old. Focal has ldc 1.20.

I think the dub version is 1.19.<something>

I am having to manually symbolically link /usr/bin/gcc and /usr/bin/cc so I suspect the installation of focal is not going quite right. Especially as I have to manually set a TZ variable to avoid a lock up.

> In my .gitalab-ci.yml I use 'dlang2/ldc-ubuntu' [2] or 'dlang2/dmd-ubuntu' [3] which give always recent versions of D.
> 
> [1] https://dlang.org/changelog/2.084.0.html
> [2] https://hub.docker.com/r/dlang2/ldc-ubuntu
> [3] https://hub.docker.com/r/dlang2/dmd-ubuntu

I shall have to investigate these docker images in favour of working with a bare Ubuntu.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



June 07, 2020
On Sunday, 7 June 2020 at 10:06:14 UTC, Russel Winder wrote:
> On Sun, 2020-06-07 at 10:24 +0100, Russel Winder wrote:
>> Hi,
>> 
>> Why on earth is Dub sending out this error message (Invalid variable: DUB)
>> on
>> GitLab but not on Travis-CI or locally?
>> 
>> OK, that was slightly rhetorical, more reasonably, why is dub sending out
>> this
>> message at all?
>
> I am assuming that the error comes from the line:
>
> preBuildCommands "$DUB run --compiler=$$DC unit-threaded -c gen_ut_main -- -f generated/ut_dub_main.d -d $DUB"
>
> in the unittest configuration as suggested for using unit-threaded. The question is why does the symbol DUB not need to be defined locally or on Travis-CI, but only on GitLab?
>
> |> printenv | grep -i dub
> |>
>
> On Travis-CI and locally Dub find where it is, why does it not do this on GitLab? It is at /usr/bin/dub in all cases.

$DUB is a variable but not an environment variable.
This is also the background why the environment variable $DC needs to be escaped here.

Kind regards
Andre

June 07, 2020
On Sunday, 7 June 2020 at 12:24:13 UTC, Russel Winder wrote:
> On Sun, 2020-06-07 at 10:30 +0000, Basile B. via Digitalmars-d-learn wrote: […]
>> What is the docker image that you use ?  If it is an older version maybe that the $DUB env variable is not yet supported by the dub version that's installed (it exists since 2.084.0 according to [1]).
>
> I am using ubuntu:focal. ubuntu:bionic has ldc 1.8 which is far too old. Focal has ldc 1.20.
>
> I think the dub version is 1.19.<something>
>
> I am having to manually symbolically link /usr/bin/gcc and /usr/bin/cc so I suspect the installation of focal is not going quite right. Especially as I have to manually set a TZ variable to avoid a lock up.
>
>> In my .gitalab-ci.yml I use 'dlang2/ldc-ubuntu' [2] or 'dlang2/dmd-ubuntu' [3] which give always recent versions of D.
>> 
>> [1] https://dlang.org/changelog/2.084.0.html
>> [2] https://hub.docker.com/r/dlang2/ldc-ubuntu
>> [3] https://hub.docker.com/r/dlang2/dmd-ubuntu
>
> I shall have to investigate these docker images in favour of working with a bare Ubuntu.

Yes because that works reasonably well on gitlab.
The only problem is that you might have to setup other things as their ubuntu image is very light. Software like zip or even git are not there by default.

A simple example of `.gitlab-ci.yml` file to support D is

---
job:
  image: dlang2/dmd-ubuntu
  before_script:
  # tools that are not in their base ubuntu image
  - apt-get update -y
  - apt-get install -y supplemental_package_x
  - apt-get install -y supplemental_package_y
  # similarly to what's done on most of the other CI services
  script:
  - bash some_script.sh
  - dub build
  - dub test
  # - etc.
---