shaka-project / express-chocolatey-server

Simple Chocolatey package server for Express
5 stars 5 forks source link

How to interact with chocolatey? #1

Closed godofgrunts closed 1 year ago

godofgrunts commented 1 year ago

We are moving from an unsupported server and I'm looking into this as a solution for us.

I've successfully got the server up and running, but, as noted in the README, this doesn't have the v2 api.

I've only ever used chocolately by adding v2 api sources to it. So how do I use the chocolately client to interact with this server?

joeyparrish commented 1 year ago

You make a great point. I documented running the server, but not the choco commands we use with it.

Here's an example from our lab packages doc:

choco source add -n=shaka-lab -s=https://shaka-lab-chocolatey-dot-shaka-player-demo.appspot.com/
choco install shaka-lab-node

In this example, that long URL is where the server is running in Google Cloud, and shaka-lab-node is the name of the package we host there.

So if you want to name your source foo, host a package called bar at server URL http://baz.gov:8080/, you would run:

choco source add -n=foo -s=http://baz.gov:8080/
choco install bar

Then you could upgrade the package by deploying a package update, restarting your server (package metadata is loaded at startup), and running this on your client:

choco upgrade -y bar

Does this help? If so, I'll add this information to the README.

godofgrunts commented 1 year ago

This is what I tried before writing an issue (guess I should have mentioned that) and it wasn't working for me. Here is where I'm at.

Server: 10.161.0.247 Port: 8000

I have one nupkg in there for testing called phwms.1.0_15.nupkg. I pulled this from our current working server so I know it works.

Start the server with PORT=8000 npx express-chocolatey-server *.nupkg

It starts and tells me it sees my phwms package.

If I curl http://10.161.0.247:8000 I get:

$ curl http://10.161.0.247:8000
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<service xmlns="http://www.w3.org/2007/app"
         xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="Packages">
      <atom:title>Packages</atom:title>
    </collection>
  </workspace>
</service>

So the server is up and running.

Add the source to my chocolatey:

choco source add -n Test --source="http://10.161.0.247:8000/"

Run choco source to verify:

Test - http://10.161.0.247:8000/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.

Now if I run choco upgrade phwms (since it's already installed) I get an error saying it cannot be found:

choco upgrade phwms
Chocolatey v1.1.0
Upgrading the following packages:
phwms
By upgrading, you accept licenses for the packages.

phwms was not found with the source(s) listed.
 If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
 Version: ""; Source(s): "http://10.161.0.247:8000/"

Chocolatey upgraded 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:
 - phwms - phwms was not found with the source(s) listed.

I'm not sure if choco list is supposed to work since not all of the API is functional, but I also get 0 packages found this way.

Kikilluh commented 1 year ago

Edit - RESOLVED : This is a bit silly. I juste had to add à / at the end of the source URL. My bad..

choco source add -n=test -s 'https://my-express-choco-server.com/'

Hello, i have the same problem here.

It sounds silly but i can't figure out how to retrieve my package, with choco or even with https.

I have two docker container :

My express-chocolatey-server is running well on the port 443, and my putty package (for test) is well pushed :

Loaded packages: [
{
  id: 'putty',
  version: '0.78',
  title: 'PuTTY',
  authors: 'Simon Tatham',
  owners: 'chocolatey-community, Rob Reynolds',
...

Like godofgrunts, if i go on https://my-express-choco-server.com, i get a file with a random name and the same content as him.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<service xmlns="http://www.w3.org/2007/app"
         xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="Packages">
      <atom:title>Packages</atom:title>
    </collection>
  </workspace>
</service>

Same message from chocolatey when i am trying to install putty :

choco install putty -s test
Chocolatey v1.2.0
Installing the following packages:
putty
By installing, you accept licenses for the packages.
Error retrieving packages from source 'https://my-express-choco-server.com:
 URI non valide : Impossible d'analyser le nom d'hôte.
putty not installed. The package was not found with the source(s) listed.
 Source(s): 'https://my-express-choco-server.com'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - putty - putty not installed. The package was not found with the source(s) listed.
 Source(s): 'https://my-express-choco-server.com'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.
choco search --source test
Chocolatey v1.2.0
[NuGet] Not able to contact source 'https://my-express-choco-server.com'. Error was URI non valide : Impossible d'analyser le nom d'hôte.
[NuGet] Not able to contact source 'https://my-express-choco-server.com'. Error was URI non valide : Impossible d'analyser le nom d'hôte.
0 packages found.

It seems that we are missing just a little last action or method to call the repository ... Do you have an idea to unlock the situation ?

Thanks a lot !

joeyparrish commented 1 year ago

Try choco search phwms. This should result in a query to your server like:

http://10.161.0.247:8000/Packages()?$filter=substringof(%27phwms%27,tolower(Id))

This is working for my server.

joeyparrish commented 1 year ago

If that doesn't work, please let me know and I'll try to arrange some better way for me to help you debug this.

godofgrunts commented 1 year ago

Thanks for responding, but we have decided to move to a different package management system.

joeyparrish commented 1 year ago

Okay. Sorry I wasn't able to help you. This system is still pretty nascent and the filter parsing is very, very simple and may miss some cases that we haven't run across in our own infrastructure yet.

joeyparrish commented 1 year ago

Reopening because I'm seeing the same issue now with a fresh chocolatey install on a new machine.

joeyparrish commented 1 year ago

Should be fixed in v1.0.2, which I just tagged and published to NPM

joeyparrish commented 1 year ago

I deployed the update to my source, and it appears to be working. The fix commit also includes a new mention in the README for how to configure clients: https://github.com/shaka-project/express-chocolatey-server#configuring-clients