Can we eject back to Managed Workflow from the bare workflow?

I was initially working in the managed workflow and then ejected to the Bare workflow, just to understand and explore it better. I could dive into the Android and iOS folders, etc…
But now I want to get back to the Managed workflow. How do I do that?
I tried the expo eject command but it happened to eject me back to the Bare workflow. How do I switch back to the managed workflow?
Thanks.

you can revert the change if you’re using git - this is why we warn you to commit before running eject :slight_smile: otherwise, rm -rf ios android and npm uninstall react-native-unimodules

2 Likes

Let’s say the project was ejected a year ago, & now I want to revert back after many changes just deleting the android & ios folder & uninstalling react-native-unimodules take us back to managed workflow?

I am ok if I lose OTA, and expo builds service.

Yes, as long as there’s no native code you need to keep, that should be fine and you will not have to give up OTA or Expo’s build service :slight_smile:

Fortunately, these days with EAS Build you can even still make use of custom native code that’s not included in Expo! Sometimes you’ll need a config plugin to make it work.

But I would suggest creating a new project using expo init and comparing all of the config files etc. with your app to see if there’s anything else that it makes sense to change.

And of course this is safe to try, because you just need to make sure that everything is committed in Git before you uneject. Then if anything goes wrong you can get back to where you are now and try again.

1 Like

Hi @wodin - I’ve inadvertently ejected from my managed project using expo prebuild then run eas build for the first time as I wanted to try the new service but the process has failed.

I’ve noticed that I have now 3 more files - android, ios, .gitignore - can I go back to managed workflow by simply deleting those 3 directories and run a new classic or eas build?

I don’t think I’ve committed anything yet as my build failed.

Cheers

I sometimes run expo prebuild if I want to check the results of a config plugin. After that I run git status to see what files/directories have been added or changed. (I’m using yarn, so I have yarn.lock. If you’re using npm you’ll see package-lock.json instead of yarn.lock).

% git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .gitignore
	modified:   package.json
	modified:   yarn.lock

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	android/
	index.js
	ios/
	metro.config.js

no changes added to commit (use "git add" and/or "git commit -a")

Then I run git checkout -- .gitignore package.json yarn.lock to revert the changes to those files and I delete the other files/directories.

Well, I didn’t realised but I have a bit of a messy situation, and yes I’m using npm and I have package-lock.json

In my status I have:

  • Changes to be committed (both new file and modified)
  • Changes not staged for commit (new file, modified and deleted)
  • Untracked files

Note: files like App.js are showing in both Changes to be committed and Changes not staged for commit

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   .expo-shared/README.md
	modified:   App.js
	modified:   app.json
    modified:   assets/splash.png
	new file:   cocktail/Sazerac/Sazerac.xcodeproj/project.pbxproj
	new file:   cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/contents.xcworkspacedata
	new file:   cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
	new file:   cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/xcuserdata/maxaquilino.xcuserdatad/UserInterfaceState.xcuserstate
	new file:   cocktail/Sazerac/Sazerac.xcodeproj/xcuserdata/maxaquilino.xcuserdatad/xcschemes/xcschememanagement.plist
	new file:   cocktail/Sazerac/Sazerac/AppDelegate.h
	new file:   cocktail/Sazerac/Sazerac/AppDelegate.m
    new file:   navigation/SwitchNavigator.js
	modified:   package-lock.json
	modified:   package.json
    new file:   util/GoogleService-Info.plist
	new file:   util/firebase.js
	new file:   util/google-services.json
    ... more files

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .expo-shared/assets.json
	modified:   .gitignore
	modified:   App.js
	new file:   android/app/eas-build.gradle
	modified:   app.json
    deleted:    cocktail/Sazerac/Sazerac.xcodeproj/project.pbxproj
	deleted:    cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/contents.xcworkspacedata
	deleted:    cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
	deleted:    cocktail/Sazerac/Sazerac.xcodeproj/project.xcworkspace/xcuserdata/maxaquilino.xcuserdatad/UserInterfaceState.xcuserstate
	deleted:    cocktail/Sazerac/Sazerac.xcodeproj/xcuserdata/maxaquilino.xcuserdatad/xcschemes/xcschememanagement.plist
	deleted:    cocktail/Sazerac/Sazerac/AppDelegate.h
	deleted:    cocktail/Sazerac/Sazerac/AppDelegate.m
    deleted:    cocktail/cocktail.xcodeproj/project.pbxproj
	deleted:    cocktail/cocktail.xcodeproj/project.xcworkspace/contents.xcworkspacedata
	deleted:    cocktail/cocktail.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
	deleted:    cocktail/cocktail.xcodeproj/project.xcworkspace/xcuserdata/maxaquilino.xcuserdatad/UserInterfaceState.xcuserstate
	deleted:    cocktail/cocktail.xcodeproj/xcuserdata/maxaquilino.xcuserdatad/xcschemes/xcschememanagement.plist
	deleted:    cocktail/cocktail/AppDelegate.h
	deleted:    cocktail/cocktail/AppDelegate.m
    new file:   eas.json
    modified:   package-lock.json
	modified:   package.json

    ... more files

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	GoogleService-Info.plist
	google-services.json
	helpers/reviews.js
	i18n/bartenders.json
	index.js
	metro.config.js
    ... more files

Shall I run what you suggested git checkout -- .gitignore package.json package-lock.json and delete android, ios, .gitignore

I did a backup of this project a couple of days ago prior to start the eas build, just in case.

hmmm… I’m not sure. You have some native code in the cocktail directory. I don’t know how that fits in.

Maybe do this:

Create a new app that you use to compare things like app.json, package.json, etc. with your real app.
Create another new app and run expo prebuild in it to see what changes are made by expo prebuild.

By comparing those to your app, work out how to revert the prebuild changes.

After that you will need to sort out whatever’s going on with cocktail and your other changes :slight_smile:

The cocktail directory can be ignored as it was created by Xcode after I run expo prebuild. There is nothing in there that I’ve added myself, no native code. I guess if I move back to managed I would not need that directory and Expo will ignore it.

Do you reckon I can follow your approach and run git checkout -- .gitignore package.json package-lock.json? Worse case scenario I still have previous version of my project in other environments.

cheers

Yes, if it’s created during prebuild then it will be created on the build server when you run eas build.

Yes, I think you’re right. Worst case is you have to re-install a dependency or two that you forgot you’d installed since running expo prebuild :wink: