repman-io / repman

Repman - PHP Repository Manager: packagist proxy and host for private packages
https://repman.io
MIT License
508 stars 105 forks source link

Artifact cannot be downloaded because presumably "reference" is missing in the download url #453

Open benn0r opened 3 years ago

benn0r commented 3 years ago

When i try for example to install a package with composer require PACKAGE_NAME:1.0.0 composer tries to download https://HOST/dists/PACKAGE_NAME/1.0.0.0/.zip I assume there should be something before ".zip". In the composer.lock i can see the definition: https://HOST/dists/%package%/%version%/%reference%.%type%

So for me it looks like %reference% is missing in the URL that composer tries to download. Is there certain attributes i have to add to the composer.json of my artifacts for artifacts to work properly? Or something else that i have to configure specifially for artifacts? When i add a package with repository type "Gitlab" everything works great.

akondas commented 3 years ago

Hi @benn0r, sorry for late response. I'll need a little more information.

benn0r commented 3 years ago

Hi @akondas, thank you for your reply.

I am using standalone Repman Docker Container. With "type of package" you mean "library" or "composer-plugin" as defined in the composer.json or what do you mean?

The minimal composer.json that is included in the ZIP File in the artifacts folder and that leads to the described issue, looks like this:

{
  "name": "PACKAGE_NAME",
  "type": "library",
  "version": "1.3",
  "autoload": {
    "psr-4": {
      "NAMESPACE\\": "src/"
    }
  }
}
benn0r commented 2 years ago

@akondas could you perhaps provide me with an example artifact zip file which works correctly in your environment? I could then see how its done and hopefully fix my artifacts.

akondas commented 2 years ago

We usually use Github integration, but I can prepare such a package and share it in this issue.

benn0r commented 2 years ago

any news on this? i would really like to work with this project

benn0r commented 2 years ago

Actually by combing through the repo i found this: https://github.com/repman-io/repman/tree/master/tests/Resources/artifacts If i upload this artifacts to my repman server and add it as an artifact it also doesnt work. Here the complete error:

root@777793e4ec17:/var/www/api/foo# composer require buddy-works/alpha:1.0.0
./composer.json has been updated
Running composer update buddy-works/alpha
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking buddy-works/alpha (1.0.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading buddy-works/alpha (1.0.0)
    Failed downloading buddy-works/alpha, trying the next URL (404: The "https://buddy-works.repo.HOST/dists/buddy-works/alpha/1.0.0.0/.zip" file could not be downloaded (HTTP/2 404 ))
  - Downloading buddy-works/alpha (1.0.0)
  - Downloading buddy-works/alpha (1.0.0)
  - Downloading buddy-works/alpha (1.0.0)
  - Downloading buddy-works/alpha (1.0.0)

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

  [Composer\Downloader\TransportException]                                                                                          
  The "/artifacts/test/buddy-works-alpha-1.0.0.zip" file could not be downloaded: failed to open stream: No such file or directory  

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...
jeanfrauc commented 1 year ago

Hi @akondas, do you think this problem can be fixed ? Because, I'd like to use artifacts too on a standalone Repman but I have the same problem. When I try to install it with Composer I get this error message :

[Composer\Downloader\TransportException]
The "/path/to/artifacts/example_1.1.1.zip" file could not be downloaded: Failed to open stream: No such file or directory

And in my composer.lock, the artifact has no reference :

            "name": "artifacts/example",
            "version": "1.1.1",
            "dist": {
                "type": "zip",
                "url": "/path/to/artifacts/example_1.1.1.zip",
                "shasum": "c3a723bdb07fae5d22afb6856d8800df62ebf5ad",
                "mirrors": [
                    {
                        "url": "https://my_repman.local.dev/dists/%package%/%version%/%reference%.%type%",
                        "preferred": true
                    }
                ]
            }

@benn0r, did you find a workaround ?

benn0r commented 1 year ago

@benn0r, did you find a workaround ?

I did not, i eventually stopped looking and I switched to Gitlab Package Registry

jeanfrauc commented 1 year ago

Thank you @benn0r for your very quick reply, I will try Gitlab Package Registry

akondas commented 1 year ago

sorry :disappointed: , at this point I don't have much time to look at this problem more, and it is difficult for me to determine when I will find, but I will be happy to help with code review and merging if someone would like to help ... :shrug:

jeanfrauc commented 1 year ago

No problem @akondas, I even don't know if Repman could answer to my need. In fact, I want to be able to push several times the same version of an artifact on somekind of Composer Packages Repository and Satis that I am currently using can't do it. That's why I'm looking for another solution. Thanks anyway.

mateusrovedaa commented 10 months ago

Hi, I have the same problem when use Artifact.

image

The workaround I used to get the package downloaded was to manually add the reference property to the .lock file.

image

After run composer install, that works fine.

image

edpittol commented 6 months ago

I made a PR (#670) for this issue.

srtab commented 3 months ago

We're having the same problem. @akondas are you considering reviewing the solution suggested by @edpittol? It will be a huge help for us, deploying a version with this fixed.