280

I develop Java code with Eclipse and regularly get this message:

resource is out of sync with the filesystem.

Right-click > Refresh will always clear this.

But why can't Eclipse refresh automatically when it finds this condition? Are there cases where you want the resource to be out of sync?.

If there are such conditions and they don't apply to my work, is there a way of getting Eclipse to refresh automatically when it encounters this state?. (I appreciate that it should refresh as little as it needs to in normal development to increase performance for human developers.)

UPDATE (2012-06-25): My latest update (Version: Indigo Release Build id: 20110615-0604) no longer shows Preferences - General - Workspace - Refresh Automatically There is an option "Refresh on access" - should I use this?

zb226
  • 9,586
  • 6
  • 49
  • 79
peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
  • _Why_ do you get the message? You might lose work if not careful. – Thorbjørn Ravn Andersen Dec 03 '10 at 12:10
  • 1
    I get this message *always* when I search workspace, because the Servers project (in web tools) contains log files which keep updating outside eclipse. Until now I have not found any solution apart from Refresh Automatically, but that gives othe rproblems (specifically: when some Ant build runs, Eclipse will refresh half-way the Ant build and mess things up). – Stijn de Witt Sep 29 '14 at 12:39
  • perhaps just right lick on the project then select "refresh"? – Junchen Liu Mar 30 '15 at 10:48
  • Silly question: Why is "an extra copy" of a resource obligatory? Do everybody definitely need this with the accompanying chance of getting "out of sync". – nsandersen Feb 10 '16 at 10:07
  • How can a file possibly be out of sync if I **just** opened eclipse and there is definitely no other process changing the file? Goddamnit, Eclipse! – Niko O Jun 29 '21 at 12:37

10 Answers10

331

You can enable this in Window - Preferences - General - Workspace - Refresh Automatically (called Refresh using native hooks or polling in newer builds)

Eclipse Preferences "Refresh using native hooks or polling" - Screenshot

The only reason I can think why this isn't enabled by default is performance related.

For example, refreshing source folders automatically might trigger a build of the workspace. Perhaps some people want more control over this.

There is also an article on the Eclipse site regarding auto refresh.

Basically, there is no external trigger that notifies Eclipse of files changed outside the workspace. Rather a background thread is used by Eclipse to monitor file changes that can possibly lead to performance issues with large workspaces.

Jmini
  • 9,189
  • 2
  • 55
  • 77
