pymongo_inmemory icon indicating copy to clipboard operation
pymongo_inmemory copied to clipboard

TypeError: expected str, bytes or os.PathLike object, not int on self._mongod.start()

Open stevenmz opened this issue 1 year ago • 4 comments

Describe the bug subprocess fails to load mongod on os x

To Reproduce Steps to reproduce the behavior:

import pytest
from pymongo_inmemory import MongoClient

if not os.path.exists("mongo_dl_cache/download") or not os.path.exists("mongo_dl_cache/extract"):
    os.makedirs("mongo_dl_cache/download")
    os.makedirs("mongo_dl_cache/extract")
    os.makedirs("mongo_dl_cache/data")

os.environ["PYMONGOIM__DOWNLOAD_FOLDER"]="mongo_dl_cache/download"
os.environ["PYMONGOIM__MONGOD_PORT"]= "27017"
os.environ["PYMONGOIM__EXTRACT_FOLDER"]="mongo_dl_cache/extract"
os.environ["PYMONGOIM__MONGOD_DATA_FOLDER"]="mongo_dl_cache/data"
os.environ["PYMONGOIM__DOWNLOAD_URL"]="https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-6.0.12.tgz"

client = MongoClient()

Expected behavior MongoClient should connect.

Logs If applicable, add any kind of collected logs to help us understand the problem.

../../opt/anaconda3/envs/py311/lib/python3.11/site-packages/pymongo_inmemory/_pim.py:15: in init self._mongod.start() ../../opt/anaconda3/envs/py311/lib/python3.11/site-packages/pymongo_inmemory/mongod.py:142: in start self._proc = subprocess.Popen(boot_command) ../../opt/anaconda3/envs/py311/lib/python3.11/subprocess.py:1026: in init self._execute_child(args, executable, preexec_fn, close_fds, self = <Popen: returncode: None args: ['mongo_dl_cache/extract/c42eeac2efb615d0fe85...>

args = ['mongo_dl_cache/extract/c42eeac2efb615d0fe8562483f94326dcfeeb5a97cdeb3b4263c92a8ff27d04e/mongodb-macos-x86_64-6.0.12/bin/mongod', '--dbpath', 'mongo_dl_cache/data', '--logpath', 'mongo_dl_cache/data/mongod.log', '--port', ...] executable = b'mongo_dl_cache/extract/c42eeac2efb615d0fe8562483f94326dcfeeb5a97cdeb3b4263c92a8ff27d04e/mongodb-macos-x86_64-6.0.12/bin/mongod' preexec_fn = None, close_fds = True, pass_fds = (), cwd = None, env = None, startupinfo = None, creationflags = 0 shell = False, p2cread = -1, p2cwrite = -1, c2pread = -1, c2pwrite = -1, errread = -1, errwrite = -1 restore_signals = True, gid = None, gids

= None, uid = None, umask = -1, start_new_session = False, process_group = -1

Offending line: self.pid = _fork_exec( args, executable_list, close_fds, tuple(sorted(map(int, fds_to_keep))), cwd, env_list, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, errpipe_read, errpipe_write, restore_signals, start_new_session, process_group, gid, gids, uid, umask, preexec_fn, _USE_VFORK) E TypeError: expected str, bytes or os.PathLike object, not int

Context:

  • OS: OS X Ventura 13.5.1 Intel based
  • Version of pymongo_inmemory 0.4.0
  • Version of mongo you are downloading [e.g. 4.0] I have tried 6.0.12 and the latest 7.0.4

stevenmz avatar Nov 28 '23 00:11 stevenmz