jacob-carlborg/dvm

dmd version used by dvm still uses global include path

Closed this issue · 4 comments

Using dvm 0.5.0.
After I use dvm use dmd reports the intended version, yet it uses the global include path to import library modules (/usr/include/dmd/phobos/).

Hmm, which config file is DMD using? You can find out by running dmd | head.

Oh, it's my mistake.
I should have pass a path to the chosen dmd to dub (as a --compiler option).
I thought dub will pick the first found dmd in PATH, but it seems, the search is more complicated than that.
Probably the thing should be mentioned on README.

I thought dub will pick the first found dmd in PATH, but it seems, the search is more complicated than that.

Hmm, I thought it would too. I always use Dub and DMD through DVM. But I don't have a globally installed DMD. It's a possibility that it's using the correct version of DMD but picking up the wrong dmd.conf file. To know for sure which version of DMD you're compiling with you can add pragma(msg, __VERSION__); to the source code.

Also, if you're running Dub through a shell script you need to manually setup DVM:

if [ -s "$HOME/.dvm/scripts/dvm" ] ; then
    . "$HOME/.dvm/scripts/dvm" ;
    dvm use 2.086.0
fi

@jacob-carlborg I have this if statement in my .bashrc (minus dvm use which I do in the bash separately).
I checked, dub really uses the globally installed dmd version even if some other dmd version is in PATH before the global one.
So the right way is to use

dub --compiler=`which dmd`