Dub Error Message "Invalid variable: DUB"

Paul Backus snarwin at gmail.com
Sun Jun 7 16:54:48 UTC 2020


On Sunday, 7 June 2020 at 16:26:17 UTC, Andre Pany wrote:
> On Sunday, 7 June 2020 at 15:37:27 UTC, Paul Backus wrote:
>> On Sunday, 7 June 2020 at 12:52:12 UTC, Andre Pany wrote:
>>>
>>> I am not sure but $DUB is a variable which could be used in 
>>> dub descriptor file but it isn't an environment variable.
>>>
>>> $DUB_EXE is an environment variable.
>>>
>>> Kind regards
>>> Andre
>>
>> If what you say is true, the Dub documentation needs to be 
>> updated:
>>
>> https://dub.pm/package-format-json.html#environment-variables
>
> Each of the table has an explanation section were they can be 
> used. $DUB can only be used within the dub descriptor but not 
> within scripts called from the hooks.
>
> From the hooks you can use these environment variables: 
> https://github.com/andre2007/dub/blob/376ff5854dcd7bbc6116f72001c8c6d13eb3cbf0/source/dub/generators/generator.d#L763
>
> Kind regards
> Andre

The documentations says:

> Inside of custom commands directives a number of additional 
> variables is available:

...and then lists the variables from the function you linked to. 
"Additional" implies that they are not the only variables that 
can be used in hooks, and that the variables listed previously 
(such as $DUB) can also be used. If this is not the case, then 
the documentation is inaccurate and should be updated.

I would also add: if you feel the need to link to the source code 
to explain to use a feature, rather than referring to the 
documentation, that is a good sign that the documentation is 
inadequate.


More information about the Digitalmars-d-learn mailing list