Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: /packages.json: URL using bad/illegal format or missing URL when creating a new Docker/Laravel project #11861

Open
Ambroz91 opened this issue Feb 23, 2024 · 3 comments
Labels

Comments

@Ambroz91
Copy link

Hello.
I'm trying to create a laravel project using this template (https://github.com/ucan-lab/docker-laravel) and Desktop Docker on Windows, but I had the following error. Some time ago it worked just fine and now the error shows up.

In CurlDownloader.php line 389:

  [Composer\Downloader\TransportException]
/packages.json: URL using bad/illegal format or missing URL

My composer.json: (not sure it is the right one or it should be a docker one)

{
    "name": "laravel/framework",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "homepage": "https://laravel.com",
    "support": {
        "issues": "https://github.com/laravel/framework/issues",
        "source": "https://github.com/laravel/framework"
    },
    "authors": [
        {
            "name": "Taylor Otwell",
            "email": "taylor@laravel.com"
        }
    ],
    "require": {
        "php": "^8.0.2",
        "ext-ctype": "*",
        "ext-filter": "*",
        "ext-hash": "*",
        "ext-mbstring": "*",
        "ext-openssl": "*",
        "ext-session": "*",
        "ext-tokenizer": "*",
        "brick/math": "^0.9.3|^0.10.2|^0.11",
        "doctrine/inflector": "^2.0.5",
        "dragonmantank/cron-expression": "^3.3.2",
        "egulias/email-validator": "^3.2.1|^4.0",
        "fruitcake/php-cors": "^1.2",
        "guzzlehttp/uri-template": "^1.0",
        "laravel/serializable-closure": "^1.2.2",
        "league/commonmark": "^2.2.1",
        "league/flysystem": "^3.8.0",
        "monolog/monolog": "^2.0",
        "nesbot/carbon": "^2.62.1",
        "nunomaduro/termwind": "^1.13",
        "psr/container": "^1.1.1|^2.0.1",
        "psr/log": "^1.0|^2.0|^3.0",
        "psr/simple-cache": "^1.0|^2.0|^3.0",
        "ramsey/uuid": "^4.7",
        "symfony/console": "^6.0.9",
        "symfony/error-handler": "^6.0",
        "symfony/finder": "^6.0",
        "symfony/http-foundation": "^6.0",
        "symfony/http-kernel": "^6.0",
        "symfony/mailer": "^6.0",
        "symfony/mime": "^6.0",
        "symfony/process": "^6.0",
        "symfony/routing": "^6.0",
        "symfony/uid": "^6.0",
        "symfony/var-dumper": "^6.0",
        "tijsverkoyen/css-to-inline-styles": "^2.2.5",
        "vlucas/phpdotenv": "^5.4.1",
        "voku/portable-ascii": "^2.0"
    },
    "replace": {
        "illuminate/auth": "self.version",
        "illuminate/broadcasting": "self.version",
        "illuminate/bus": "self.version",
        "illuminate/cache": "self.version",
        "illuminate/collections": "self.version",
        "illuminate/conditionable": "self.version",
        "illuminate/config": "self.version",
        "illuminate/console": "self.version",
        "illuminate/container": "self.version",
        "illuminate/contracts": "self.version",
        "illuminate/cookie": "self.version",
        "illuminate/database": "self.version",
        "illuminate/encryption": "self.version",
        "illuminate/events": "self.version",
        "illuminate/filesystem": "self.version",
        "illuminate/hashing": "self.version",
        "illuminate/http": "self.version",
        "illuminate/log": "self.version",
        "illuminate/macroable": "self.version",
        "illuminate/mail": "self.version",
        "illuminate/notifications": "self.version",
        "illuminate/pagination": "self.version",
        "illuminate/pipeline": "self.version",
        "illuminate/queue": "self.version",
        "illuminate/redis": "self.version",
        "illuminate/routing": "self.version",
        "illuminate/session": "self.version",
        "illuminate/support": "self.version",
        "illuminate/testing": "self.version",
        "illuminate/translation": "self.version",
        "illuminate/validation": "self.version",
        "illuminate/view": "self.version"
    },
    "require-dev": {
        "ext-gmp": "*",
        "ably/ably-php": "^1.0",
        "aws/aws-sdk-php": "^3.235.5",
        "doctrine/dbal": "^2.13.3|^3.1.4",
        "fakerphp/faker": "^1.21",
        "guzzlehttp/guzzle": "^7.5",
        "league/flysystem-aws-s3-v3": "^3.0",
        "league/flysystem-ftp": "^3.0",
        "league/flysystem-path-prefixing": "^3.3",
        "league/flysystem-read-only": "^3.3",
        "league/flysystem-sftp-v3": "^3.0",
        "mockery/mockery": "^1.5.1",
        "orchestra/testbench-core": "^7.24",
        "pda/pheanstalk": "^4.0",
        "phpstan/phpdoc-parser": "^1.15",
        "phpstan/phpstan": "^1.4.7",
        "phpunit/phpunit": "^9.5.8",
        "predis/predis": "^1.1.9|^2.0.2",
        "symfony/cache": "^6.0",
        "symfony/http-client": "^6.0"
    },
    "provide": {
        "psr/container-implementation": "1.1|2.0",
        "psr/simple-cache-implementation": "1.0|2.0|3.0"
    },
    "conflict": {
        "tightenco/collect": "<5.5.33"
    },
    "autoload": {
        "files": [
            "src/Illuminate/Collections/helpers.php",
            "src/Illuminate/Events/functions.php",
            "src/Illuminate/Foundation/helpers.php",
            "src/Illuminate/Support/helpers.php"
        ],
        "psr-4": {
            "Illuminate\\": "src/Illuminate/",
            "Illuminate\\Support\\": [
                "src/Illuminate/Macroable/",
                "src/Illuminate/Collections/",
                "src/Illuminate/Conditionable/"
            ]
        }
    },
    "autoload-dev": {
        "files": [
            "tests/Database/stubs/MigrationCreatorFakeMigration.php"
        ],
        "psr-4": {
            "Illuminate\\Tests\\": "tests/"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "9.x-dev"
        }
    },
    "suggest": {
        "ext-apcu": "Required to use the APC cache driver.",
        "ext-fileinfo": "Required to use the Filesystem class.",
        "ext-ftp": "Required to use the Flysystem FTP driver.",
        "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().",
        "ext-memcached": "Required to use the memcache cache driver.",
        "ext-pcntl": "Required to use all features of the queue worker and console signal trapping.",
        "ext-pdo": "Required to use all database features.",
        "ext-posix": "Required to use all features of the queue worker.",
        "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
        "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
        "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).",
        "brianium/paratest": "Required to run tests in parallel (^6.0).",
        "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).",
        "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
        "filp/whoops": "Required for friendly error pages in development (^2.14.3).",
        "guzzlehttp/guzzle": "Required to use the HTTP Client and the ping methods on schedules (^7.5).",
        "laravel/tinker": "Required to use the tinker console command (^2.0).",
        "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^3.0).",
        "league/flysystem-ftp": "Required to use the Flysystem FTP driver (^3.0).",
        "league/flysystem-path-prefixing": "Required to use the scoped driver (^3.3).",
        "league/flysystem-read-only": "Required to use read-only disks (^3.3)",
        "league/flysystem-sftp-v3": "Required to use the Flysystem SFTP driver (^3.0).",
        "mockery/mockery": "Required to use mocking (^1.5.1).",
        "nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
        "pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
        "phpunit/phpunit": "Required to use assertions and run tests (^9.5.8).",
        "predis/predis": "Required to use the predis connector (^1.1.9|^2.0.2).",
        "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
        "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).",
        "symfony/cache": "Required to PSR-6 cache bridge (^6.0).",
        "symfony/filesystem": "Required to enable support for relative symbolic links (^6.0).",
        "symfony/http-client": "Required to enable support for the Symfony API mail transports (^6.0).",
        "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^6.0).",
        "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^6.0).",
        "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0)."
    },
    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

Output of composer diagnose:

Checking platform settings: OK
Checking git settings: OK git version 2.39.1
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking Composer version: OK
Checking Composer and its dependencies for vulnerabilities: OK
Composer version: 2.7.1
PHP version: 8.2.0
PHP binary path: C:\wamp64\bin\php\php8.2.0\php.exe
OpenSSL version: OpenSSL 3.0.7 1 Nov 2022
cURL version: 7.85.0 libz 1.2.12 ssl OpenSSL/3.0.7
zip: extension present, unzip not available, 7-Zip present (7z)

When I run this command:

docker-compose exec app composer create-project --prefer-dist laravel/laravel . -vvv

I get the following output:

Running 2.7.1 (2024-02-09 15:26:28) with PHP 8.3.3 on Linux / 5.15.133.1-microsoft-standard-WSL2
Loading config file /composer/config.json
Loading config file /composer/auth.json
Failed to initialize global composer: Composer could not find the config file: /composer/composer.json
To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage
Creating a "laravel/laravel" project at "./"
Loading config file /composer/config.json
Loading config file /composer/auth.json
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/workspace): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/workspace): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/workspace): git log --pretty="%H" -n1 HEAD
Executing command (/workspace): hg branch
Executing command (/workspace): fossil branch list
Executing command (/workspace): fossil tag list
Executing command (/workspace): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /composer/composer.json