ddewaele
  • 22,363
  • 10
  • 69
  • 82
  • +1 Does this only happen during this condition? Or will it happen enough to affect me elsewhere? – peter.murray.rust Dec 03 '10 at 08:43
  • 1
    I have Preferences - General - Workspace - Refresh Automatically. Is this the same? – peter.murray.rust Dec 03 '10 at 08:47
  • 1
    Any way to have it automatically accept changes from the filesystem for open editor windows that don't have unsaved changes? – Leopd Jun 02 '11 at 16:17
  • 1
    @Leopd See [avoiding eclipse “changed on file system” dialog?](http://stackoverflow.com/questions/815707/) – Piotr Dobrogost Nov 13 '11 at 12:25
  • 14
    It now seems to be called "Refresh using native hooks or polling" (Indigo SR1). – Oliver Bock Aug 14 '12 at 01:21
  • If you have a huge project, the constant builds can become annoying. I solved it with [an extreme solution](http://stackoverflow.com/questions/7556364/disable-the-building-of-one-project-in-an-eclipse-workspace). – brandizzi Sep 20 '13 at 22:07
  • I dont understand how "refresh using native hooks or polling" is translated to "refresh automatically". The former suggests that eclipse all the time keeps track on which files there are in the file system, but the latter could be that eclipse actually checks which files there are when I need to perform a file search operation. – Anders Lindén Mar 31 '14 at 18:50
  • Yeah right clicking porject on package explorer and selecting refresh updated the project to reflect what's on disk and the error went away. – JohnMerlino Jun 03 '14 at 19:12
  • Works in Eclipse Mars as well, enabling "refresh using native hooks of Pooling" as suggested, thank you. – 1vand1ng0 Jan 12 '16 at 17:35
  • Auto refresh is recommended when using eGit. eGit can start rejecting forwards when the underlying filesystem goes out of sync (like when editing files externally). The auto refresh can ensure these don't happen. – Dominic Cerisano May 18 '16 at 02:10
38

Just right click on the file or on the project and click Refresh. The error will vanish. I also faced the same issue and it worked for me.

bhejaFry
  • 715
  • 1
  • 7
  • 12
  • 21
    The OP mentioned that in his question, "'Refresh' will always clear this." The problem is that this is incredibly annoying when working with complex projects or in conjunction with tools external to Eclipse that are changing the file system. – ryanbrainard Oct 26 '12 at 18:50
19

enter image description hereWindow -> Preferences -> General -> Workspace

hitesh141
  • 963
  • 12
  • 25
14

For the new Indigo version, the Preferences change to "Refresh on access", and with a detail explanation : Automatically refresh external workspace changes on access via the workspace.

As “resource is out of sync with the filesystem” this problem happens when I use external workspace, so after I select this option, problem solved.

zhihong
  • 1,808
  • 2
  • 24
  • 34
5

This happens to me all the time.

Go to the error log, find the exception, and open a few levels until you can see something more like a root cause. Does it says "Resource is out of sync with the file system" ?

When renaming packages, of course, Eclipse has to move files around in the file system. Apparently what happens is that it later discovers that something it thinks it needs to clean up has been renamed, can't find it, throws an exception.

There are a couple of things you might try. First, go to Window: Preferences, Workspace, and enable "Refresh Automatically". In theory this should fix the problem, but for me, it didn't.

Second, if you are doing a large refactoring with subpackages, do the subpackages one at a time, from the bottom up, and explicitly refresh with the file system after each subpackage is renamed.

Third, just ignore the error: when the error dialog comes up, click Abort to preserve the partial change, instead of rolling it back. Try it again, and again, and you may find you can get through the entire operation using multiple retries.

  • A few of my imports were corrupt after this, but a quick *Organise Imports* fixed that too. – z0r Jun 06 '14 at 00:02
  • I needed to do this (ignore the error and retry) when just moving a class to a new package. – z0r Jun 06 '14 at 00:03
1

If this occurs trying to delete a folder (on *nix) and Refresh does not help, open a terminal and look for a symlink below the folder you are trying to delete and remove this manually. This solved my issues.

TaninDirect
  • 458
  • 1
  • 7
  • 15
1

A little hint. The message often appears during rename operation. The quick workaround for me is pressing Ctrl-Y (redo shortcut) after message confirmation. It works only if the renaming affects a single file.

wathson
  • 21
  • 3
  • What does `Ctrl-Y` do? – z0r Jun 06 '14 at 00:05
  • 1
    Ctrl-Y is "redo". In this particular case you rename something then eclipse encounters a problem and undoes rename operation. Pressing Ctrl-Y recovers the rename attempt. – wathson Jul 14 '14 at 12:06
  • Ah I see. Not in Ubuntu; it's `Ctrl-Shift-Z`. Consider adding the explanation of why you press `Ctrl-Y` to your answer :) – z0r Jul 15 '14 at 00:57
1

When you open an Eclipse workspace from within a clearcase view and try to rename the project, you will often get the pop-up warning ... “Resource ‘project’ is out of sync with the file system”. If refreshing the project does not fix the problem, then do the following workaround: a. Open workspace WITHOUT being in a view b. Select the project in Project Explorer c. ClearCase -> Associate Project (project should now look like project [] ) d. Right click project -> Refresh (vob sub-folders should now be empty) e. Right click project -> Rename ... f. Enter New name

Now you can close the workspace, reopen it in a view and refresh the project. You may also dissociate the project if you prefer the project not to be associated with the vob.

0

If you are a regular Eclipse user than you might have got this error many times. The error simply says, “you’ve made changes in files in your workspace from outside eclipse”. The simplest solution would be to select the project and press F5 (Right click -> Refresh).

if you need more explanation you can read from this web site

BERGUIGA Mohamed Amine
  • 6,094
  • 3
  • 40
  • 38
0

I was not able to resolve this error by either refresh or by turning on "native polling" workspace feature. Turned out my project was also opened in two instances of eclipse. Once I closed the other instance, the error went away. So make sure your project is only opened at one place if you are seeing this error.

java_doctor_101
  • 3,287
  • 4
  • 46
  • 78