Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native failed to upgrade : fatal: working tree '.' already exists

I tried to upgrade react native version from 0.41 to 0.44 using these instructions, but I got this error :

error Command failed.
Exit code: 128
Command: git
Arguments: clone https://github.com/lwansbrough/react-native-camera.git /Users/abdelnacer/Library/Caches/Yarn/v1/.tmp/264e7f98ae7b8a32797877705f218964
Directory: /Users/abdelnacer/work/react/DuluxTradePoints
Output:
fatal: working tree '.' already exists.
git-upgrade ERR! An error occurred during upgrade: 
git-upgrade ERR! Error: Command 'yarn add [email protected]' exited with code 1:
stderr: undefinederror Command failed.
Exit code: 128
Command: git
Arguments: clone https://github.com/lwansbrough/react-native-camera.git /Users/abdelnacer/Library/Caches/Yarn/v1/.tmp/264e7f98ae7b8a32797877705f218964
Directory: /Users/abdelnacer/work/react/DuluxTradePoints
Output:
fatal: working tree '.' already exists.

stdout: yarn add v0.24.5
[1/4] Resolving packages...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

    at ChildProcess.child.on.code (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:58:18)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) 
git-upgrade ERR! Restore initial sources 
Note: checking out 'project-snapshot'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 4c8828d... Project snapshot

May be someone have any ideas what I'm doing wrong?

like image 644
Abdennacer Lachiheb Avatar asked Nov 20 '25 01:11

Abdennacer Lachiheb


2 Answers

I tried several yarn + react-native-git-upgrade but it didn't work for me

To make the upgrade work I had to remove the node_modules and clean the yarn cache too.

1) Remove node_modules:

rm -rf ./node_modules

2) Clean yarn cache

rm -rf /Users/<myUsername>/Library/Caches/Yarn/v1/.tmp

yarn cache clean 

I am not sure if it would have worked with running just the removal of .tmp

3) Run yarn

4) Run upgrade again

react-native-git-upgrade

Note: My upgrade was from 0.51.0 to 0.53.3

like image 197
Florin Dobre Avatar answered Nov 22 '25 15:11

Florin Dobre


facing the same issue,

try to run

yarn

then

react-native-git-upgrade

or

it might help you :

https://github.com/facebook/react-native/issues/11578#issuecomment-278022460

like image 28
Muhammad Shaharyar Avatar answered Nov 22 '25 17:11

Muhammad Shaharyar