Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 507328 - Eclipse forgets about global settings and installed features
Summary: Eclipse forgets about global settings and installed features
Status: CLOSED DUPLICATE of bug 461670
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 506797 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-11-10 02:49 EST by Martin Lippert CLA
Modified: 2018-05-31 10:06 EDT (History)
12 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lippert CLA 2016-11-10 02:49:06 EST
I am using Eclipse JEE Neon.1 package, start it up on my macOS Sierra machine and install an additional feature from an update site. That all works fine.

BUT:

When I start Eclipse the next day, the global settings are lost as well as my newly installed feature. This is a dramatic problem from my point of view.

Observations:

- when I install the additional feature, the progress tells me that Eclipse seems to install ALL installed features again
- a new folder in ~/.eclipse is being created, for example: org.eclipse.platform_4.6.1_1742145858_macosx_cocoa_x86_64
- the additional plugin is being put into this folder (together with configuration data)
- the next day, a new folder in ~/.eclipse is being created, containing fresh configuration data and no additional plugins

Why does this happen? Any idea what is going wrong here?
Comment 1 Martin Lippert CLA 2016-11-10 03:23:50 EST
I tried this with Eclipse 4.7M3 (SDK) and it looks like:

- starting Eclipse by clicking on "Eclipse.app" (the macOS way of doing things), this new config folder is being created and additional plugins are being installed in there.

- starting Eclipse by clicking "eclipse" in "Eclipse.app/Contents/MacOS/" there is no new config folder being created and additional plugins are being installed into "Eclipse.app/Contents/Eclipse"

Why is that different?
Comment 2 Thomas Watson CLA 2016-11-10 08:31:32 EST
Pascal, do you have any ideas on why this is happening?  I would move to p2 but the difference in behavior between launching with "Eclipse.app" vs the eclipse binary seems to indicate some issue with the native launcher.
Comment 3 Martin Lippert CLA 2016-11-16 10:17:05 EST
Any new insights on this?
Comment 4 Martin Lippert CLA 2016-11-17 08:23:04 EST
I tried to find out more, here are my results:

This seems to be related to App Translocation in macOS Sierra. If you start the macOS app as regular app from somewhere on your disc, the application gets translocated into a random private location and started from there. This is a security enhancement of macOS Sierra.

This translocation seems to confuse Eclipse somehow. The osgi.configuration.area is then created in another random location under ~/.eclipse/. And that randomly chosen area seems to change every day or so.

If this translocation doesn't happen (for example if the app is moved to the Applications folder of macOS), then everything is just fine and the osgi.configuration.location is set to the location of the app (as usual).

If you start Eclipse not by clicking in the Eclipse.app icon, but you start the executable inside of the package (Eclipse.app/Contents/MacOS/eclipse) then macOS Sierra doesn't translocate the app either and everything is fine. That seems to be the reason why it makes a difference (as mentioned in the comment above).

So it looks like there is something going wrong at startup time when the app is being translocated by macOS Sierra.
Comment 5 Mikaël Barbero CLA 2016-11-17 09:06:38 EST
(In reply to Martin Lippert from comment #4)

We may need to provide a signed DMG to distribute Eclipse on the Mac if we want to avoid the randomized path (see bug 461670 comment 2).
Comment 6 Mikaël Barbero CLA 2016-11-17 09:09:26 EST
(In reply to Martin Lippert from comment #4)
> If this translocation doesn't happen (for example if the app is moved to the
> Applications folder of macOS)

Is it that simple to workaround the translocation? You opened the app by clicking the Eclipse.app icon in the /Applications folder and everything was fine?
Comment 7 Martin Lippert CLA 2016-11-17 10:13:04 EST
> We may need to provide a signed DMG to distribute Eclipse on the Mac if we
> want to avoid the randomized path (see bug 461670 comment 2).

Not sure about that. At least this happens for a signed .app package (officially signed with an Apple Developer certificate). Not sure if a signed DMG changes the behavior.
Comment 8 Martin Lippert CLA 2016-11-17 10:14:55 EST
> > If this translocation doesn't happen (for example if the app is moved to the
> > Applications folder of macOS)
> 
> Is it that simple to workaround the translocation? You opened the app by
> clicking the Eclipse.app icon in the /Applications folder and everything was
> fine?

From what I read, yes, that is enough. In that case the app is regarded as "installed". That is what I read and what I tried. Although I should mention that the .app package was signed with a dev certificate from Apple.
Comment 9 Martin Lippert CLA 2016-11-17 10:18:00 EST
The most interesting (and important) question from my end is:

--> Where does the osgi.configuration.area gets configured to point to this random location in ~/.eclipse/

If we can fix this, it should work all the cases, independent of the app being translocated or not.

Tom, do you know where this happens? Would love to take a look at the code that decides this.
Comment 10 Thomas Watson CLA 2016-11-17 12:20:39 EST
(In reply to Martin Lippert from comment #9)
> The most interesting (and important) question from my end is:
> 
> --> Where does the osgi.configuration.area gets configured to point to this
> random location in ~/.eclipse/
> 
> If we can fix this, it should work all the cases, independent of the app
> being translocated or not.
> 
> Tom, do you know where this happens? Would love to take a look at the code
> that decides this.

Checkout the method:

org.eclipse.equinox.launcher.Main.computeDefaultConfigurationLocation()
Comment 11 Martin Lippert CLA 2016-11-18 05:10:33 EST
(In reply to Martin Lippert from comment #7)
> > We may need to provide a signed DMG to distribute Eclipse on the Mac if we
> > want to avoid the randomized path (see bug 461670 comment 2).
> 
> Not sure about that. At least this happens for a signed .app package
> (officially signed with an Apple Developer certificate). Not sure if a
> signed DMG changes the behavior.

From what I read, a signed DMG will indeed turn-off the Gatekeeper Path Randomization.
Comment 12 Martin Lippert CLA 2016-11-18 05:52:52 EST
Thanks for the pointer into the code, Tom, much appreciated. I debugged this today and I think there isn't much that we can do here.

macOS Sierra has Gatekeeper Path Randomization. That is activated in very specific situations (if you download the Eclipse zip file, extract it, and start Eclipse right there, for example). If it is activated, Gatekeeper Path Randomization copies the app to a private randomized read-only area on the disc and starts it from there.

As a consequence the Equinox Launcher detects that the install location is read-only and creates a matching folder in the users home in ~/.eclipse/. It uses a hash of the install dir as part of the name. All good so far.

The bad part of this is that the Gatekeeper Path Randomization happens after every restart of your machine again (to a new, different location). Maybe this "do the path randomization again" thing is triggered by other events, too. This means, from the Equinox launcher perspective, this looks like a new install and a new matching config area will be created - and all old installs and settings are lost.

I don't see a good way to solve this in the launcher, since I have no idea how to differentiate between a newly installed app and a newly path randomized version of the app.

Solutions that avoid the Gatekeeper Path Randomization are:
- move your Eclipse.app via the finder to a different location
- create a signed DMG image and ship that instead (since that requires people to move the app to a new location on disc)
- start Eclipse via the executable (instead of the macOS app bundle)

Therefore I will mark this as closed and "not eclipse". And will post a note to the cross-project list to make people aware of this issue.
Comment 13 Dani Megert CLA 2016-11-23 12:22:40 EST

*** This bug has been marked as a duplicate of bug 461670 ***
Comment 14 Mikaël Barbero CLA 2016-11-28 09:04:19 EST
*** Bug 506797 has been marked as a duplicate of this bug. ***
Comment 15 Olivier Croquette CLA 2017-06-15 09:34:13 EDT
(In reply to Martin Lippert from comment #12)
> macOS Sierra has Gatekeeper Path Randomization. That is activated in very
> specific situations (if you download the Eclipse zip file, extract it, and
> start Eclipse right there, for example).

This happened to me with an Oxygen RC and was a pretty frustrating experience, since every thing looks good at first, but the problem started only when I resumed my work on the next day.

> I don't see a good way to solve this in the launcher, since I have no idea
> how to differentiate between a newly installed app and a newly path
> randomized version of the app.

I think it is very much desirable to detect if the translocation is active and warn the user accordingly.
Maybe it would be even better to abort the start of the application, since it's clear that it WILL create problems.

It seems there are at least 3 options to detect if translocation is enabled:
- Use <Security/SecTranslocate.h> from the 10.12 SDK
- Use custom code that doesn't require the 10.12 SDK, like described here: http://lapcatsoftware.com/articles/detect-app-translocation.html
- Use a hack, like checking if the starting path contains the string "AppTranslocation" (the translocated path looks like "/private/var/folders/n6/drcyfyts2w5b7cq0bl4mv2km0000gn/T/AppTranslocation/7F0451C2-1F69-4CF7-AE4C-9BA402FBB7B4/d/Eclipse\ 4.7RC2\ I20170524-2000.app" on my system)


> Solutions that avoid the Gatekeeper Path Randomization are:
> - move your Eclipse.app via the finder to a different location
> - create a signed DMG image and ship that instead (since that requires
> people to move the app to a new location on disc)
> - start Eclipse via the executable (instead of the macOS app bundle)

Just for the record, I tried to use "xattr" to remove the flag "com.apple.quarantine", but that didn't seem to be enough, I had to move the application using the finder.

> Therefore I will mark this as closed and "not eclipse". And will post a note
> to the cross-project list to make people aware of this issue.

I think lots of confusion and effort can be saved on the user side if a warning was provided. Does that sound feasible or/and reasonable?  Should I open a new ticket?
Comment 16 Olivier Croquette CLA 2017-06-15 09:37:10 EDT
*** Bug 518303 has been marked as a duplicate of this bug. ***
Comment 17 Sam Brannen CLA 2018-05-31 10:00:38 EDT
Sounds like a duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=507328

And the answer is likely "due to App Translocation".

See also: https://lapcatsoftware.com/articles/app-translocation.html
Comment 18 Sam Brannen CLA 2018-05-31 10:02:05 EDT
Oops. I posted that previous comment to the wrong issue.

Is there any way to delete comments?
Comment 19 Dani Megert CLA 2018-05-31 10:06:13 EDT
(In reply to Sam Brannen from comment #18)
> Oops. I posted that previous comment to the wrong issue.
> 
> Is there any way to delete comments?

No.