/packages.jsontps://packagist.org

In CurlDownloader.php line 389:

  [Composer\Downloader\TransportException]
/packages.json: URL using bad/illegal format or missing URL


Exception trace:
  at phar:///usr/bin/composer/src/Composer/Util/Http/CurlDownloader.php:389
 Composer\Util\Http\CurlDownloader->tick() at phar:///usr/bin/composer/src/Composer/Util/HttpDownloader.php:392
 Composer\Util\HttpDownloader->countActiveJobs() at phar:///usr/bin/composer/src/Composer/Util/HttpDownloader.php:363
 Composer\Util\HttpDownloader->wait() at phar:///usr/bin/composer/src/Composer/Util/HttpDownloader.php:114
 Composer\Util\HttpDownloader->get() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:1486
 Composer\Repository\ComposerRepository->fetchFile() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:1195
 Composer\Repository\ComposerRepository->loadRootServerFile() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:823
 Composer\Repository\ComposerRepository->hasProviders() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:484
 Composer\Repository\ComposerRepository->loadPackages() at phar:///usr/bin/composer/src/Composer/Repository/RepositorySet.php:198
 Composer\Repository\RepositorySet->findPackages() at phar:///usr/bin/composer/src/Composer/Package/Version/VersionSelector.php:87
 Composer\Package\Version\VersionSelector->findBestCandidate() at phar:///usr/bin/composer/src/Composer/Command/CreateProjectCommand.php:416
 Composer\Command\CreateProjectCommand->installRootPackage() at phar:///usr/bin/composer/src/Composer/Command/CreateProjectCommand.php:196
 Composer\Command\CreateProjectCommand->installProject() at phar:///usr/bin/composer/src/Composer/Command/CreateProjectCommand.php:153
 Composer\Command\CreateProjectCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:384
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:145
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:93
 require() at /usr/bin/composer:29

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]

And I expected this to happen:
I expect to pass the instalation process.

@Seldaek
Copy link
Member

Seldaek commented Feb 23, 2024

This is very odd.. /packages.jsontps://packagist.org looks like it somehow got mangled from https://packagist.org/packages.json, deleting the first two characters.. I don't see how this could happen unless you defined a custom repository.

Could you share the contents of /composer/config.json from inside the container?

@Ambroz91
Copy link
Author

{
    "config": {
        "process-timeout": 3600},
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://packagist.org\r"
        }
    }
}

@Seldaek
Copy link
Member

Seldaek commented Feb 23, 2024

Ok, that's the problem then.. The \r there should be removed. I don't know why that's in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants