{"action":"created","issue":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/3841","labels_url":"https://api.github.com/repos/nwjs/nw.js/issues/3841/labels{/name}","comments_url":"https://api.github.com/repos/nwjs/nw.js/issues/3841/comments","events_url":"https://api.github.com/repos/nwjs/nw.js/issues/3841/events","html_url":"https://github.com/nwjs/nw.js/issues/3841","id":107048869,"number":3841,"title":"gui.App.dataPath and Mac OS X sandbox","user":{"login":"talldude","id":542985,"avatar_url":"https://avatars.githubusercontent.com/u/542985?v=3","gravatar_id":"","url":"https://api.github.com/users/talldude","html_url":"https://github.com/talldude","followers_url":"https://api.github.com/users/talldude/followers","following_url":"https://api.github.com/users/talldude/following{/other_user}","gists_url":"https://api.github.com/users/talldude/gists{/gist_id}","starred_url":"https://api.github.com/users/talldude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talldude/subscriptions","organizations_url":"https://api.github.com/users/talldude/orgs","repos_url":"https://api.github.com/users/talldude/repos","events_url":"https://api.github.com/users/talldude/events{/privacy}","received_events_url":"https://api.github.com/users/talldude/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-17T18:51:24Z","updated_at":"2015-09-19T15:22:40Z","closed_at":null,"body":"We're in the process of preparing our nw.js app for (hopeful) release in the Mac App Store, and are using nw.js 0.12.3 along with the nwjs-macappstore-builder:\r\n\r\nhttps://github.com/johansatge/nwjs-macappstore-builder\r\n\r\nReading the Apple developer guide on Sandboxing:\r\n\r\nhttps://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html\r\n\r\nit looks like our App Data should be in the ~/Library/Containers/BundleID directory - not ~/Library/Application Support/AppName.\r\n\r\nIs there an undocumented App.containerPath (or something like it) that we can use in place of dataPath?  I've tried replacing all of App.dataPath references in our code to use ~/Library/Containers/BundleID, but it does not seem to work - after signing and packaging, when we run the signed app we get:\r\n```\r\nSep 17 10:52:08 Brians-MacBook-Pro kernel[0]: Sandbox: nwjs(27283) deny file-read-data /\r\nSep 17 10:52:08 Brians-MacBook-Pro kernel[0]: Sandbox: appleeventsd(50) deny file-read-metadata /Library\r\nSep 17 10:52:08 Brians-MacBook-Pro kernel[0]: Sandbox: appleeventsd(50) deny mach-lookup com.apple.ocspd\r\nSep 17 11:10:31 Brians-MacBook-Pro kernel[0]: Sandbox: nwjs Helper(34158) deny forbidden-sandbox-reinit\r\n```\r\nin the system.log.  I'm not 100% sure this is the issue, but was hoping someone here might have an idea of what would need to be done.\r\n\r\nThanks!\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26765130-gui-app-datapath-and-mac-os-x-sandbox?utm_campaign=plugin&utm_content=tracker%2F51989&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F51989&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/comments/141679343","html_url":"https://github.com/nwjs/nw.js/issues/3841#issuecomment-141679343","issue_url":"https://api.github.com/repos/nwjs/nw.js/issues/3841","id":141679343,"user":{"login":"johansatge","id":5699295,"avatar_url":"https://avatars.githubusercontent.com/u/5699295?v=3","gravatar_id":"","url":"https://api.github.com/users/johansatge","html_url":"https://github.com/johansatge","followers_url":"https://api.github.com/users/johansatge/followers","following_url":"https://api.github.com/users/johansatge/following{/other_user}","gists_url":"https://api.github.com/users/johansatge/gists{/gist_id}","starred_url":"https://api.github.com/users/johansatge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johansatge/subscriptions","organizations_url":"https://api.github.com/users/johansatge/orgs","repos_url":"https://api.github.com/users/johansatge/repos","events_url":"https://api.github.com/users/johansatge/events{/privacy}","received_events_url":"https://api.github.com/users/johansatge/received_events","type":"User","site_admin":false},"created_at":"2015-09-19T15:22:40Z","updated_at":"2015-09-19T15:22:40Z","body":"Hello,\r\n\r\nwhat is the behavior of the app ? Does it crash after displaying the errors in the logs ?\r\n\r\nI have tried to sign the following app:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n    <body>\r\n        <p id=\"write\">Processing...</p>\r\n        <p id=\"read\">Processing...</p>\r\n        <script>\r\n            var gui = require('nw.gui');\r\n            var fs = require('fs');\r\n            var write_node = document.getElementById('write');\r\n            var read_node = document.getElementById('read');\r\n            var file_path = '/Users/' + process.env['USER'] + '/Library/Containers/com.yourcompany.yourapp/Data/sample.json';\r\n            fs.writeFile(file_path, '{\"foo\":\"bar\"}', {encoding: 'utf8'}, function(error)\r\n            {\r\n                if (error)\r\n                {\r\n                    write.innerHTML = 'Write error: ' + error.message;\r\n                    read.innerHTML = 'No read';\r\n                }\r\n                else\r\n                {\r\n                    write.innerHTML = 'Write ok';\r\n                    fs.readFile(file_path, {encoding: 'utf8'}, function(error)\r\n                    {\r\n                        read.innerHTML = error ? 'Read error: ' + error.message : 'Read ok';\r\n                    });\r\n                }\r\n            });\r\n        </script>\r\n    </body>\r\n</html>\r\n```\r\n\r\nIt looks good, the `sample.json` file is created in `/Users/johan/Library/Containers/com.yourcompany.yourapp/Data`, and can be read. (No specific entitlements are needed.)\r\n\r\n![write-read sample 2015-09-19 16-51-03](https://cloud.githubusercontent.com/assets/5699295/9976872/0a6c04ca-5ef2-11e5-9543-0e4009e0647d.png)\r\n\r\nNow as you said, the `gui.App.dataPath` var is not suitable, and as far as I know there is no special case for the MAS. Maybe we should open a feature request to support this.\r\n"}}