I discovered a strange behaviour when deploying Symfony Flex applications on Windows using Git and Composer. Somehow the line endings in symfony.lock are changing during composer install. Maybe someone can give me a hint what I'm doing wrong or what I can do better.
The Environment:
- Windows based development machine
- Windows based production sever
- Git configured with
core.autocrlf=true on both machines
Steps to reproduce:
-
Create a new project on dev
composer create-project symfony/skeleton demo
symfony.lock is created using LF charater as line endings ✔️
-
Add everything to Git
cd demo
git init
git add -A
-
A warning is displayed but symfony.lock still has LF line endings in working copy ✔️
warning: LF will be replaced by CRLF in symfony.lock.
The file will have its original line endings in your working directory.
-
Commit & Push
git commit -m "init"
git remote add origin https://...
git push -u origin master
-
Clone project on prod machine
git clone https://... demo
symfony.lock now has CRLF line endings (because of core.autocrlf=true) ✔️
-
Check status
cd demo
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
-
Install project
composer install
symfony.lock now has LF line endings ❓
-
check status again
git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
no changes added to commit (use "git add" and/or "git commit -a")
So my question is why is symfony.lock updated during composer install? Is that an expected behaviour? I thougth it should be read-only during install just like composer.lock?
Everytime I update my project on production I will have to revert the changes to symfony.lock before I can do a git pull. Thats not very intuitive.
I discovered a strange behaviour when deploying Symfony Flex applications on Windows using Git and Composer. Somehow the line endings in
symfony.lockare changing duringcomposer install. Maybe someone can give me a hint what I'm doing wrong or what I can do better.The Environment:
core.autocrlf=trueon both machinesSteps to reproduce:
Create a new project on dev
composer create-project symfony/skeleton demosymfony.lockis created usingLFcharater as line endings ✔️Add everything to Git
cd demogit initgit add -AA warning is displayed but
symfony.lockstill hasLFline endings in working copy ✔️Commit & Push
git commit -m "init"git remote add origin https://...git push -u origin masterClone project on prod machine
git clone https://... demosymfony.locknow hasCRLFline endings (because ofcore.autocrlf=true) ✔️Check status
cd demogit statusInstall project
composer installsymfony.locknow hasLFline endings ❓check status again
git statusSo my question is why is
symfony.lockupdated duringcomposer install? Is that an expected behaviour? I thougth it should be read-only during install just likecomposer.lock?Everytime I update my project on production I will have to revert the changes to
symfony.lockbefore I can do agit pull. Thats not very intuitive.