I want to make a deploy but I can't. I don't know why.
I ran the composer install command to generate the lock file...
Error log:
ERROR: No 'composer.lock' found!
A 'composer.lock' file was not found in your project, but there
is a 'composer.json' file with dependencies inside 'require'.
The lock file is required in order to guarantee reliable and
reproducible installation of dependencies across platforms and
deploys. You must follow the Composer best practice of having
your lock file under version control in order to deploy. The
lock file must not be in your '.gitignore'.
My .gitignore:
/vendor
/.idea
Homestead.json
Homestead.yaml
I committed the file.
My last 3 commits (from git log --oneline):
19cb5e3 (HEAD -> demo) env update
2ce2333 added composer.lock
285922a Demo
Can you delete your vendor folder + composer.lock and then try to run composer install.
Related
I am working on an application with laravel 8, whenever I run composer update 5000+ vendor files are tracked by GitHub however /vendor is added into the .gitignore file. here is a snap of my .gitignore file:
Might be possible that you have already staged/added the vendor folder before putting in the .gitignore file. Or you have manually staged/added the folder to git through command.
In any case, one solution for you is to unstage the files by using
git reset /vendor/*
and if this doesn't solve your problem, then it might be possible that you already have committed older files into git; so, /vendor files are getting tracked by git.
Solution steps:
Delete the /vendor folder.
Make a clean commit of tracked files inside /vendor (if there are any)
Run composer install again to get back /vendor folder.
After these steps, vendor will not be tracked. (Considering /vendor/ is still present in the .gitignore file)
when I initialize a new project with composer I have this error in the terminal:
No lock file found. Updating dependencies instead of installing from
lock file. Use composer update over composer install if you do not
have a lock file.
Can someone explain to me?
composer update and composer install are similar in that they both download your dependencies, but are different in an important way.
The update command will retrieve the latest versions of all of your dependencies that meet your version constraints in your composer.json file. Next, it has to discover the exact versions to install of your dependencies, your dependencies’ dependencies, their dependencies, and so on all the way to the bottom. If it can’t find a set of versions that satisfy all constraints, the command exits with an error explaining what it can’t resolve and why. If all dependencies can be resolved, they will be downloaded into the vendor directory. Finally, a composer.lock file will be generated that has the exact versions and commits that were installed.
If a lock file is present and you run composer install, composer doesn’t have to do the dependency resolution because they’ve already been resolved. It downloads the exact version of each package from the lock file.
The message you received is telling you that your dependencies haven’t been resolved yet (by the update command), but running install will act like an update if there is no composer.lock file.
Making pull of Laravel 5 app from external branch I got several conflict errors like
error: refusing to lose untracked file at 'vendor/composer/autoload_static.php'
CONFLICT (modify/delete): vendor/composer/autoload_real.php deleted in HEAD and modified in b871903544566b6c1fd662ac67e7987f1ecc8643. Version b871903544566b6c1fd662ac67e7987f1ecc8643 of vendor/composer/autoload_real.php left in tree.
but in .gitignore file I have vendor directory:
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
composer.lock
package-lock.json
1.txt
I wonder why such errors and how to fix them?
I suppose there is no sense in manually editing files inside of /vendor ?
Thanks!
that's not a normal vendor package, it the autoload generated by composer.
Run this command to generate the file anew to fix the error.
compser dump-autoload
But what you really should do is to remove the autoload from your git:
delete the tracked file & commit the change
add it to the ignore list (it should be already ignored)
push
run command dump-autoload on every installation after pull
OR follow these instructions How to stop tracking and ignore changes to a file in Git? and the do step 4
When I add files to my local repository, some vendor packages are excluded even though they are not listed in the .gitignore file. Since they are not pushed to the remote repository, other developers are not able to pull the vendor packages.
The Vendors files are not to upload on github.The composer.json file of your laravel project have all the information to install all of your vendors.So try to update your composer.
To update composer use cmd or terminal command:
composer update
composer install
Be sure that the composer.json file is not ignore by .gitignore file.
Fixing the root .gitignore is not enough.
I had the same problem and found out that there are multiple .gitignore in subfolders.
My workflow for developing Symfony bundles is the following:
install Symfony
create a git repo for the new bundle, put a composer.json file in there
require the new package in the top-level composer.json, using #dev version
composer update newpackage => the package is downloaded, using git clone
work on the git clone inside vendors, committing and pushing from it
This is all fine and dandy, but seems to break in one specific case:
if I alter the 'autoload' tag of the already-installed package, it seems that Composer has a hard time taking it into account:
I tried 'composer dumpautoload', and it does nothing
I do not want to remove the composer.lock file, as I do not want other packages to be updated to a newer version, I only want to alter the autoload config of that one package
I tried removing by hand vendor/composer/installed.json, and what happened is that Composer re-downloaded all the vendors and wiped any data which happened to be in there at that moment
The same problem manifested itself when I did alter the autoload section of the package on a separate clone, pushed the changes to git and ran 'composer update mypackage' - although that might have been related to packagist not having received the ping from github.
I can of course alter by hand the composer.lock and vendor/composer/installed.json files, but that seems too hackish. It also does not gives the guarantee that user downloading the package the 1st time will see it working.
Try:
./composer.phar dumpautoload -o
It reads the composer.json files and rewrites all the autoload files which pick up the new paths.
dumpautoload uses the package information from vendor/composer/installed.json and not the individual composer.json files. You need to change the autoload info there, too.
The file installed.json is only being update when you run a
composer update