11

Problem

A Chocolatey Package, which requires certain software located on the Chocolatey Gallery has been created by following the instructions on this website. If the nuspec file contains dependencies:

...</tags>
    <dependencies>
      <dependency id="dependentPackageA" version="1.0"/>
      <dependency id="dependentPackageB" version="2.0"/>
    </dependencies>
  </metadata>...

and the command cinst packageName -source ""%cd%;http://chocolatey.org/api/v2/"" is executed to test the Chocolatey Package locally, the following error occurs:

The term 'http://chocolatey.org/api/v2/' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a 
path was included, verify that the path is correct and try again.

If the dependency snippet has been commented and cinst packageName -source %cd% is executed the Chocolatey Package will be installed locally.

Providing the Chocolatey Package to the Chocolatey Gallery and subsequently install it by issuing cinst packageName succeeds (package and dependencies are installed).

Question

How to test Chocolatey Package dependencies locally before publishing it to the Chocolatey Gallery?

030
  • 8,013
  • 8
  • 63
  • 100

1 Answers1

10

Use apostrophe ' and double quotes " on each side, like:

--source "'.;https://chocolatey.org/api/v2/'"

To shorten that a bit, in newer versions of Chocolatey you can try:

-s "'.;chocolatey'"

https://github.com/chocolatey/choco/wiki/CreatePackages#testing-your-package

Passing Arguments to Chocolatey

ferventcoder
  • 10,640
  • 2
  • 51
  • 83
  • The docs at https://github.com/chocolatey/chocolatey/wiki/CreatePackages#testing-your-package are incorrect (they say to use 2 double quotes, when the single quote here is correct). – codekaizen Nov 27 '14 at 08:47
  • This doesn't work for me. The error message is the same as noted in the question. I've already tried various combination of the URI (with https, with trailing slash and without it). – ComFreek Jan 02 '15 at 15:54
  • @ComFreek Which chocolatey version? Could you post the full command you are trying in a comment? – 030 Jan 02 '15 at 15:56
  • Choco v0.9.8.28. `PS D:\Desktop\chocolatey\chocolatey-packages\netbeans> choco install netbeans -source '"D:\Desktop\chocolatey\chocolatey-packages\netbeans;http://chocolatey.org/api/v2/"'` – ComFreek Jan 02 '15 at 16:00
  • @ComFreek Could you replace with `%cd%;` and try it again? The command should be `choco install netbeans -source '"%cd%;http://chocolatey.org/api/v2/"'` – 030 Jan 02 '15 at 16:06
  • 1
    @utrecht I used [`Convert-Path .`](http://blogs.technet.com/b/heyscriptingguy/archive/2014/09/26/powertip-find-current-working-directory-in-powershell.aspx) instead of `%cd%` to get the current working directory in PowerShell and it works! `choco install netbeans -source "$(Convert-Path .);http://chocolat ey.org/api/v2/"` Thank you very much! /ferventcoder: Could you please incorporate this into your answer? – ComFreek Jan 02 '15 at 16:11
  • @utrecht Sorry to have been too overhasty since the error still remained, however, it only appeared after the installation of NetBeans. It is probably not that fatal anymore because Chocolatey doesn't try to look for the already installed jdk8 package. – ComFreek Jan 02 '15 at 16:19
  • @ComFreek You can shorten that down to the well-known `$pwd`. I updated the answer to reflect that (and the wiki) – ferventcoder Jan 02 '15 at 19:34
  • Well, it still throws the error, but I have finally found a solution: use `"'$pwd;https://chocolatey.org/api/v2/'"` (double quotes at first and then single quotes!). – ComFreek Jan 02 '15 at 22:40
  • Powershell... ugh on handling string parsing sometimes... :/ – ferventcoder Jan 03 '15 at 13:29