Skip to content

[bug] use api fs.readTextFile case error #5196

@wcly

Description

@wcly

Describe the bug

trigger error when using api fs.readTextFile in production mode.

image

Reproduction

  1. set tauri.conf.json
 "tauri": {
    "allowlist": {
      "all": true,
      "fs": {
        "scope": ["$RESOURCE/*"]
      }
  }
}
  1. use api
import {
  readTextFile,
} from "@tauri-apps/api/fs";

async fucntion fun(){
 const contents = await readTextFile(localConfigPath);
}
  1. build app
pnpm tauri build --debug
  1. install app
  2. run app

Expected behavior

readTextFile success.

Platform and versions

Environment
  › OS: Mac OS 12.5.1 X64
  › Node.js: 16.13.2
  › npm: 8.1.2
  › pnpm: 7.10.0
  › yarn: 1.22.18
  › rustup: 1.25.1
  › rustc: 1.63.0
  › cargo: 1.63.0
  › Rust toolchain: stable-x86_64-apple-darwin 

Packages
  › @tauri-apps/cli [NPM]: 1.0.5
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.5,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.2,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ src-tauri
  ├─ .git
  ├─ .vscode
  └─ src

Stack trace

No response

Additional context

It only throw error in production mode, work on dev mod

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions