Sourcetree won't load
Asked by Will Koegelenberg:

I've been using SourceTree for months and this morning it won't load. The splash screen comes up and the disappears. I checked the log and the following error was logged with every attempt at launching it:

ERROR \[2019-05-09 09:17:39,903\] \[1\] \[Sourcetree.Composition.VSMef.Net471.VSMefCompositionManager\] \[Log\] - Unable to load MEF components  
System.InvalidOperationException: Sequence contains no elements  
at System.Linq.Enumerable.First\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.PartDiscovery.GetElementTypeFromMany(Type type)  
at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_ImportingSiteTypeWithoutCollection()  
at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_IsLazy()  
at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_LazyFactory()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.SatisfyImports()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.SatisfyImmediateImports()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.\<\>c__DisplayClass15_0.\<GetExportedValueHelper\>b__0()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func\`3 lazyFactory)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.\<CreateValue\>b__10_0(RuntimeImport import)  
at System.Linq.Enumerable.WhereSelectArrayIterator\`2.MoveNext()  
at System.Linq.Buffer\`1..ctor(IEnumerable\`1 source)  
at System.Linq.Enumerable.ToArray\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.\<\>c__DisplayClass15_0.\<GetExportedValueHelper\>b__0()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func\`3 lazyFactory)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.\<CreateValue\>b__10_0(RuntimeImport import)  
at System.Linq.Enumerable.WhereSelectArrayIterator\`2.MoveNext()  
at System.Linq.Buffer\`1..ctor(IEnumerable\`1 source)  
at System.Linq.Enumerable.ToArray\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.\<\>c__DisplayClass15_0.\<GetExportedValueHelper\>b__0()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func\`3 lazyFactory)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.\<CreateValue\>b__10_0(RuntimeImport import)  
at System.Linq.Enumerable.WhereSelectArrayIterator\`2.MoveNext()  
at System.Linq.Buffer\`1..ctor(IEnumerable\`1 source)  
at System.Linq.Enumerable.ToArray\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.\<\>c__DisplayClass15_0.\<GetExportedValueHelper\>b__0()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func\`3 lazyFactory)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.\<CreateValue\>b__10_0(RuntimeImport import)  
at System.Linq.Enumerable.WhereSelectArrayIterator\`2.MoveNext()  
at System.Linq.Buffer\`1..ctor(IEnumerable\`1 source)  
at System.Linq.Enumerable.ToArray\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.\<\>c__DisplayClass15_0.\<GetExportedValueHelper\>b__0()  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func\`3 lazyFactory)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.\<CreateValue\>b__10_0(RuntimeImport import)  
at System.Linq.Enumerable.WhereSelectArrayIterator\`2.MoveNext()  
at System.Linq.Buffer\`1..ctor(IEnumerable\`1 source)  
at System.Linq.Enumerable.ToArray\[TSource\](IEnumerable\`1 source)  
at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)  
at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()  
at System.Lazy\`1.CreateValue()  
at System.Lazy\`1.LazyInitValue()  
at Microsoft.VisualStudio.Composition.NetFxAdapters.MefV1ExportProvider.\<\>c__DisplayClass12_0.\<UnwrapExport\>b__1()  
at System.ComponentModel.Composition.Primitives.Export.get_Value()  
at System.ComponentModel.Composition.ReflectionModel.ImportingItem.Cast(Type type, Export export)  
at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportingItem item, Export\[\] exports)  
at System.ComponentModel.Composition.Hosting.ImportEngine.PartManager.TrySetImport(ImportDefinition import, Export\[\] exports)  
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable\`1 imports, AtomicComposition atomicComposition)  
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)  
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)  
at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)  
at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)  
at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)  
at Sourcetree.Composition.VSMef.Net471.VSMefCompositionManager.\<Compose\>d__5.MoveNext()


Answers:
author: Jonathan Folland
body: I deleted file "\\AppData\\Local\\Atlassian\\SourceTree.exe_Url_lt03l1ybxwq1qoho5ydpzegbicen0mbc\\3.4.11.0\\Composition.cache"  

This resolved the issue for me and so far I have not seen any issues.

comments: author: David Smith
body: This is the perfect fix!

For those who stumble across this with the same issue.

<br />

<br />

Last night I left my laptop on stand by with Sourcetree and Visual Studio open.

Windows decided to do a security update overnight so Sourcetree showed this exact issue in the morning.

I reversed the update but the corruption of the cache remained. Removing this file and relaunching the software resolved my issue as it rebuilt the cache with the new information.

I have logged a complaint with Microsoft as this looks like a .NET/Visual Studio issue caused by the changes in their update.  

Thank you for the help Jonathan, absolute lifesaver!  


author: Mauro Bertoli
body: [@Jonathan Folland](/t5/user/viewprofilepage/user-id/349261) thank you, life saver, it did work form me too. The same problem happened after a Windows 11 update. After the update and the reboot, Sourcetree 3.4.13 just shown his splash screen and then crashed.

To help others, you can just rename the file without deleting it.

Be aware that you need to find the folder with your current/latest version (as you can have many similar folders with different IDs) and rename \`Composition.cache\` to \`_Composition.cache\` and then start Sourcetree. A new \`Composition.cache\` file will appear.

Out of curiosity, I did compare the two (binary) files, and found out that the only change was related to the \`Sourcetree\` folder renamed in \`SourceTree\` ?  
Ex:  
before =\> C:/Users/\[user\]/AppData/Local/Sourcetree/app-3.4.13/

after =\> C:/Users/\[user\]/AppData/Local/SourceTree/app-3.4.13/


author: David Brady
body: Thank you! Same thing happened to me. Windows 11 updated and then Sourcetree wouldn't load. And deleting the cache file fixed it.


author: Matthew Sweeney
body: This worked for me, after Windows Update apparently screwed up Sourcetree.


author: Andr?s Rosero T.
body: Same for me, the new Windows 11 update crashed my SourceTree installation. I deleted the cache file, and now it works again! Thanks a lot! :-)


author: Denis Birnie
body: Happened on Windows 10 too - so suspecting this month's .Net updates, applied yesterday.


author: Haerun Syahnur
body: this also worked for me and yes, also after Windows update


author: Jean Zunino
body: [Jonathan Folland](https://community.atlassian.com/t5/user/viewprofilepage/user-id/349261), thank you.  
Same situation happened to me. And deleting Composition.cache fixed the problem.


author: DMCDEV
body: **RIGHT ON!**

Thanks for this; I just spent an hour trying to debug this, looking for errors in the sourcetree.log file after the app failed to launch. I'm amused by how much attention this post received yesterday after being dormant for so long.


author: Alan Ma
body: Thanks! this worked for me.


author: Hondaman900
body: You saved my life!! This worked and I found this post/solution right as I was about to uninstall and reinstall SourceTree and rebuild my project and server access etc. That would have been very painful. I renamed the cache file and everything worked again.

Thank you!


author: Haoyang Lu
body: You my hero Mr.Folland!


author: Antonio cano montes
body: [Jonathan Folland](https://community.atlassian.com/t5/user/viewprofilepage/user-id/349261) thank you for your answer, you have saved my time


author: frjonesandson
body: Thanks so much, major time saver!


author: Emerson R
body: Can confirm, this worked for me as well.

Thank you!


author: Rahul Mishra
body: Thank you very much, this worked for me. How did you get to this solution of removing this particular file? I am curious to know the thought process.

p.s. In hindsight, now that you have mentioned that Composition.cache needs to be deleted, there are related error entries in log file that mention Composition (Microsoft.VisualStudio.Composition.PartDiscovery.GetElementTypeFromMany)

But I would never have reached to this solution by looking at these entries. :-)


author: Mukherjee, Apratim
body: Thank you, this worked for me


author: Christoffer Jedb?ck
body: ? Works like a charm! ?


author: wilson
body: You saved my time! perfect worked for me.


author: jpguillebaud
body: Thank you, that fix solved it for me also!


author: Darrell Thacher
body: Worked for me too! Thanks!

Seems like with all the increased security updates to our computers, we are now spending significant time troubleshooting post-security-update issues!


author: Leo Tohill
body: SAME SAME.


author: Danny Gorter
body: None of this worked for me. Apparently the folder names were mixed up. My executable is in AppData\\Local\\SourceTree\\app-3.4.2 and the config of Atlassion appeared to be in \\AppData\\Local\\Atlassian\\SourceTree.exe_{ID}\\3.4.2.0

I renamed the first folder to app-3.4.2.0 (so I added the 0) and then it started a fresh registration os Sourcetre. Did not complete this but killed it and changed the folder name back to app-3.4.2 and it started properly again.

comments: author: jermainefeng
body: Yep, I've tried your solution and works.

By the way I rename the folder back to origin name again and all the settings and repos keep the same.

And a prompt with temp files shown, I think this is the root cause why the source tree not loaded.


author: Ana Retamal
body: Hi Will,

Are you still experiencing this issue?

I've checked the log and I can see several mentions of Visual Studio, are you using Sourcetree with Visual Studio? Can you try [wiping Sourcetree preferences](https://confluence.atlassian.com/sourcetreekb/how-to-wipe-sourcetree-preferences-412484640.html) and starting it again, and see if this time it works?

If you're still having issues, can you let us know which Sourcetree and Windows version are you using, so we can help you troubleshoot this issue?

Best regards,

Ana

comments: author: tangwei cai
body: I also have this problem. Has it been solved?


Tags: windows