DVM - D Version Manager 0.4.3

Jacob Carlborg via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Sep 4 23:22:13 PDT 2014


On 04/09/14 22:51, Jordi Sayol via Digitalmars-d-announce wrote:

> On Debian testing (mate desktop) without ~/.dvm dir, dmd still not found:
> ----
> $ dvm install dvm
> $ dvm install 2.065.0
> Fetching: http://ftp.digitalmars.com/dmd.2.065.0.zip
> [========================================>] 50581/49347 KB
>
> Installing: dmd-2.065.0
> $ dvm use 2.065.0
> $ dmd
> bash: dmd: command not found
> ----
>
> BTW Is there a reason to mandatory copy dvm to ~/.dvm/bin directory?

Yes. DVM works like this:

* When invoking "dvm" on the command line a bash function is actually called

* The bash function will forward to the "dvm" executable located in 
~/.dvm/bin

* When running "dvm use 2.065.0" the executable it will write a shell 
script setting up the PATH variable to point to path of the install 
compiler with the specified version. In this case which will be 
~/.dvm/compilers/dmd-2.065.0/linux/bin

* When the "dvm" executable has finished running the "dvm" function will 
source the shell script which modifies the PATH variable in the current 
session

This is the only why I found to propagate environment variables from a 
child process (dvm) to the parent process (the shell)

When running "dvm install dvm", dvm will do the following:

* Setup the necessary directory structure in "~/.dvm"

* Install the shell script containing [1] the "dvm" bash function to 
~/.dvm/scripts

* Copy itself to ~/.dvm/bin

* Add a couple of lines to .bash_profile or .bashrc that sources the 
"dvm" script:

if [ -s ~/.dvm/scripts/dvm ] ; then
   . ~/.dvm/scripts/dvm
fi

I wanted the installation process to be as easy as possible, what's why 
I wrote an installer in the tool. Yes I know, that's not how most tools 
work like. But it do require some special setup and most tools don't 
require.

[1] https://github.com/jacob-carlborg/dvm/blob/master/resources/dvm.sh

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list