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

Mongo Shell Support for MongoDB > 4.2 #524

Open
michaelmosmann opened this issue Jun 21, 2024 Discussed in #522 · 0 comments
Open

Mongo Shell Support for MongoDB > 4.2 #524

michaelmosmann opened this issue Jun 21, 2024 Discussed in #522 · 0 comments
Assignees

Comments

@michaelmosmann
Copy link
Member

Discussed in #522

Originally posted by bendherville June 13, 2024
Hi,
We are upgrading embed.mongo in our application as we have recently moved from windows to mac (m3) for development and the v2 version of embed.mongo doesn't work with arm64. Previously we programatically used mongo shell to run some scripts to setup our DB before our integration tests were executed.

I'm trying to do the same in v4.14.0 but I am getting an error when MongoShell is initialising.
The code looks like;

    public void runScript(String script, ServerAddress serverAddress) throws IOException {
        Transitions transitions = MongoShell.builder().build().transitions(Version.V7_0_11)
                .replace(Start.to(MongoShellArguments.class).initializedWith(MongoShellArguments.builder().scriptName(script).build()))
                .addAll(Start.to(ServerAddress.class).initializedWith(serverAddress));

        try (TransitionWalker.ReachedState<ExecutedMongoShellProcess> state = transitions.walker()
                .initState(StateID.of(ExecutedMongoShellProcess.class))) {
            // TODO: check state
        }
    }

and the error is;
java.lang.IllegalStateException: Cannot build ExtractedFileSet, some of required attributes are not set [executable]

But digging into it a bit, it appears it's downloading an archive and looking for a file named '.*mongo' with the archive. Presumably it's looking for the mongo shell command.

The archive it's downloaded is /Users/bend/.embedmongo/archives/https-fastdl-mongodb-org/56cb3d10404e5b9df5358ac4ee83efcb/osxmongodb-macos-arm64-7-0-11-tgz/bdaa5f3450eea95884efe91ca458f071e85217364d4d13665376dc8c51e1d319/archive.tgz

This contains mongod and mongos executables only.

MongoShell is defaulting the Command to Mongo, which is where that .*mongo pattern is coming from. In newer versions of mongodb the mongo shell command is called mongosh and distributed separate from the database package so I guess this is why it's not working but not entirely sure.

Can anyone confirm that MongoShell should work with mongo version v7_0 on MacOS?

@michaelmosmann michaelmosmann self-assigned this Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant