www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to do equivalent of npm install --save with dub?

reply "Andrew Grace" <a blah.com> writes:
I am trying to play with D, but I'm getting stuck with the DUB 
package manager.  If use DUB to download a package to my project, 
how do I get DUB to add what I downloaded to the dub.json file?  
I have tried DUB --fetch --cache=local http-parser (for example). 
  It downloads the package, but then nothing is added to the list 
of dependencies.

I'd appreciate any help.

Thanks,
Andrew
Jan 12 2015
next sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 13/01/2015 2:01 p.m., Andrew Grace wrote:
 I am trying to play with D, but I'm getting stuck with the DUB package
 manager.  If use DUB to download a package to my project, how do I get
 DUB to add what I downloaded to the dub.json file? I have tried DUB
 --fetch --cache=local http-parser (for example).  It downloads the
 package, but then nothing is added to the list of dependencies.

 I'd appreciate any help.

 Thanks,
 Andrew
Documentation here: http://code.dlang.org/package-format Basically: { "name": "myproject", ... "dependencies": { "project(:subproject)?": "semver" } } There's no need to tell dub to download any package. It'll do so automatically.
Jan 12 2015
prev sibling parent Mike Parker <aldacron gmail.com> writes:
On 1/13/2015 10:01 AM, Andrew Grace wrote:
 I am trying to play with D, but I'm getting stuck with the DUB package
 manager.  If use DUB to download a package to my project, how do I get
 DUB to add what I downloaded to the dub.json file? I have tried DUB
 --fetch --cache=local http-parser (for example).  It downloads the
 package, but then nothing is added to the list of dependencies.

 I'd appreciate any help.
As Rikki said, you don't need to download anything. You've got it rather backwards. *You* add the dependency to the dub.json and then *DUB* will pull it down and compile it automatically when you execute 'dub' or 'dub build' in the same directory as the configuration file. See the dub.json at [1] as an example. It's a simple little TicTacToe game that has a dependency on DerelictSDL2, which, if you look at [2], you'll find has a dependency on DerelictUtil. If you clone the source, cd into the top-level directory and execute 'dub', then DUB will pull down both DerelictUtil and DerelictSDL2, compile them into libraries, compile the game code, then link it with the libraries and run the executable. [1] https://github.com/aldacron/t3/blob/master/dub.json [2] https://github.com/DerelictOrg/DerelictSDL2/blob/master/package.json
Jan 13 2015