Skip to content

Can't set APIFY_LOCAL_STORAGE_DIR in Electron #1091

@andreysamode

Description

@andreysamode

Hello,

When I build an Electron app and run it, I get the following error:

Uncaught (in promise) Error: ENOENT: no such file or directory, mkdir '/apify_storage/datasets'
    at Object.mkdirSync (fs.js:823)
    at Object.module.exports.makeDirSync (/Users/name/Projects/Crawler/dist/mac/Crawler.app/Contents/Resources/app.asar/node_modules/fs-extra/lib/mkdirs/make-dir.js:101)
    at ApifyStorageLocal._ensureDatasetDir (/Users/name/Projects/Crawler/dist/mac/Crawler.app/Contents/Resources/app.asar/node_modules/@apify/storage-local/dist/index.js:159)
    at ApifyStorageLocal.dataset (/Users/name/Projects/Crawler/dist/mac/Crawler.app/Contents/Resources/app.asar/node_modules/@apify/storage-local/dist/index.js:112)
    at StorageManager._getOrCreateStorage (node_modules/apify/build/storages/storage_manager.js:103)
    at StorageManager.openStorage (node_modules/apify/build/storages/storage_manager.js:54)
    at Object.openDataset (node_modules/apify/build/storages/dataset.js:408)

If I run it using "npm start", it seems to work and creates the storage directory right in the root folder (ignoring the APIFY_LOCAL_STORAGE_DIR variable).

I tried to set APIFY_LOCAL_STORAGE_DIR using this:

`process.env.APIFY_LOCAL_STORAGE_DIR = '/path-to-apify-storage';

... and this:

exec('export APIFY_LOCAL_STORAGE_DIR="/path-to-apify-storage";');

... and even straight-up command line:

export APIFY_LOCAL_STORAGE_DIR="/path-to-apify-storage";

Unfortunately, Apify.openDataset() seems to ignore it.

Any ideas on how to get it to register the environment variable or perhaps specify the storage location in some other way?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions