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

Windows / Node.js / "make_dir() failed: No such file or directory" when using Realm.open() #2097

Open
ttous opened this Issue Nov 5, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@ttous
Copy link

ttous commented Nov 5, 2018

Hello,
I am trying to link my app to my realm using an admin user I created with Realm Studio, but I cannot get the Realm.open(...) method to work. I have been struggling with this for hours, I first thought I had a permission issue, but launching the code does create the react-object-server directory, with two sub-directories inside:

  • an empty one, named df1b418b-cc11-4c64-bf3b-e6f76b36774e.
  • io.realm.object-server-utility, which contains others sub-directories (metadata, ...).

I am launching the command from an administrator Windows terminal.

Thanks in advance for your help 👍 .

Goals

Open a realm with my admin user's credentials.

Expected Results

The Realm.open(...) method works

Actual Results

Open error: Error: Unable to open a realm at path 'C:\Users\ttoussaint\Documents\missions\compass-group\smart_checkout\server\realm-object-server\df1b418b-cc11-4c64-bf3b-e6f76b36774e\realms%3A%2F%2Fsmartcheckoutpoc.de1a.cloud.realm.io%3A%2Fdefault%2F__partial%2Fb62c46b40d11d1466360e9cb6f3a19db%2Fc78d573302c4f55d72ccb4c196f8e2433c15193a.management': make_dir() failed: No such file or directory.
    at Promise (C:\Users\ttoussaint\Documents\missions\compass-group\smart_checkout\server\node_modules\realm\lib\extensions.js:121:29)
    at Promise (<anonymous>)
    at Function.open (C:\Users\ttoussaint\Documents\missions\compass-group\smart_checkout\server\node_modules\realm\lib\extensions.js:120:27)
    at Realm.Sync.User.login.then (C:\Users\ttoussaint\Documents\missions\compass-group\smart_checkout\server\src\loader.js:30:15)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Steps to Reproduce

node src\loader.js

Code Sample

src\loader.js

const Realm = require('realm');
const constants = require('./constants.js');

// Define your models and their properties
const CarSchema = {
    name: 'Car',
    properties: {
        make: 'string',
        model: 'string',
        miles: { type: 'int', default: 0 },
    }
};
const PersonSchema = {
    name: 'Person',
    properties: {
        name: 'string',
        birthday: 'date',
        cars: 'Car[]',
        picture: 'data?' // optional property
    }
};

const admin = Realm.Sync.Credentials.usernamePassword(constants.username, constants.password);

Realm.Sync.User.login(constants.serverUrl, admin)
    .then((user) => {
        let config = user.createConfiguration();
        config.schema = [CarSchema, PersonSchema];
        Realm.open(config)
            .then(realm => {
                // Create Realm objects and write to local storage
                realm.write(() => {
                    const myCar = realm.create('Car', {
                        make: 'Honda',
                        model: 'Civic',
                        miles: 1000,
                    });
                    myCar.miles += 20; // Update a property value
                });

                // Query Realm for all cars with a high mileage
                const cars = realm.objects('Car').filtered('miles > 1000');

                // Will return a Results object with our 1 car
                cars.length // => 1

                // Add another car
                realm.write(() => {
                    const myCar = realm.create('Car', {
                        make: 'Ford',
                        model: 'Focus',
                        miles: 2000,
                    });
                });

                // Query results are updated in realtime
                cars.length // => 2
            })
            .catch((error) => {
                console.error('Open error:', error);
            });
        user.logout();
    })
    .catch((error) => {
        console.error('Login error:', error);
    });

src\constants.js

module.exports = {
    username: "admin",
    password: <my_admin_password>,
    serverUrl: "https://smartcheckoutpoc.de1a.cloud.realm.io"
};

Version of Realm and Tooling

  • Realm JS SDK Version: Realm package ^2.18.0
  • Node or React Native: Node 8.4.0
  • Client OS & Version: Windows 10

@realm-probot realm-probot bot added the O:User label Nov 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment