Clean out Eclipse workspace metadata
Asked Answered
S

5

40

I use multiple workspaces with Eclipse. I recently noticed that some of my workspaces have a lot of cruft in them from software packages that I installed and then later removed. As far as I can tell, the situation is that many packages write stuff (sometimes a lot of stuff) to the .metadata folder for every workspace I open while the package was installed. When I removed a package, it seems to clean out the .metadata folder for the workspace that I happen to have open at the time, but all the other workspaces are left with orphaned metadata. Sometimes this metadata causes problems—often, errors while opening the workspace and sometimes instability.

The only way I know to deal with this is to create a new workspace, import projects from the polluted workspace, reconstructing all my settings (a major pain) and then delete the old workspace. Is there an easier way to deal with this?

Sethrida answered 1/8, 2012 at 21:51 Comment(3)
I like how nobody really answered the question.Unwilling
@Unwilling - Yeah. I think that the wide range of suggestions exactly points out the problem: there's no good way to deal with this situation. (I hope nobody believes that hunting around for magic files to copy over by hand or to delete is a good thing.) There's something off kilter in how Eclipse workspaces are designed.Sethrida
Well from what I have seen the real answer is as follows: either (A.) suck it up, (B.) delete the .metadata directory in the workspace and reimport the projects and set everything back up, or (C.) nuke and reinstall Eclipse.Unwilling
O
28

There is no easy way to remove the "outdated" stuff from an existing workspace. Using the "clean" parameter will not really help, as many of the files you refer to are "free form data", only known to the plugins that are no longer available.

Your best bet is to optimize the re-import, where I would like to point out the following:

  • When creating a new workspace, you can already choose to have some settings being copied from the current to the new workspace.
  • You can export the preferences of the current workspace (using the Export menu) and re-import them in the new workspace.
  • There are lots of recommendations on the Internet to just copy the ${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings folder from the old to the new workspace. This is surely the fastest way, but it may lead to weird behaviour, because some of your plugins may depend on these settings and on some of the mentioned "free form data" stored elsewhere. (There are even people symlinking these folders over multiple workspaces, but this really requires to use the same plugins on all workspaces.)
  • You may want to consider using more project specific settings than workspace preferences in the future. So for instance all the Java compiler settings can either be set on the workspace level or on the project level. If set on the project level, you can put them under version control and are independent of the workspace.
Orsini answered 2/8, 2012 at 6:10 Comment(3)
I'm affraid that export preferences precisely exports ${old_workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings: #13334650Revoke
@Revoke Of course it does. But it is restricted to a very small subset of the available preferences, and by that, to a small subset of the metadata settings folder.Orsini
I was referring to your "There are lots of recommendations on the Internet to just copy the ${old_workspace}/..." Also according to my experiments it blindly exports all the org.eclipse.core.runtime/.settings folder - not a subset (see my question for couple related bugs). What would be the other settings one needs ("free form data") was my question preciselyRevoke
B
12

One of the things that you might want to try out is starting eclipse with the -clean option. If you have chosen to have eclipse use the same workspace every time then there is nothing else you need to do after that. With that option in place the workspace should be cleaned out.

However, if you don't have a default workspace chosen, when opening up eclipse you will be prompted to choose the workspace. At this point, choose the workspace you want cleaned up.

See "How to run eclipse in clean mode" and "Keeping Eclipse running clean" for more details.

Birr answered 1/8, 2012 at 22:12 Comment(1)
Actually, clean mode clears OSGi things only and DOES NOT affect the workspace. The second link is quite misleading in that regard.Machzor
L
3

In my case eclipse is not showing parent class function on $this, so I perform below mention points and it starts works:-

I go to my /var/www/ folder and check for .metadata folder (Here check the .log file and it shows) Resource is out of sync with the file system: 1. Go to Eclipse --> Project --> Clean 2. Windows -- preferences --> General --> Workspace --> And set it to "Refresh Automatically"

After that boom - things gets start working :)

If you want to load variables from other files too then ado this :- Eclipse-->Windows-->Preferences-->Php-->Editor-->Content Assist --> and check "show variable from other files"

Then it will show element , variables and other functions also.

Lombard answered 8/5, 2014 at 9:29 Comment(0)
V
1

In some cases, I could prevent Eclipse from crashing during startup by deleting a .snap file in your workspace meta-data (.metadata/.plugins/org.eclipse.core.resources/.snap).

See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=149121 (the bug has been closed, but happened to me recently)

Vulturine answered 1/10, 2014 at 8:23 Comment(0)
S
1

The only way I know to deal with this is to create a new workspace, import projects from the polluted workspace, reconstructing all my settings (a major pain) and then delete the old workspace. Is there an easier way to deal with this?

For synchronizing or restoring all our settings we use Workspace Mechanic. Once all the settings are recorded its one click and all settings are restored... You can also setup a server which provides those settings for all users.

Stumer answered 8/7, 2016 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.