I have a website hosted and I want to use composer to resolve my project dependencies on production. But everytime I run composer update I get this error:
$
[RuntimeException]
Failed to execute git status --porcelain --untracked-files=no
error: unknown option `porcelain'
I got the conclusion: git's version on host is too old and it cant recognize --porcelain option.
So, I need update git on host but for what version? What is it the minimum version I can update git to run composer without any issue?
The --porcelain option has been added to git status in git 1.7.0-rc0, commit 6f15787 in September 2009.
So you need at least a git 1.7+.
Related
I have been writing laravel code for quite sometime. Currently, I tried cloning a project from github and editing locally. I installed composer in my project directory but a vendor folder was not included, I tried to run composer install but I gives me this error
Your lock file does not contain a compatible set of packages. Please run composer update
How do I resolve this?
Note: I have tried running composer update on previous clones and that didn't work.
Run this command:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
Disclaimer, this solution will not fix the issue for PHP 8 projects.
In most cases this happens because of PHP 8 (In my case it was GitHub CI actions automatically started using PHP 8 even though my project is php 7.4)
If you have multiple PHP installations (E.g. 7.4 and 8 on the same server), this is how you can fix it.
Specify your php version in your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
If you have the lock file already committed, run composer update after you adding above line in to the composer.json and then commit the new lock file. (Please be aware composer update will upgrade your packages to latest versions)
I solved this problem with this command:
composer self-update --1
It probably works because at time that the project was developed, composer was on another version and when change the Major version from 1 to 2 the compatibility was broke. With this command you downgrade composer and probably going to solve this
You should try running composer update --lock that will update all packages and recreate the compose.lock file.
Either you can delete the composer.lock file and run composer install that will also recreate the .lock file.
This resolved my issue.
I had this error with Github Actions trying to deploy a Laravel app, this is probably different than the OP's case but none of the suggestions worked for me. Adding my answer here just in case there is someone else out there with a similar problem to mine.
I had to disable -q in Github Actions and see that it was complaining about extensions not being installed.
Make sure your require section of composer's php extensions matches the extensions: in your github action file for shivammathur/setup-php#v2 and it will deploy again
Recently I've just come across of this error when I tried to run my Laravel 7 project which required php v7.* with php v8. As I forgot my php version I just tried bunch of composer command, but just got error after error.
Anyway, to solve this just downgrade/upgrade php version as required. Just search how to do that in youtube.
you can see your project required php version in composer.json file (just if you wonder)
Also you can try following way (But though it didn't worked for me, seems it helped quite some people)
-- Open composer.json file and change php version to something like this: "php": "^7.3|^8.1"
-- Then run composer update
I faced this problem with my cakephp project in garuda linux (arch based)
Fix :
Install php-intl using sudo pacman -S php-intl
Enable php intl by editing php config ( in my case /etc/php/php.ini ) .
add extension=intl or uncomment the existing one
restart apache or whatever you are using
I had the same error deploying another project with composer, but the problem was a missing php extension.
I understand you solve your problem but for anyone seeing the same error message, here is a general guidance :
The error message Your lock file does not contain a compatible set of packages. Please run composer update is shown each time there is a conflict during the dependency solving step of composer install. (see the relevant part in composer source code)
It doesn't inform on the real problem though, and it could be hard to guess.
To get the exact explanation you can add --verbose option to composer install command (the option is available to any composer command (see the doc)) : composer install --verbose
It will give you the full message explaining what exactly is preventing composer install from completing (package version conflict, missing php extension, etc.), then you'll be able to fix the problem.
Hope this could help.
In my case this problem is occuring in Ubuntu 20.04 Desktop. This is due to some missing packages.
I ran the following commands to install some packages then rerun Composer install and its working properly. The commands are:
sudo apt-get install php-mbstring
sudo apt-get install php-xml
Then rerun composer install
In my composer.json I have
"require": {
. . .
"unisharp/laravel-filemanager": "~1.8"
}
Currently, the latest version is v1.8.2.2 and after running the composer update command I have it installed on my localhost project (everything is OK).
I have pushed (git push origin master) from localhost to the remote repo on Bitbucket, and via SSH I have connected to the web server and cloned (git clone ...) it from that remote repo.
Now, when I run composer update (on web server) - it installs v1.8.0 which has some bug. After that, when I try again to run composer update - I get:
Nothing to install or update
... but it's still v1.8.0 (not v1.8.2.2 like it is on localhost).
So, I have identical project with identical composer.json on my localhost and on live server but, for some reason, localhost has the latest version of the package and live version has the old version with bug and composer update doesn't update it.
Do you know why this is happening and how can I solve it?
You should run composer update locally. This will update composer.lock with the versions of all the packages you have installed. You should commit your composer.lock file to your version control.
On your server, once you've updated your files you should then run a composer install so Composer can update its dependencies to match those specified in your composer.lock file.
I just spent two hours debugging this. Turns out the problem was that there was a "version" tag in the composer.json file.
When there is a version tag there, that version will be used in priority above any git tag version that you apply.
I need to discus a very important thing for me (probably for all users who uses composer in their projects). I am working on laravel. Whenever i work on my local machine, i run composer update after adding new library in vendor.
Now it works fine on local machine. But when i upload these files on my server, it shoots error like "Undefine class ....". I dont know how to run composer update command on server (Also it might be not safe).
So may i just know which files are updated by using composer update on cmd. What other files needed to go live to avoid this error??
You may:
Run composer update on your local server only, whenever you want.
Commit/push every files (including composer.lock) but the vendor directory
Deliver to your production server (without vendor, with composer.lock)
Then run composer install on your production server. It will update all your dependencies according to your composer.lock(so the exact same versions as your last update on your local server).
So in other words: you should not run composer update on your server, just composer install on every delivery (and you will need to keep your composer.lock)
Hope it will help you.
run composer dump-autoload before composer update. If still doesn't work then try to clear composer cache using composer clear-cache
composer update will update the version of every package from you vendor folder.
normally if you can not ensure you need update all the version of every package, you should use composer install
the reason of error "undefined class" is normally caused from app.php.Because service provider is defined in app.php, but the class(package) not been installed.
in order to solve your problem, try do this in three ways:
composer install --no-scripts;
comment the service providers which not been installed already from app.php, then composer install
composer dump-autoload
I'm not able to download lavarvel installer using composer 1.2.0 (latest version)
The error received: Failed to open stream: HTTP request failed!
I googled and could not find the answer to fix this to problem.
If possible, someone please try to run this command composer global require "laravel/installer" to check if it works? I think the link to packaglist is no longer valid but I'm not sure.
C:\wamp\www\st>composer self-update -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file C:\Users\Louis\AppData\Local\Temp\composer-cacert-bcf331364fef73d53e4368ba519a6c3fcb21ea7836c3d8efad4ec32731e8152a.pem: valid
Executing command (C:\wamp\www\st): git branch --no-color --no-abbrev -v
Executing command (C:\wamp\www\st): git describe --exact-match --tags
Executing command (C:\wamp\www\st): git log --pretty="%H" -n1 HEAD
Reading C:/Users/Louis/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/Louis/AppData/Roaming/Composer/composer.json
Running 1.2.0 (2016-07-19 01:28:52) with PHP 5.5.12 on Windows NT / 6.2
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Downloading https://getcomposer.org/versions
You are already using composer version 1.2.0 (stable channel).
Two ways of laravel install(normally i follow step 1)
step 1.
download zip file from github https://github.com/laravel/laravel
and unzip and put it on wamp/www(where you normally put your project)
wamp>www>folderproject>shift+right click>open command window
here> write on composer composer install
step 2.
go to wamp>www>hold shift and click right mouse ->open command window here->paste composer create-project laravel/laravel in command prompt
then go to laravel project then shift+ right click ,open command window here>write php artisan serve
Config Laravel
• after install laravel then goes to wamp>www>laravelproject
• copy from here .env.example ,and paste it here then .env - Copy.example will create,
• then open sublime ,go to .env - Copy.example file right click and rename to .env and enter
• then goes to wamp>www>laravelproject ,shift+right click ,write php artisan key:generate in command promt
I figured it out this morning. The problem was Kaspersky Internet Security blocked the connection between my PC and packagist.org . I am surprised that it never happened to anyone but me.
*** Solution:
- Disable your antivirus for a momment and run the command installing Laravel.
Thank you all.
Hey i guess you using php 5.5 first upgrade your php version then install use
composer global require "laravel/installer"
if you don't want upgrade your php then
use
composer global require "laravel/installer=~1.1"
I believe your problem is that the config.json-file for Composer has ""packagist": false" inside the file. Try opening the file and changing to : true"
Or run,
cd ~/.composer/vendor/bin
Then
composer global require "laravel/installer"
you can easily first disable your antivirus , then check your version of php that you are using make sure that it is above PHP VERSION 5.5 then open your terminal or cmd then go to directory of composer then paste `composer global require "laravel/installer"
I create a JSON file called composer.json with
{
"require":{"php-activerecord/php-activerecord": "dev-master"}
}
I then go to the folder in Terminal and type: composer install
I receive this fail message:
[RuntimeException]
Failed to clone https://github.com/kla/php-activerecord.git, git was not found, check that it is installed a
nd in your PATH env.
sh: git: command not found
I have no idea what to do. Any help would be great.
Your system does not find the command line command git.
Your options:
Install git for the command line.
Don't install "dev-master" of that library, but a tagged version instead.
The first one will make it work in general. The second one will avoid using git to download the source code, but a ZIP file of that version.