[SERVER-77253] permission issue running as a service on WSL2 Created: 17/May/23  Updated: 17/May/23  Resolved: 17/May/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 7.0.0-rc1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mike Shen Assignee: Chris Kelly
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

1. Prerequisites: clean Windows / Ubuntu WSL2 install

2. Follow instructions here for "Install MongoDB".

https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database

3. Continue with "Add the init script to start MongoDB as a service"

MongoDB will not start.

Participants:

 Description   

mongoDB install as a service on WSL2 does not work due to permissions issue with PIDFILE.

in "init.d" file, Line 149 creates the PIDFILE with sudo priviledges.
When mongodb is started up as a service, it's started as mongodb:mongodb. This prevents access to the PIDFILE, which prevents mongodb from running.



 Comments   
Comment by Mike Shen [ 17/May/23 ]

I'm in a coding bootcamp and a bunch of us ran into the same issue.  I think we were all on Windows 11, if that makes any difference.

I'm fairly new at this - so yeah, the sudo touch definitely might not be the best way about it.

For the issue itself, I'm good to go - the change worked for me.

Thanks for responding so quickly.  It's cool to see you guys actually responding to issues.

 

Comment by Chris Kelly [ 17/May/23 ]

Hey michael.m.shen@gmail.com! Thanks for your report and PR.

WSL isn't supported by MongoDB officially. As for suggesting to add sudo touch $PIDFILE to debian/init.d, I'm not sure if that's exactly what we'd want to try first. That said, I use MongoDB on WSL and don't have these issues with it (running as binaries, not as services installed via package manager). I would probably be interested in other permissions issues on the system that could be interfering first, since this is functionality we've had in there for 8 years or longer without incident.

MongoDB does not maintain the docs for Microsoft, so officially we'd recommend using our reference for installing. 

If you're looking to try out MongoDB on WSL (for testing purposes) I personally use m to manage this. That said, if there are permissions issues on the WSL side, figuring out a solution to that outside of MongoDB is likely appropriate. If there has been change in behavior between versions, that would be something we'd possibly want to check out. 

For now I'm going to close this and ask you to start by asking our community for help by posting on the MongoDB Developer Community Forums with this info.

If the discussion there leads you to suspect a bug in the MongoDB server (with the understanding we don't support WSL), then we'd want to investigate it as a possible bug here in the SERVER project.

Chris

Generated at Thu Feb 08 06:34:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.