Skip to content
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

bug: app data dir for ios #12552

Open
laciferin2024 opened this issue Jan 28, 2025 · 2 comments
Open

bug: app data dir for ios #12552

laciferin2024 opened this issue Jan 28, 2025 · 2 comments
Labels
platform: iOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@laciferin2024
Copy link

Describe the bug

The data dir app_handle.path().app_data_dir() is throwing permission denied in ios.

Reproduction

Used app_handle.path().app_data_dir(). and std:fs to write a json file

Throws:

Panic in wallet.rs:84: Could not create app data directory: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.2.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 23.3.0
    - pnpm: 9.1.0
    - yarn: 1.22.19
    - npm: 10.9.0
    - bun: 1.1.13

[-] Packages
    - tauri 🦀: 2.2.5
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1

[-] Plugins
    - tauri-plugin-notification 🦀: 2.2.1
    - tauri-plugin-sql 🦀: 2.2.0
    - tauri-plugin-positioner 🦀: 2.2.0
    - tauri-plugin-persisted-scope 🦀: 2.2.0
    - tauri-plugin-window-state 🦀: 2.2.1
    - tauri-plugin-os 🦀: 2.2.0
    - tauri-plugin-log 🦀: 2.2.1
    - tauri-plugin-single-instance 🦀: 2.2.1
    - tauri-plugin-fs 🦀: 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build

Stack trace

CoinOS              0x103a78950  std::sys::backtrace::__rust_end_short_backtrace
  CoinOS              0x103a7a904  _rust_begin_unwind
  CoinOS              0x103b2fd28  core::panicking::panic_fmt
  CoinOS              0x103b30118  core::result::unwrap_failed
  CoinOS              0x1030ade6c  core::result::Result<T>::expect
  CoinOS              0x100c48038  app_lib::store::wallet::WalletStore::new
  CoinOS              0x10099169c  app_lib::run::{{closure}}::{{closure}}
  CoinOS              0x100bd41e8  core::ops::function::FnOnce::call_once{{vtable.shim}}
  CoinOS              0x100b64d74  alloc::boxed::Box<T>::call_once
  CoinOS              0x100c612cc  tauri::app::setup
  CoinOS              0x100c5c880  tauri::app::App<T>::run::{{closure}}
  CoinOS              0x100c912e8  tauri_runtime_wry::handle_event_loop
  CoinOS              0x100c9ef4c  tauri_runtime_wry::Wry<T>::run::{{closure}}
  CoinOS              0x100d3cfb0  tao::platform_impl::platform::event_loop::EventLoopHandler<T>::handle_nonuser_event
  CoinOS              0x102f10d04  tao::platform_impl::platform::app_state::handle_nonuser_events
  CoinOS              0x102f0c07c  tao::platform_impl::platform::app_state::did_finish_launching
  CoinOS              0x102f1d5b0  tao::platform_impl::platform::view::create_delegate_class::did_finish_launching
  UIKitCore           0x191063a9c  -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
  UIKitCore           0x191060d60  -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
  UIKitCore           0x190e82648  -[UIApplication _runWithMainScene:transitionContext:completion:]
  UIKitCore           0x1910341a4  -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
  UIKitCore           0x190e3767c  _UIScenePerformActionsWithLifecycleActionMask
  UIKitCore           0x190fd7110  __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
  UIKitCore           0x190fd6e20  -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
  UIKitCore           0x190d9d870  -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
  UIKitCore           0x190d9d590  -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
  UIKitCore           0x190d9d048  __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
  UIKitCore           0x190d9c1f0  +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:]
  UIKitCore           0x190d9b828  _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion
  UIKitCore           0x190d9b4d8  -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
  UIKitCore           0x190e3742c  __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.229
  UIKitCore           0x190e36d7c  -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
  UIKitCore           0x190e2e7a0  -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
  UIKitCore           0x190e16a90  -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
  UIKitCore           0x190e14f9c  -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
  FrontBoardServices  0x1a7eb8008  __95-[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]_block_invoke
  FrontBoardServices  0x1a7eb5830  -[FBSScene _callOutQueue_coalesceClientSettingsUpdates:]
  FrontBoardServices  0x1a7eb7790  -[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]
  FrontBoardServices  0x1a7ecbc90  __93-[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]_block_invoke.197
  FrontBoardServices  0x1a7ecb4c4  -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
  FrontBoardServices  0x1a7edab8c  -[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]
  libdispatch         0x19617bfa4  _dispatch_client_callout
  libdispatch         0x19617f9ec  _dispatch_block_invoke_direct
  FrontBoardServices  0x1a7ec4374  __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
  FrontBoardServices  0x1a7ec42f4  -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
  FrontBoardServices  0x1a7ec41cc  -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
  CoreFoundation      0x18e43ff38  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
  CoreFoundation      0x18e43fecc  __CFRunLoopDoSource0
  CoreFoundation      0x18e442b2c  __CFRunLoopDoSources0
  CoreFoundation      0x18e441d28  __CFRunLoopRun
  CoreFoundation      0x18e494270  CFRunLoopRunSpecific
  GraphicsServices    0x1db5dd4bc  GSEventRunModal
  UIKitCore           0x190fd6778  -[UIApplication _run]
  UIKitCore           0x190bfce60  UIApplicationMain
  CoinOS              0x100d3d894  tao::platform_impl::platform::event_loop::EventLoop<T>::run
  CoinOS              0x100e20d9c  tao::event_loop::EventLoop<T>::run
  CoinOS              0x100c9eaa4  tauri_runtime_wry::Wry<T>::run
  CoinOS              0x100c5c754  tauri::app::App<T>::run
  CoinOS              0x100c5cd48  tauri::app::Builder<T>::run
  CoinOS              0x1009911ec  app_lib::run::{{closure}}
  CoinOS              0x100bc7a1c  tokio::runtime::park::CachedParkThread::block_on::{{closure}}
  CoinOS              0x100bc6e44  tokio::runtime::park::CachedParkThread::block_on
  CoinOS              0x100cd87dc  tokio::runtime::context::blocking::BlockingRegionGuard::block_on
  CoinOS              0x100cadf20  tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
  CoinOS              0x100d37218  tokio::runtime::context::runtime::enter_runtime
  CoinOS              0x100caded4  tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  CoinOS              0x100e24344  tokio::runtime::runtime::Runtime::block_on_inner
  CoinOS              0x100e24604  tokio::runtime::runtime::Runtime::block_on
  CoinOS              0x100b7ce68  tauri::async_runtime::Runtime::block_on
  CoinOS              0x100b7a37c  tauri::async_runtime::GlobalRuntime::block_on
  CoinOS              0x100b7cef0  tauri::async_runtime::block_on
  CoinOS              0x100b10e0c  app_lib::run_wrapper
  CoinOS              0x100bd86bc  core::ops::function::FnOnce::call_once
  CoinOS              0x100d48750  core::panic::unwind_safe::AssertUnwindSafe<T>::call_once
  CoinOS              0x100b83568  std::panicking::try::do_call
  CoinOS              0x100e08660  ___rust_try
  CoinOS              0x100e0625c  std::panic::catch_unwind
  CoinOS              0x100990c40  app_lib::stop_unwind
  CoinOS              0x100b10e28  app_lib::_start_app
  CoinOS              0x100b10e3c  _start_app
  CoinOS              0x100984024  _main

Additional context

On the other hand: this is working: dirs::home_dir().expect("Failed to retrieve home directory"); even for ios.Using home dir to store files!!

@laciferin2024 laciferin2024 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jan 28, 2025
@tauri-apps tauri-apps deleted a comment Jan 28, 2025
@FabianLars
Copy link
Member

Did you try calling create_dir_all on the path returned by app_data_dir ? The path it returns is technically wrong so it's more nested than it should be and since Tauri doesn't create directories it doesn't need itself you may be trying to write a file into a non existent directory.

@laciferin2024
Copy link
Author

laciferin2024 commented Jan 29, 2025

        std::fs::create_dir_all(&app_data_dir).expect("Could not create app data directory");

Its the app data dir that's failing to be created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: iOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants