-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(macOS) iCloud save location regularly reset, now impossible to change #728
Comments
This is very strange. First time I've seen feedback like this. The two possibilities I can think of immediately are:
What is the specific performance? Could you screenrecord your operation?
Of course, it's supported. You can get some logs via:
|
Just to make sure, are you running macOS 15? I discovered that there are several issues that can be caused by changes related to sandbox permissions in macOS 15. Have you denied or allowed any system authorization pop-ups regarding the App? |
Yes, I use macOS Sequoia 15.0, I think this happened before the update already though.
Not that I know of, where would I need to check? |
The scripts are in an iCloud folder that is marked as "keep contents downloaded". I have no idea what iCloud does with the folder in the background.
This did work now, so I can't currently reproduce this.
I was under the impression iCloud did things that made using it as Storage for Userscripts difficult :-) |
Some authorization pop-ups are temporary or one-time, so you can't check them.
As for the "keep downloaded" folder, in theory it shouldn't have too many surprises, but who knows? Like I said in the issue below, since I don't use iCloud Drive myself, debugging related issues is difficult for me. And it’s definitely not a priority for me right now. I believe this issue may occur in macOS 15 or earlier, for example if an "eviction" occurs there. I also believe that the new "keep downloaded" features of macOS 15 / iOS 18 will play some role. But if you can reproduce the "cannot change save location" issue, I will check and try to solve it. But are you sure this issue ever happened in macOS 14 or earlier? |
I'm seeing the same problem after upgrading to MacOS 15.0. I keep the user script folder in iCloud and periodically UserScripts changes it back to the default Container folder. I am able to change it back to the iCloud Folder, so I can fix this, but it does get annoying. This was never an issue on prior versions of MacOS. I have seen the same thing happen with my iPhone and iPad on iOS 18. I have the scripts folder set to keep downloaded. Of note, there is no issue with the actual files syncing in iCloud, it's just that the UserScript extension periodically changes the user set folder back to the default folder. |
I'm sorry, but the issues you are experiencing appear to be inconsistent. Let’s not lump all the issues and options together. @thegcat raise two main issues here:
"keep downloaded" is a new feature in macOS 15 / iOS 18 and I think it should help alleviate "issue 1" if iCloud is indeed deleted and re-created the folder behind the scenes (e.g. eviction due to space optimization). So did you encounter "issue 1" when "keep downloaded" option was enabled or when it was disabled? It should be noted that, my previous comment about macOS 15 was only about "issue 2" and I had wondered if "issue 2" only happened in macOS 15. But now that I have investigated clearly, that has nothing to do with the problem I found. So, for "issue 1", we create a "bookmark" for the folder you selected (outside of the app sandbox) to maintain access to the folder, but if the "bookmark" becomes invalid (e.g. the folder was deleted and then re-created), we lose access to the folder (without the bookmark, the app cannot access folders outside the sandbox), so you may see it revert to the default path. For "issue 1", I don't have much help at the moment since I can't debug iCloud. For "issue 2", if you could reproduce it stably and provide some necessary information or logs, I will try to solve it. I hope this time I have made things clear. |
I have the issue where the User Script save location keeps changing from the custom I set to to back to the default location. This started with MacOS 15. I set it to /Users/username/Documents/UserScripts/ and it gets changed back to /Users/username/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/scripts every now and then (usually after restarting my Mac). I'm not sure if that is what you are calling the "iCloud Save location" issue, though I do have the Documents folder syncing to iCloud. Of note, I checked and User Scripts does not have permission to access the Documents folder, but I was never prompted to allow access and it seems to work without needing that. Maybe Safari extensions don't need that, but any other app that tries to access Documents requires me giving permission. I don't have "issue 2". |
@Morac2 The macOS stuff is just confusing, isn’t it? Compared to its advertised safety, it just makes it impossible for people to know what it is doing behind the scenes. The first thing to be clear about is that if you don't authorize an app to access your "documents" folder, they really can't. And But why does it have access to the folder you selected in "Documents" folder? Because you "selected" it. This is another authorization mechanism in macOS, which means that the App can access the files or folders you provide or selected through the system "open and save panels". If you want to know the details, here is the official documentation.
I don't know what it does to your folder when you turn on iCloud sync for the "Documents" folder, since I don't use iCloud. But if the same thing doesn't happen when you select a non-iCloud synced folder, you know what's probably going on. As I explained above, The app uses the "bookmark" to access folder of your selected, and if that "bookmark" becomes invalid, the "restore to default path" situation what you describe may occur. If you want to see what's going on behind the scenes, such as whether the bookmark has invalid and what the app has tried, please refer to the method I provided above for viewing system and app logs. Since the app and extension do not collect any usage data, without any logs or details or reproducible actions, we cannot provide any further help. |
Both problems are probably not related, I would open a new issue for the iCloud-related issue regarding iCloud on macOS 15? Regarding the issue of not being able to change the "Save Location" on macOS, I have captured console logs of the activity when it doesn't work: log
"fehler" means error. |
As an additional data point: This happens even for folders that are in my home directory and that are not the Documents folder for example. |
So, could you clarify, which issue only occurs in macOS 15, and which one also occurs in macOS 14 ? I would rather you create a separate issue for "save location impossible to change (issue 2)". Because the discussion and description in this issue are more about "issue 1".
The log has almost no context. I can guess where the error print, but it's not much help. It just calls the system API to create a "bookmark", like I said above. userscripts/xcode/Shared/Preferences.swift Lines 101 to 112 in 55f0f1b
But we still don’t know why it throws "The file couldn’t be opened.", we can't even know in which process it happened. The func is called in multiple processes, it might be more helpful if you could get a more complete logs. For example, under normal circumstances you may find the following logs:
If that's a local folder (no iCloud involved), I don't think there's any difference in "Documents" or other locations, at this point. |
Regarding "issue 1", I now have some new information, but I would still like to get your reproduction and error message logs to confirm this. I think one possibility is that we couldn't access the folder while iCloud was syncing it, so the "bookmark" couldn't resolve at that point, and we then deemed the "bookmark" invalid and deleted it. You should be able to find the following logs: error Userscripts-Mac-Safari-Extension resolvBookmark(_:_:_:) - ???
info Userscripts-Mac-Safari-Extension removeBookmark() - remove invalid bookmark: ScriptsDirectoryUrlBookmarkData But I need error messages marked with question marks to confirm the conjecture and identify specific errors. This "error" should be found in the historical system logs, which means there is no need for instant monitoring and reproduction. So please run the command below in log show --start 2024-09-01 --predicate 'process="Userscripts-Mac-Safari-Extension" && category="Userscripts_Mac_Safari_Extension/Preferences.swift"' --info --debug > userscripts-log.txt If the issue is as I guessed, then we need some asynchronous detection like @2xsaiko tried using |
I have attached the log, but it seems there's not much history to go by. I'll try to provide one when Userscripts forgets the folder again. |
It is worth mentioning that the |
I have a log, it has the line you expected. |
@thegcat While the error still doesn't provide enough information, such as why "the file cannot be opened", but it basically confirms my suspicion that there was some "time" when the iCloud folder couldn't be read. (e.g. it might be syncing; it can't read synchronously) As far as I know, Apple introduced the FileProvider mechanism to iCloud Drive in macOS 14, which is asynchronous. Currently, we may not have an easy way to solve this issue. As I mentioned above, we must redesign a caching and synchronization mechanism to completely solve the issues. Before we solve the issue, as a possible self-workaround, you might consider setting a local path (rather than any via the FileProvider). Then sync the content to the cloud folder manually, or via tools/scripts/automation etc. |
This is no problem, I can switch to the builtin/online sync solution for the time being. If there's anything I can check to clarify what iCloud does (watch the node id, try to access the file every second or whatever) I could to that, but that might be useless if the file access mechanism will be changed? |
@thegcat Thanks, but we can almost assume that the issues arises from the FileProvider state. If there is more new information or logs about "issue 2", please provide it to us. |
For me, I don't see anything about bookmarks in the logs when the folder resets to the default value. The only errors I see are:
|
@Morac2 Have you enabled "Enable Native Logger"? These logs are not helpful. |
I'm on macOS 15.0, Userscripts Screen.Recording.2024-10-08.at.6.44.51.AM.480p.mov |
@blalor The log filter is for "iCloud save location regularly reset (issue 1)", so you missed the change path part of the log. Please try to get a more extensive log: log show --start 2024-10-01 --predicate 'process BEGINSWITH "Userscripts"' --info --debug > userscripts-log.txt |
I'm now seeing the same problem with "issue 2". I can't change the path to anything other than the default. I dumped the log from right after selecting "open" when trying to change the folder:
|
I noticed another application I ran that I set a different directory for the default location (external drive) was also defaulting to the ~/Library/Containers/... folder. I restarted my Mac and then I could change the UserScript folder. I first noticed this with macOS Sequoia so I think this is a bug in Sequoia. |
Same, after upgrading to macOS 15.0.1 (or maybe just due to restarting after that upgrade?) I can now select the desired folder. |
@Morac2 I edited your comments to better format and remove incorrect references. I looked at your logs, but it doesn't contain any useful information, and there doesn't appear to be any log entries produced by the App's internal As I replied above, either you may not have the "Enable Native Logger" option turned on, or you may be using an incorrect log collection method. Without relevant logs, it is really difficult for us to analyze possible issues. I'm trying to build a built-in log export functionality that I hope will help and simplify the process. Additional question: Does the "Cannot change save location" only occur when trying to change to iCloud/External Drive, or does it also apply to any local disk path? Because iCloud/External Drive may all be driven by I've added readability detection in #734 but haven't released a new version yet, maybe I should release one so at least it will have a popup. |
Here you go, try But, of course, it's always nice to see a more detailed associated error log. |
@ACTCD I’m almost certain this is a MacOS 15 bug as I’ve seen another application have the same problem where I can’t change the default folder to any folder until I restart my Mac. That happens every few days. When it happened I noticed that UserScripts reverted to the default folder as well. |
@Morac2 I know it comes with macOS 15. In other words, this is not enough to prove that it is a system bug, maybe it is a "feature". |
Bringing some updates, possible source of both issues:https://forums.developer.apple.com/forums/thread/764435
So @Morac2 might be right, this might be the system bug and have been fixed as of macOS 15.1 beta 4. |
I've never encountered a folder location reset on macOS (still running Sonoma 14.6.1 here), but I started seeing it on iOS after one of the 18.x releases. I initially set it to Keep Downloaded when some files were not there to modify the site, but then it kept resetting to the default location. The folder is a Keep Downloaded folder, so definitely going nowhere. I've currently given up and am just manually syncing the files I've changed from the iCloud location to the On my iPhone Userscripts folder. I haven't checked the code yet, but if the app is using UserDefaults, then this bug identified by Christian Selig might be at play. Their workaround was to switch to their own library, TinyStorage, for the info they formerly stored in UserDefaults. |
@jeremy-w I don't think The problem is that we need logs to determine why the For example it cannot be read, or is no longer valid. |
Scale or security of data is not needed to trigger the issue. The user defaults issue described in the linked post is:* iOS for some reason stores defaults so they are only available after first unlock* UserDefaults reads before that unlock return values as if the key has no data, rather than erroring* iOS pre-warming can mean your app fires up in this state* Now, if you write the app’s fallback value to defaults on finding nothing, it clobbers the user’s value* Attempts to identify this scenario to work around it are lossy* So the author’s proposed workaround is a storage file that has no data protection applied and a library that provides equivalent benefit wrt caching and thread safety to UserDefaults to work with the file.--Jeremy W. Shermanhttp://jeremywsherman.com/On Oct 25, 2024, at 13:01, ACTCD ***@***.***> wrote:
@jeremy-w I don't think UserDefaults is a issue in this use case, we are not storing sensitive or large amounts of data.
The problem is that we need logs to determine why the bookmark was reset.
For example it cannot be read, or is no longer valid.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I've been running the 15.1 public beta for a few days and I can report I have not seen the Save Location resetting. I have checked twice in that timeframe and both times I could also change the Save Location without any issues. It seems this one can be added to the "things breaking in .0 releases for no apparent reason" pile, sorry for the hassle. |
@jeremy-w iOS 15 was released in 2021, I don't understand why it says the problem becomes sharp in 2024, and why is it related to iOS 18 again? So, in my opinion, it would be nice to knowledge it, but I wouldn't guess it's relevant to the issue. |
@thegcat Thanks for confirming. We'll keep this issue open until people can transition to the fixed OS versions. |
On 15.0, I can fix the issue with a |
@dotsam Thanks for confirming. It looks like we'll just have to wait for macOS 15.1 to be officially released. |
This should be fixed in macOS 15.1, which was released a week ago. |
I tried using Userscripts with an iCloud Drive custom Save Location. I used the
com~apple~CloudDocs/UserScripts
folder. This works well on iOS, unfortunately there are problems on macOS.On macOS the extension regularly changed the Save Location back to the default folder. I also tried using the TestFlight version (currently
5.0.0 (108)
installed) but the Save Location was also reverted to the default there.Now I also have the problem that the Save Location is stuck on the default folder. Trying to change the Save Location in the macOS app or in the Safari extension does not work (I tried with Safari open and the app closed, app open and Safari closed, both open, nothing works).
Is this a supported setup? Is there anything I can do to help debug this? Or should I just host my scripts in a git repo and use the built-in update function and not use iCloud anymore?
The text was updated successfully, but these errors were encountered: