Composer error: UnexpectedValueException - php

My composer suddenly stopped working. I didn't even add new packages, just wanted to check, if there are any updates:
PS C:\data\www\project.dev> composer self-update
You are already using composer version 1.3.2 (stable channel).
PS C:\data\www\project.dev> composer update
> php artisan clear-compiled
The compiled class file has been removed.
Loading composer repositories with package information
Updating dependencies (including require-dev)
[UnexpectedValueException]
Could not parse version constraint >=~2: Invalid version string "~2"
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]...
All solutions I found so far suggested to update composer and check the composer.json, but there shouldn't nu anything wrong in there:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.3.*",
"edofre/laravel-fullcalendar-scheduler": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "5.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
As you can see, there is nothing special in there.
PS: Of course, I already chkecked this and this, but those are unrelated problems.

EDIT:
The Problem is fixed in the 1.3.0#dev version of the composer-asset-plugin.
It can be installed via:
composer global require fxp/composer-asset-plugin:~1.3#dev
See also: https://github.com/fxpio/composer-asset-plugin/issues/270
I have tracked down your problem using the verbose output of composer.
The problem is initially caused by requiring
"edofre/laravel-fullcalendar-scheduler": "^1.0"
Within this some bower packages are required ( For this I assume you installed Composer Asset Plugin -at least I had to do this as stated in the docs of laravel-fullcalendar-scheduler)
One of these bower packages is for example:
"bower-asset/fullcalendar-scheduler": "v1.4.0"
The Bower fullcalender-schedulare has some dependencies ( in bower.json):
"dependencies": {
"jquery": "2 - 3",
"moment": "^2.9.0",
"fullcalendar": "~3.2.0"
},
The used composer asset plugin translates the jquery dependency to:
">=~2,<4.0"
This finally causes the error in the composer module https://github.com/composer/semver which raises an error composer/semver/src/VersionParser.php:485
For testing i have manually changed the version to >=2.0 which is working.
I currently have not investigated wheter this is a bug in the composer/semver lib or a bug in the composer asset plugin.
The composer docs say that ~2 is a valid version number, but I don't know if it is supposed to be used in comparisons like ">~2" ( in my oppionion this makes no sense at all... )

Related

Laravel 5.2 Heroku Deployment Failed to install system packages

I am trying to deploy Laravel 5.2 project to heroku but I am getting the following error
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
! ERROR: Failed to install system packages.
Your platform requirements (for runtimes and extensions) could
not be resolved to an installable set of dependencies, or a
repository was unreachable.
Full error information from installation attempt:
> Loading repositories with available runtimes and extensions
>
> Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
> Nothing to install or update
> Generating autoload files
Please verify that all requirements for runtime versions in
'composer.lock' are compatible with the list below, and ensure
all required extensions are available for the desired runtimes.
For reference, the following runtimes are currently available:
PHP: 7.1.10, 7.1.9, 7.1.8, 7.1.3, 7.1.2, 7.1.1, 7.0.24,
7.0.23, 7.0.22, 7.0.17, 7.0.16, 7.0.15, 5.6.31, 5.6.30,
5.5.38
HHVM: 3.5.1
For a list of supported runtimes & extensions on Heroku, please
refer to: https://devcenter.heroku.com/articles/php-support
! Push rejected, failed to compile PHP app.
! Push failed
This is my composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"barryvdh/laravel-ide-helper": "^2.1",
"components/jquery": "2.1.4",
"components/jqueryui": "1.11.4",
"kodeine/laravel-acl": "^0.1.3",
"laravelcollective/html": "5.2.*"
},
"require-dev": {
"symfony/dom-crawler": "~3.0",
"symfony/css-selector": "~3.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I ran have tried to deploy about a couple of dozens time after using composer install, composer update, composer update --lock and I even deleted the composer.lock file and ran composer update again but this error is not going anywhere. Please help!
It turned out that my vendor folder was not listed in .gitignore files and it was being pushed along with the other files on heroku. Once I added the vendor folder to .gitignore everything started working seamlessly.

composer update failed Your requirements could not be resolved to an installable set of packages

I have this composer file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "4.2.*",
"guzzlehttp/guzzle": "~4.0",
"zizaco/confide": "~4.0#dev",
"zizaco/entrust": "1.2.*#dev",
"way/generators": "~2.0",
"zurb/foundation": "5.0.3",
"artdarek/oauth-4-laravel": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "4.4.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
when I run
composer update
I got this error
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for artdarek/oauth-4-laravel dev-master -> satisfiable by artdarek/oauth-4-laravel[dev-master].
- artdarek/oauth-4-laravel dev-master requires lusitanian/oauth dev-master -> satisfiable by
lusitanian/oauth[dev-master] but these conflict with your requirements
or minimum-stability.
I beleive that the error is in artdarek/oauth-4-laravel but I don't know how to reslove it, any help please?
I found this page [Composer fails when installing a dependency of a dependency, but not when the dependency is installed directly][1] helpful and it fixes my problem, I have changed
"artdarek/oauth-4-laravel": "dev-master"
to
"artdarek/oauth-4-laravel": "#dev"
Does anyone know what is the difference?
Try adding "lusitanian/oauth" : "dev-master" to the require list.
FYI, it is better to use specific versions since you are seeking stability :)

Laravel - can't install from my source control

I need to automate my laravel project setup/upgrade on my production machine from source control.
I wrote a bash script to clone the source from the GIT repo and run the setup.
The git code is going to the folder /var/www/prod/mainapp/, so the following bash code is running after the git command:
cd /var/www/prod/mainapp/app/
composer install # composer update will not work as well
php artisan dump-autoload
php artisan optimize
I am getting the following error when the code reaches to: php artisan optimize
PHP Fatal error: Class 'App\Providers\SocialUserProvider' not found in /var/www/prod/mainapp/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
in my app.php i have the following providers:
App\Providers\FacebookGraphProvider::class,
Torann\GeoIP\GeoIPServiceProvider::class,
App\Providers\SocialUserProvider::class,
this is my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"torann/geoip": "0.2.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database",
"app/Facades",
"app/Services"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
You need to add to the classmap the line that will tell who should be autoloaded. app/Providers
"classmap": [
"database",
"app/Facades",
"app/Services",
"app/Providers" //this is the missing part.
]
I've come across this a few times.
My workaround is to run
composer install --no-scripts
You are getting that error due to the pre install scripts in your composer.json file and by adding that flag to the install process you skip these scripts.
Once you have everything installed you can then just use composer install and composer update as you usually would.

Deployment on Laravel Forge throwing faker not found Exception

I am trying to deploy a laravel project on forge and i am getting the below exception :
Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Faker\Factory' not found
I have the faker reference in require-dev in composer.json!
composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"tymon/jwt-auth": "0.5.*",
"dingo/api": "1.0.x#dev"
},
"require-dev": {
"fzaninotto/faker": "~1.5",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"laracasts/testdummy": "1.*",
"laracasts/generators": "^1.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
Deployment script in Forge:
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan db:seed --class="StaticDataSeeder"
I was able to deploy the same project locally with out any problem and composer update on forge also runs successfully and i can see the faker package getting downloaded.
Please let me know if i am missing something.
There is a clear conflict that explains your problem:
You've added the "fzaninotto/faker" package to the require-dev section.
You're running the deployment composer install command with the --no-dev option which explicitly prohibits installing the packages listed in require-dev.
So the solution is either to move the package to the require section or remove the --no-dev option when deploying.
I have same problem on heroku deployment i think it same, i fix with
moving "fzaninotto/faker": "~1.4" from "require-dev" to "require" in composer.json and composer.lock
composer install
composer update
git add
git commit
git push heroku
if you don't use heroku as deployment don't run from step 4-6
Run the next command:
composer install
And the problem should go away

Composer is not copying on the specified bin-dir directory

I had this issue sometimes, on windows, on mac, on ubuntu...
I have this composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"zizaco/confide": "~4.0#dev",
"zizaco/entrust": "1.2.*#dev",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "4.1.4",
"behat/behat": "3.0.12",
"behat/mink": "1.5.0",
"behat/mink-extension": "2.0.0",
"behat/mink-goutte-driver": "1.0.9",
"codeception/verify": "0.2.7",
"codeception/specify": "0.3.6"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"bin-dir": "bin/",
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
This is Laravel 4 with a few testing packages.
After a composer install or a composer update the directory "bin" is not created on my project.
I should have one binary for phpunit and another for behat. So i have to use the commands like vendor/behat/bin/behat and vendor/phpunit/phpunit/phpunit which is a pain.
Any idea why the binaries are not on the "bin" folder?
Yesterday, the some project with less packages, I had the binary folder there with the phpunit binary. Now is gone. I don't get it.
This happened to me today as well. While I haven't yet figured out why it happens, a dirty workaround is to remove vendor folder and run composer install.
I've found this pull request in composer's git repo:
https://github.com/composer/composer/pull/5127
It seems that the feature of recreating the binaries, will get released in Composer 1.1

Categories