www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - official activate script is super confusing

reply Chris Katko <ckatko gmail.com> writes:
https://dlang.org/install.html#activate

I ran the two curl liners for grabbing DMD and LDC newest.

So now I have ~/dlang/ldc-1.32.2 and ~/dlang/dmd-2.104.0

How am I supposed to have both "activated"? Why does LDC have to 
override DMD, and DMD have to override LDC in the PATH?

I have both installed on another system without using this script 
and they run fine side-by-side. I can call dmd, or ldc, without 
any special "activate" calls. But this script seems to be the 
easiest/fastest way to download DMD and LDC.

I normally have separate scripts for dmd and ldc. (godmd, and 
goldc) But it seems I'll have to hardcode calls to the right 
activate script before my normal script code.

```sh
#godmd
~/dlang/dmd-2.104.0/activate
dmd -I.......
```

But the activate scripts may have different version numbers in 
path!

~/dlang/dmd-2.104.0/activate

will one day become

~/dlang/dmd-2.105.0/activate

and so on.
Jul 01 2023
parent IchorDev <zxinsworld gmail.com> writes:
On Saturday, 1 July 2023 at 22:16:47 UTC, Chris Katko wrote:
 https://dlang.org/install.html#activate

 I ran the two curl liners for grabbing DMD and LDC newest.

 So now I have ~/dlang/ldc-1.32.2 and ~/dlang/dmd-2.104.0

 How am I supposed to have both "activated"? Why does LDC have 
 to override DMD, and DMD have to override LDC in the PATH?
Who said it has to? Run the activation scripts the other way around. It just prepends them to the binary search path.
 I normally have separate scripts for dmd and ldc. (godmd, and 
 goldc) But it seems I'll have to hardcode calls to the right 
 activate script before my normal script code.

 ```sh
 #godmd
 ~/dlang/dmd-2.104.0/activate
 dmd -I.......
 ```

 But the activate scripts may have different version numbers in 
 path!

 ~/dlang/dmd-2.104.0/activate

 will one day become

 ~/dlang/dmd-2.105.0/activate

 and so on.
Don't put the activate command in your script like that in the first place. You can run it in your shell's `.profile`, or just append the directories from `~/dlang/install.sh get-path` to the `.profile` yourself: ```sh #use a specific version you already have: PATH="$(dirname $(~/dlang/install.sh get-path dmd-2.104.0)):$PATH" #OR always install the latest version: PATH="$(dirname $(~/dlang/install.sh get-path dmd --install)):$PATH" ``` Remember, this is prepending (just like activate), which means if you do this with multiple compilers then the LAST one will take precedence over all the others.
Aug 10 2023