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

Support Ubuntu 22.04 properly (Error: libcrypto.so.1.1 missing) #732

Closed
lyj711 opened this issue Jan 10, 2023 · 13 comments
Closed

Support Ubuntu 22.04 properly (Error: libcrypto.so.1.1 missing) #732

lyj711 opened this issue Jan 10, 2023 · 13 comments
Labels
Distribution support Add / modify an (linux) distribution not a MMS issue This is not an issue for "mongodb-memory-server" released Pull Request released | Issue is fixed

Comments

@lyj711
Copy link

lyj711 commented Jan 10, 2023

Versions

  • NodeJS: 16.13.0
  • mongodb-memory-server-*: 8.11.0
  • mongodb(the binary version): 6.0.0
  • mongodb(the js package): 4.13.0
  • system: Ubuntu

package: mongo-memory-server

What is the Problem?

When running 'pnpm test', following error occured:

Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"

Code Example

import { Test, TestingModule } from '@nestjs/testing';
import { EventController } from './event.controller';
import { EventService } from './event.service';
import {MongoMemoryReplSet} from 'mongodb-memory-server';
import {Event} from '@prisma/client';
import { PrismaService } from '../prisma.service';
import { BadRequestException } from '@nestjs/common';
import { BlockchainService } from '../blockchain/blockchain.service';


describe('EventController', () => {
  let controller: EventController;
  let prisma: PrismaService;
  let mongodb: MongoMemoryReplSet;
  let eventModel: Event;

  beforeAll(async () => {
    mongodb = await MongoMemoryReplSet.create();
  });

  beforeEach(async () => {
    process.env.DATABASE_URL = mongodb.getUri('test');

    const module: TestingModule = await Test.createTestingModule({
      controllers: [EventController],
      providers: [EventService,PrismaService,BlockchainService],
    }).compile();

    controller = module.get<EventController>(EventController);
    eventModel = module.get<Event>(Event);
  });

  afterEach(async () => {
    await prisma.event.deleteMany({});

  })

  afterAll(async () => {
    await mongodb.stop();
  });



  it('Should throw an error if event id is not valid',async  () => {
    await expect(() => controller.getEvent('63bbd31c7a644b96fc34dc28')).toThrow(
      BadRequestException);
  });
});

Debug Output

Debug Output
EventController › Should throw an error if event id is not valid

    Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"

Do you know why it happenes?

no

@lyj711 lyj711 added the bug label Jan 10, 2023
@hasezoey
Copy link
Collaborator

known issue, nothing MMS can do about - there are just no Ubuntu 2204 binaries yet, so MMS falls back to 2004 binaries, but those require OpenSSL 1.1, and Ubuntu 2204 only ships 3.x, so your options are:

  • downgrade ubuntu version
  • manually install openssl 1.1
  • wait for mongodb to drop a binary for 2204
  • use the mongodb packages from APT and set a system binary environment variable as a workaround *1

see https://jira.mongodb.org/browse/SERVER-62300
TL;DR: they are planning to add a ubuntu 2204 binary for 6.0.4

*1 somehow in ubuntu APT archives, there are mongodb builds for ubuntu 2204, but no "official" mongodb builds (Official builds can be found here)

@hasezoey hasezoey added Distribution support Add / modify an (linux) distribution not a MMS issue This is not an issue for "mongodb-memory-server" labels Jan 10, 2023
@hasezoey hasezoey changed the title a library is missing or cannot be opened: "libcrypto.so.1.1" Support Ubuntu 22.04 properly (Error: libcrypto.so.1.1 missing) Jan 10, 2023
@MichaelJCole
Copy link

MichaelJCole commented Jan 15, 2023

See also: shelfio/jest-mongodb#408

I have mongodb running all over the place on 22.04 with docker.

Would it be possible to substitute the binary download for a docker command?

In my experience, mongodb is much more focused on their Atlas platform than the community editions, so this might be one of many future issues like this. I spent hours on a workaround but came up empty. I'm probably not the first. I saw someone else suggest packaging mongo with the library in a snap or appimage, but I don't know how to do that (or if it would work)

Here is a reproduction:

git clone  git@github.com:renatops1991/clean-code-api.git 
cd clean-code-api
npm install
npm run test

This will come at the issue through jest-mongo

@hasezoey
Copy link
Collaborator

Would it be possible to substitute the binary download for a docker command?

MMS is currently not build to use anything other than the direct binary, you currently have 2 options:

  • automatic download, assuming the binary exists there
  • use a manual binary and let MMS use that (namely SYSTEM_BINARY config option)

i dont think MMS will add the ability to use anything other than the direct binary, though you could also just run MMS inside a container and let it use a binary there

@hasezoey
Copy link
Collaborator

update, there is now mongodb 6.0.4, which has a build for ubuntu 2204 (though that version is seemingly not documented yet)

build 6.0.4 ubuntu2204

@hasezoey hasezoey removed the bug label Jan 19, 2023
@github-actions
Copy link

@github-actions github-actions bot added the released Pull Request released | Issue is fixed label Jan 19, 2023
@hasezoey
Copy link
Collaborator

Note: for now it still required to set a custom mongodb version with at least 6.0.4 (currently default for MMS 8.x is still mongodb 5.0.x, see config option VERSION

see When a Version gets upgraded

@forivall
Copy link

if someone needs 6.0.3 for any weird reason, i found that the .deb download contains a version which should work #686 (comment)

@sagrawal31
Copy link

sagrawal31 commented Jun 20, 2023

Still facing the problem in GitLab node:lts on GitLab CI (after setting export MONGOMS_VERSION=6.0.4)-

Running with gitlab-runner 16.1.0~beta.5.gf131a6a2 (f131a6a2)
  on green-5.shared.runners-manager.gitlab.com/default xS6Vzpvo, system ID: s_d878f787d8ea
  feature flags: FF_USE_IMPROVED_URL_MASKING:true
Preparing the "docker+machine" executor
Using Docker executor with image node:lts ...

#480 (comment) fixed it for me for the time being.

@hasezoey
Copy link
Collaborator

docker image node:lts is currently based on debian:12

there are currently no native binaries for debian 12, last being debian 11, i assume debian 12 changes the libcrypto version like ubuntu 22 did, maybe try to use the ubuntu 22 binary via config option ARCHIVE_NAME
(valid archive names can be found here, use the .tgz archives)

@sagrawal31
Copy link

Thanks, @hasezoey. I changed to node:lts-bullseye and it worked.

@olof-nord
Copy link

This error is occurring for me too - trying to upgrade from Node.js v18.18.2 to v20.

NodeJS: 20.9.0
mongodb-memory-server-*: 9.1.1
mongodb(the binary version): 6.0.6
mongodb(the js package): 5.9.2
system: Ubuntu

does anyone have any ideas how to resolve this?

@hasezoey
Copy link
Collaborator

hasezoey commented Jan 3, 2024

This error is occurring for me too - trying to upgrade from Node.js v18.18.2 to v20.

this issue has nothing to do with a nodejs version upgrade, if you have such issues, please open a new issue

@olof-nord
Copy link

This error is occurring for me too - trying to upgrade from Node.js v18.18.2 to v20.

this issue has nothing to do with a nodejs version upgrade, if you have such issues, please open a new issue

Many thanks for the quick reply. So it turns out the problem was somewhere else (CI) - the search results led me here though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Distribution support Add / modify an (linux) distribution not a MMS issue This is not an issue for "mongodb-memory-server" released Pull Request released | Issue is fixed
Projects
None yet
Development

No branches or pull requests

6 participants