In my composer setup I load packages from 2 repos. One composer repo and a private gitlab repo. When I try to do a composer install on my local windows machine, I get the following error messages:
GitLab: The project you were looking for could not be found. fatal:
Could not read from remote repository. Please make sure you have the
correct access rights and the repository exists. ... The requested
package sv-test/testextension could not be found in any version, there
may be a typo in the package name.
Authentification is done via lokal ssh-key and password, that doesnt seem to be the problem. Whats wrong with my setup?
The composer.json of the project looks like this:
{
"repositories": [
{
"type": "composer",
"url": "https://composer.typo3.org/"
},
{
"type": "git",
"url": "git#gitlab.xydevbox.de:sv-test/Testproject.git"
}
],
"name": "svdev/master-dev-box",
"description": "",
"type": "project",
"license": "MIT",
"homepage": "https://www.xydevbox.de/",
"authors": [
{
"name": "Sacha Vorbeck",
"email": "sacha.vorbeck#xydevbox.de",
"homepage": "https://www.xydevbox.de/",
"role": "Developer"
}
],
"require": {
"sv-testbox/testextension": "*",
"helhum/typo3-console": "^4.5",
"typo3/cms": "^8.7"
},
"config": {
"sort-packages": true,
"process-timeout": 2000,
"preferred-install": {
"typo3/cms": "source",
"*": "dist"
}
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
}
}
}
The composer.json from the package to be included from the gitlab private repo looks like this:
{
"name": "sv-testbox/testextension",
"type": "typo3-cms-extension",
"description": "",
"homepage": "https://www.xydevbox.de/",
"license": ["GPL-2.0+"],
"keywords": ["TYPO3 CMS"],
"version": "master",
"dist": {
"url": "git#gitlab.xydevbox.de:sv-test/Testproject.git",
"type": "git"
}
}
Maybe the latest composer version 1.5.2 is something for you if you take a look at the release notes
Fixed GitLabDriver looping endlessly in some conditions
Fixed
GitLabDriver support for unauthenticated requests
Fixed GitLab zip
downloads not triggering credentials prompt if unauthenticated
Fixed
path repository support of COMPOSER_ROOT_VERSION, it now applies to
all path repos within the same git repository
Fixed path repository
handling of copies to avoid copying VCS files and others
Fixed
sub-directory call to ignore list and create-project commands as well
as calls to Composer using --working-dir
Fixed invalid warning
appearing when calling remove on an non-stable package
https://github.com/composer/composer/releases
Thank you Georg and NextThursday. With some help on TYPO3 slack I finally got it running. The replace part was missing. I also learned that one should not edit composer.json files manually - always use the command line options to modify it. This example: https://github.com/TYPO3-Console/TYPO3-Console/blob/master/composer.json was also helpful.
project composer.json:
{
"repositories": [
{
"type": "composer",
"url": "https://composer.typo3.org/"
},
{
"type": "vcs",
"url": "https://github.com/svorbeck/masterconfig"
}
],
"name": "svorbeck/demo",
"description": "",
"type": "project",
"license": "MIT",
"homepage": "https://xydevbox.de/",
"authors": [
{
"name": "Sacha Vorbeck",
"email": "sacha.vorbeck#xydevbox.de",
"role": "Developer"
}
],
"require": {
"svorbeck/masterconfig": "dev-master",
"typo3/cms": "^8.7"
},
"config": {
"sort-packages": true,
"process-timeout": 2000,
"preferred-install": {
"typo3/cms": "source",
"svorbeck/masterconfig": "source",
"*": "dist"
}
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
},
"helhum/typo3-console": {
"install-extension-dummy": "0"
}
}
}
ext composer.json:
{
"name": "svorbeck/masterconfig",
"type": "typo3-cms-extension",
"description": "svorbeck master configuration",
"require": {
"typo3/cms-core": "^8.7"
},
"replace": {
"masterconfig": "self.version",
"svorbeck/masterconfig": "self.version"
}
}
Related
I'm trying to build and deploy an app using CLI and a template taken from an example app.
My steps:
Download template
oc login <...>
oc new-project <...>
oc new-app -f ./nodejs.json
Result:
An app reachable to the outside world (built from the remote github repo source code)
Problem:
It's all good, but I would like to use my own source files located in my current working directory . As I understand it, in order to do this I need to modify BuildConfig part of the template.
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
"source": {
"type": "Git",
"git": {
"uri": "${SOURCE_REPOSITORY_URL}",
"ref": "${SOURCE_REPOSITORY_REF}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "nodejs:6"
},
"env": [
{
"name": "NPM_MIRROR",
"value": "${NPM_MIRROR}"
}
]
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
},
"triggers": [
{
"type": "ImageChange"
},
{
"type": "ConfigChange"
},
{
"type": "GitHub",
"github": {
"secret": "${GITHUB_WEBHOOK_SECRET}"
}
},
{
"type": "Generic",
"generic": {
"secret": "${GENERIC_WEBHOOK_SECRET}"
}
}
],
"postCommit": {
"script": "npm test"
}
}
}
Can you please help me edit this file?
As far as I can see you are developing for nodejs:
A possible solution is to build (aka do all npm stuff) on your local machine (to skip the assemble phase in the s2i build container) then start with a binary source deployment [1][2].
You can do this with these steps:
oc new-app <IMAGE-NAME>~/tmp/nocontent --name=<APPLICATION_NAME>
oc start-build <APPLICATION_NAME> --from-dir=<PATH_TO_DIR>/my-built-app
The <PATH_TO_DIR>/my-built-app dir has to contain the binary (or javascript files) on the root.
The command will stream files to a new build container in openshift (this works also on minishift).
You can also do more customization adding a .s2i dir in the <PATH_TO_DIR>/my-built-app
eg: <PATH_TO_DIR>/my-built-app/.s2i[3]
Note: You have to read documentation and/or explore a pod of your s2i image to know where the files should be placed and where the files are moved by the s2i default scripts shipped with the images itself.
[1]: https://access.redhat.com/documentation/en-us/reference_architectures/2017/html/build_and_deployment_of_java_applications_on_openshift_container_platform_3/build_and_deploy#binary_source_deployment
[2]:https://docs.openshift.com/container-platform/3.6/dev_guide/builds/basic_build_operations.html
[3]: https://access.redhat.com/documentation/en-us/openshift_container_platform/3.6/html/using_images/source-to-image-s2i#customizing-s2i-images
this is my composer.json
{
"name": "mountain-code/symfony-sonata-media-admin",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sidz/SonataMediaBundle.git",
"no-api": true
}
],
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"sensio/generator-bundle": "~2.3",
"sonata-project/admin-bundle": "~2.3",
"sonata-project/doctrine-orm-admin-bundle": "~2.3",
"sonata-project/user-bundle": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"sonata-project/media-bundle": "2.3.x-dev",
"tilleuls/ckeditor-sonata-media-bundle": "^1.0",
"egeloen/ckeditor-bundle": "^4.0",
"knplabs/knp-menu-bundle": "~1.1",
"payum/payum-bundle": "^2.1",
"php-http/guzzle6-adapter": "^1.1",
"payum/paypal-express-checkout-nvp": "^1.3",
"payum/offline": "^1.3",
"hwi/oauth-bundle": "^0.5.1"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.5.9"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}
now
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sidz/SonataMediaBundle.git",
it s empty
But I still wanted to use this composer.json by adding another adcalendar repository
But when I make require adesigns / calendar-bundle no download for empty or private repository (https://github.com/sidz/SonataMediaBundle.git), as I can do thanks
You are out of luck. You referenced other peoples stuff in a way that specifically worked around their decision to NOT publish their work for the general public to consume. You didn't fork their repo or stored their work as a backup in any other way. And now it is gone.
The only thing that hopefully is left is the current state of the vendor/sidz/SonataMediaBundle directory with the last version that you were able to download before the deletion. You could start a new repository and commit this state into it and tag it with the same version, then switch the reference to this new repository. Composer only works by package name - if the name does not change (it is defined in the composer.json file you already have), and the version does not change, Composer consideres this package to be the same, even if the source URL is different.
You could also revert your dependency to be on the original package that is still maintained: https://packagist.org/packages/sonata-project/media-bundle I don't know how much has to change in your code in order to make that work, but I'd strongly suggest to go that route because otherwise you have to maintain that unofficial package yourself.
I have to create a private yii2 extension on BitBucket, and install it in my projects with composer.
The SSH is set up correctly as far as I can understand, it was not at first - and I got an error "repo not found or you do not have permission" (or something of the kind).
The composer finds the composer.json, I removed it to test and I got an error message that "valid composer.json not found".
Now when i run composer update in my Git Bash it just prints "Nothing to install or update" and nothing appears in my vendor/ folder.
I have no errors to go on here, any ideas are mostly welcome!
I've set up the repo and added the following files:
composer.json
{
"name": "ext. name",
"type": "yii2-extension",
"description": "My desc",
"authors": [
{
"name": "Jorgen",
"email": "jorgen#domain.com",
"homepage": "http://www.domain.com"
}
],
"minimum-stability": "stable",
"support": {
"source": "bitbucket.org/companyname/yii2-extensionname"
},
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "2.0.*"
},
"autoload": {
"psr-4": {
"companyname\\extensionname\\": ""
}
}
}
.gitignore
vendor/**
models/Test.php
<?php
namespace companyname\extensionname\models;
class Test
{
}
And I've added the following to my Yii2 project composer.json:
"repositories": [
{
"type": "vcs",
"url": "ssh://git#bitbucket.org/companyname/yii2-extensionname",
}
],
Update
So I figured out that if I add my repo in this format it's found and downloaded, but the autoloader-psr4.php file is not updated with my autoloading.
"repositories": [
{
"type": "package",
"package": {
"name": "vendor/yii2-extension-name",
"version": "master",
"source": {
"type": "git",
"url": "git#bitbucket.org:vendor/yii2-extension-name",
"reference": "origin/master"
}
}
}
When I have
"repositories": [
{
"type": "git",
"url": "https://bitbucket.org/vendor/yii2-extension-name"
}
],
I get the following error:
Problem 1
- The requested package vendor/yii2-extension-name could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
There is no typos, its found and downloaded when I use "package". But then the autoloader is not updated.I've also tried all sorts of variations with git#, https and ssh. It always works as a package, never as a git or vcs.
Edit: oh, and minimum-stability is set to dev while troubleshooting.
You must use the correct name:
{
"name": "vendor/yii2-extension-name",
"type": "yii2-extension",
That is usually your Bitbucket username followed by the name of your repository.
That will work with your repositories Composer setting:
"repositories": [
{
"type": "git",
"url": "https://bitbucket.org/vendor/yii2-extension-name"
}
],
My project uses my own library which is in the private Mercurial repository placed on bitbucket.org. That library has no composer.json configured.
I try to make that library as a dependency to my project.
Firstly I wrote to composer.json the following strings:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type": "hg",
"url" : "https://bitbucket.org/myname/mylibname"
}
]
}
And running composer install I've got an error:
[RuntimeException]
Failed to clone https://bitbucket.org/myname/mylibname, could not read packages from it
abort: http authorization required
Than I changed "type": "hg" to "type": "vcs" and got another error:
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https:/***/mylibname, could not load a package from it.
After additional reading of documentation I added description of my library to the composer.json of my project, and it began to look so:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type": "vcs",
"url" : "https://bitbucket.org/myname/mylibname"
},
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"vcs",
"url":"https://bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
The same error occured:
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https:/***/mylibname, could not load a package from it.
I removed the part:
{
"type": "vcs",
"url" : "https://bitbucket.org/myname/mylibname"
},
and got an error:
[InvalidArgumentException]
Unknown downloader type: vcs. Available types: git, svn, hg, perforce, zip, rar, tar, gzip, phar, file.
I changed "type": "vcs" back to "type": "hg", composer.json looks like:
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"hg",
"url":"https://bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
and an error:
[RuntimeException]
Failed to execute hg clone 'https:/***/mylibname' '/path/to/myproject'
abort: http authorization required
The structure of my auth.json, which lies besides of composer.json is:
{
"http-basic": {
"bitbucket.org": {
"username": "myusername",
"password": "mypassword"
}
}
}
Seems like bitbucket-oauth method is buggy in the current state as of 1.1 of composer. This means that either you must have setup the SSH key on the client or if you are like me and cant setup keys because of deployment server, you will have to use basic auth.
The only way I got this working was:
~/.composer/auth.json
{
"http-basic": {
"bitbucket.org": {
"username": "bitbucketUsername",
"password": "PasswordToBitbucket"
}
}
}
composer.json
"repositories": [
{
"url": "https://username#bitbucket.org/username/my-package.git",
"type": "git"
}
],
"require": {
"username/my-package": "dev-master"
},
Composer as of version 1.2.0 have sorted this with bitbucket oauth, this is a much better method than ssh-keys if multiple developers are working on a project as the auth.json can stay within the project repository (if it's private) and only has to be setup once.
auth.json
{
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "key",
"consumer-secret": "secret"
}
}
}
composer.json
"repositories":[
{
"type": "vcs",
"url": "git#bitbucket.org:path/to.git"
}
]
Just remove https://. Works for me :)
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"hg",
"url":"bitbucket.org/myname/mylibname",
"reference":"dev"
}
}
}
]}
That didn't quite work for me, but it got me pointed into the right direction. Make sure you get your SSH key installed to access it via git#.
{
"repositories": [
{
"type": "package",
"package": {
"name": "myname/mylibname",
"version": "master",
"source": {
"type": "git",
"url": "git#bitbucket.org:myname/mylibname.git",
"reference": "master"
}
}
}
]
}
One comment on my end.
I have tested above scenarios I encountered on composer suggestion that repository needs to have at least one stable version.
https://getcomposer.org/doc/04-schema.md#minimum-stability
Due to this, I used "dev" TAG along with SSH connection and it works.
{
"require": {
"php": ">=5.4",
"myname/mylibname": "dev"
},
"repositories":[
{
"type":"package",
"package":{
"name":"myname/mylibname",
"version": "dev",
"source":{
"type":"git",
"url":"git#bitbucket.org:myname/mylibname.git",
"reference":"dev"
}
}
}
]}
I thought I had best contribute to the confusion and share what configuration worked for me. Firstly, I absolutely could not get the recommended setup from composer to work. However, the following did:
1.Edit ~.composer/auth.json and configure the http-basic key.
{
"bitbucket-oauth": {},
"github-oauth": {},
"gitlab-oauth": {},
"gitlab-token": {},
"http-basic": {
"bitbucket.org": {
"username": "USERNAME",
"password": "PASSWORD"
}
}
}
2.Use the following to define the package in your composer.json (i.e. private repository). Also bare in mind this is not a personal BitBucket account, I am a part of a team so the USERNAME#bitbucket.org is MY username and second instance is the company (https://{USERNAME}#bitbucket.org/{USERNAME||VENDOR}/{REPO}.git).
"require": {
"{USERNAME||VENDOR}/{REPO}": "dev-{BRANCH}
}
"repositories:" [
{
"type": "package",
"package": {
"name": "{USERNAME/VENDOR/REPO}",
"version": "master",
"source": {
"url":
"https://{URL}",
"type": "git",
"reference": "master"
}
}
}
]
Miscellaneous & noteworthy things to consider:
I did not use access keys
I do have my SSH key on BitBucket
I am an administrator on BitBucket
I am target the master branch
There are NO tags on the repository
Minimum stability is set to dev
You will need to add the autoload options to the package (see this)
I hope this helps anyone frustrated by this, it defintely seems as though everybody has issues. Thanks to #Tomasz Czechowski for providing the answer that eventually got this working for me!
Another example with bitbucket git repo using OAuth consumer authorization, which is actually working. Note that repo is starting with https, otherwise composer will fail with an error 'undefined offset: 1'.
auth.json
{
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "...",
"consumer-secret": "..."
}
}
}
composer.json
"repositories": [
{
"type": "git-bitbucket",
"url": "https://bitbucket.org/workspace/repo.git"
}
]
This should be an easy one. I developed a package call it MyVendor\MyPackage
inside MyVendor\MyPackage is:
MyVendor\MyPackage\composer.json
MyVendor\MyPackage\MyClass.php
The MyVendor\MyPackage\composer.json file contains:
{
"name":"MyVendor/MyPackage",
"description":"MyClass!!!",
"keywords": ["MyKeyword"],
"homepage": "http://MyPackage.com",
"type":"library",
"license": "MIT",
"authors": [
{
"name": "ME",
"email": "ME#ME.com",
"homepage":"http://ME.com"
}
],
"require": {
},
"autoload":{
"psr-4" : {
"MyVendor\\MyPackage\\":""
}
}
}
Now I have another project called MyOtherPackage whose composer.json file looks like:
{
"require": {
"monolog/monolog": "1.2.*",
"MyVendor/MyPackage": "1.0.0"
},
"autoload": {
"psr-4": {
"MyVendor\\MyOtherPackage\\": "MyOtherPackage/",
"MyVendor\\": "/"
}
},
"repositories": [
{
"type": "package",
"package": {
"name": "MyVendor/MyPackage",
"version": "1.0.0",
"source": {
"url": "https://ME.com/svn/MyVendor/MyPackage/",
"type": "svn",
"reference": "trunk"
}
}
}
]
}
So MyOtherPackage depends on MyPackage. Everything downloads just fine, but if I open up autload_namespaces.php it only includes monolog. It looks like this:
return array(
'Monolog' => array($vendorDir . '/monolog/monolog/src'),
);
Why isn't MyVendor/MyPackage appear in the namespaces.php or autoload_psr4.php file? Is the composer.json file wrong?
EDIT I added to the MyPackage composer.json file.
I've figured it out. It seems as if defining the repository as a package, I am telling composer that it isn't a composer compatible class, which means composer doesn't look for a composer.json file.
To fix it I removed the package definition and made the dependent class's composer.json file to look like:
{
"require": {
"monolog/monolog": "1.2.*",
"MyVendor/MyPackage": "1.0.0"
},
"autoload": {
"psr-4": {
"MyVendor\\MyOtherPackage\\": "MyOtherPackage/",
"MyVendor\\": "/"
}
},
"repositories": [
{
"type": "svn",
"url": "https://ME.com/svn/MyVendor/MyPackage/",
"reference": "tags"
}
]
}
This tells composer to download the package from this repository and look for the composer.json file.
You did not define any autoload mechanism in your first package. If you don't, Composer cannot know how to autoload the classes, and does nothing (which is a valid option if your package does not contain any PHP at all, but for example only images and javascript).
Add something like this:
"autoload": {
"psr-0": {
"MyVendor\\Namespace":"src/path"
}
}