asfernandes / node-firebird-drivers

Node.js Firebird Drivers
MIT License
54 stars 17 forks source link

macOS failing example #138

Closed Tomas2D closed 1 year ago

Tomas2D commented 1 year ago

Firstly, I would like to thank you for this library; it's beneficial mainly for my OpenSource project (https://github.com/Tomas2D/knex-firebird-dialect), where I want to switch from https://github.com/hgourvest/node-firebird to your library.

But when I tried to run the example provided in README.md

import { createNativeClient, getDefaultLibraryFilename } from 'node-firebird-driver-native';

async function test() {
    const client = createNativeClient(getDefaultLibraryFilename());

    const attachment = await client.createDatabase('/tmp/new-db.fdb');
    const transaction = await attachment.startTransaction();

    await attachment.execute(transaction, 'create table t1 (n integer, d date)');
    await transaction.commitRetaining();

    const statement1 = await attachment.prepare(transaction, 'insert into t1 values (?, ?)');
    await statement1.execute(transaction, [1, new Date()]);
    await statement1.execute(transaction, [2, new Date()]);
    await statement1.execute(transaction, [3, new Date()]);
    await statement1.dispose();

    const resultSet = await attachment.executeQuery(transaction, 'select n, d from t1 where n <= ?', [2]);
    const rows = await resultSet.fetch();

    for (const columns of rows)
        console.log(`n: ${columns[0]}, d: ${columns[1]}`);

    await resultSet.close();

    await transaction.commit();
    await attachment.dropDatabase();

    await client.dispose();
}

test().then(() => console.log('Finish...'));

I get the following error

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: operating system directive access failed
-Permission denied
-/tmp/firebird/]

However, running the command with sudo works. Any ideas?

Tomas2D commented 1 year ago

Temporary workaround:

sudo dscl . append /Groups/firebird GroupMembership "$(whoami)"
asfernandes commented 1 year ago

That should be related to embedded. You can also try with localhost: prefix.

I think your workaround is the correct thing to do to give permission foe the user.