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

Permission denied mac m1 #21

Closed
NorthlaneKek opened this issue Apr 28, 2023 · 19 comments
Closed

Permission denied mac m1 #21

NorthlaneKek opened this issue Apr 28, 2023 · 19 comments
Assignees

Comments

@NorthlaneKek
Copy link

NorthlaneKek commented Apr 28, 2023

Hey there. Trying to run embed Mongo in test environment but got stuck with this error:

Caused by: java.io.IOException: Cannot run program "/var/folders/yq/3bks5dkx1p5_87g951sn793c0000gn/T/extract-49a723c3-cedd-4d27-932a-5b5ce1211066extractmongod": error=13, Permission denied

I scrolled all the issues before, tried to set de.flapdoodle.embed.io.tmpdir (with System.setProperty)) and even the TMPDIR env variable to another folder. Unfortunately, the output is the same but with the another folder.
Version of flapdoodle.embed: 2.2.0
Spring boot: 2.2.6
OS: MacOS (M1 chip)

@michaelmosmann
Copy link
Member

@NorthlaneKek you are using a old version as you are using spring 2.2.6 .. and flapdoodle 2.2.0 .. is there any way to upgrade to at least spring 2.6.x?

@NorthlaneKek
Copy link
Author

@michaelmosmann unfortunately, I'm not able to upgrade spring right now

@michaelmosmann
Copy link
Member

@NorthlaneKek ,.. hmm.. flapdoodle 2.2.0 is quite old and there was a lot of refactoring done.. you can try to upgrade flapdoodle.mongo up to 3.5.4 and see if this works somehow.. and if 3.5.4 does not work make a step back until you get the newest version possible.. anything newer (>=4.x.x) will not work (or it would be a big surprise for me).

I guess that macos is preventing the execution of a binary inside of a temp folder.. so even with newer versions this problem might stick.

@michaelmosmann
Copy link
Member

@NorthlaneKek .. is your repo public?

@NorthlaneKek
Copy link
Author

NorthlaneKek commented May 2, 2023

@michaelmosmann sorry for the late response.
I bumped up the version of the lib to 3.5.4 as you said and there appeared the exception:
Could not find class [de.flapdoodle.embed.process.config.IRuntimeConfig]
I resolved it by adding (exclude = EmbeddedMongoAutoConfiguration.class) to the @SpringBootApplication annotation.

But, it seems that now mongo server doesn't even starts up. All I can see in logs related to mongo is:
Exception opening socket

P.S. repository is not public.
Is there any chance that 'not starting Mongo server' problem could be resolved by changing the versions of the lib or there should be any other ways?

@michaelmosmann
Copy link
Member

@NorthlaneKek I am not sure if I can backport all the changes to this spring version ... I must think about it...

@NorthlaneKek
Copy link
Author

@michaelmosmann oh, probably, it's my fault. I think it's better to make it clear now

  • 2.2.6 is the version of spring boot (spring itself is 5.2.5)
  • seems like I put this issue in the wrong repository: I'm using de.flapdoodle.embed.mongo, not de.flapdoodle.embed.mongo.spring
  • other teammates are not facing such problems with the same version of lib (2.2.0), spring (5.2.5) and spring boot (2.2.6)
  • if I use higher version of the lib (3.5.4) I see that embedded Mongo Server simply doesn't even try to start (maybe this version should be configured somehow the other way)

@michaelmosmann
Copy link
Member

@NorthlaneKek .. the spring versions are kind of .. missleading.. the mongodb integration is part of the spring boot project.. and i have some integrations for 2.6.x, 2.7.x and 3.0.x. This all started because spring wrote the first integrations by themself.. but misunderstood some parts of it. So i started to struggle with their misuse of "functionality" up to a point where any refactoring needed was not possible anymore. So i started to providing my own integration and spring stopped their integration with spring boot 3.0.0. ... some background for this.

other teammates are not facing such problems with the same version of lib (2.2.0), spring (5.2.5) and spring boot (2.2.6)

Same system? MacOS with M1?

if I use higher version of the lib (3.5.4) I see that embedded Mongo Server simply doesn't even try to start (maybe this version should be configured somehow the other way)

yeah.. there was a lot of api change needed to fix bugs and extend functionality ..

I think i try to make an backport to spring boot 2.2.0 and see if this works somehow.

@michaelmosmann
Copy link
Member

@NorthlaneKek

Caused by: java.io.IOException: Cannot run program "/var/folders/yq/3bks5dkx1p5_87g951sn793c0000gn/T/extract-49a723c3-cedd-4d27-932a-5b5ce1211066extractmongod": error=13, Permission denied

you can try to start the executable by yourself to see if you can fix this with setting the needed permission OR as you are using an M1 some emulation setup is needed as the mongodb binary is (if you are not using something newer .. like 6.x.x.) for an x86 cpu.

@NorthlaneKek
Copy link
Author

@michaelmosmann actually, as a more fast way to avoid all exceptions is to start mongo db in a docker container to pass all the tests (everything runs ok)

With 3.5.4 version I don't even see any mentions of "permission denied" exception. All I can see is that my application is unable to connect to localhost:27017 (and it's obvious because the application didn't even try to start the embedded mongo server and that's why there is no any 'permission denied' problem anymore)

@michaelmosmann
Copy link
Member

@NorthlaneKek i think spring failed to start the integration and eats most of the exceptions around it..

.. one way to go could be https://www.testcontainers.org/ ..

so if you are happy with your solution we could close this issue.. if not, it is easy to reopen.

@NorthlaneKek
Copy link
Author

NorthlaneKek commented May 4, 2023

@michaelmosmann it would be really great to find out any other solutions to run embed mongo server, because I'm the only one in the team who faces this problem. Of course, I can use testcontainers or something like this, but it's not really convenient :(

@michaelmosmann
Copy link
Member

@NorthlaneKek ok.. i will try.

@michaelmosmann
Copy link
Member

@NorthlaneKek my first attempt to backport it to 2.2.x failed .. so any solution will be a lot more tricky.. don't expect anything in the next two tweeks..

@NorthlaneKek
Copy link
Author

NorthlaneKek commented May 15, 2023

@michaelmosmann I spotted a pretty similar error here: flapdoodle-oss/de.flapdoodle.embed.mongo#422
and I saw you gave a link: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo.spring/blob/spring-2.7.x--embed-mongo-4.x/src/test/java/de/flapdoodle/embed/mongo/spring/autoconfigure/AutoConfigFirstIsolationTest.java
But now it shows 'not found content'
What exactly did you recommend?

P.S. extract-f....mongod file always created with such permissions: -rw-r--r--

@michaelmosmann
Copy link
Member

@NorthlaneKek .. the problem is here: the mongodb project changed the way how they store their archives for windows/macos/linux.. and the version you are using relies on the "old way" which stopped working with newer versions of mongodb, because the paths for the download are now different.. and not every version is supported on every platform..

so i had to solve this somehow .. and to solve this i had to change many other things.. so the old version you are using my work somehow in some cases.. but sometimes not anymore.. to fix this will be some kind of .. interesting.

@NorthlaneKek
Copy link
Author

@michaelmosmann is there any update?

@michaelmosmann
Copy link
Member

@NorthlaneKek i did not had enough time for a second try to backport this stuff to spring 2.2.x .. and i am afraid that there will be no further progress this week.. (just busy)

@michaelmosmann
Copy link
Member

@NorthlaneKek i guess this is still an issue.. but i did not find a way to backport this stuff.. if i can help in any other way, just ask.

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

No branches or pull requests

2 participants