flapdoodle-oss / de.flapdoodle.embed.mongo.spring

embedded mongo spring integration
Apache License 2.0
30 stars 7 forks source link

Permission denied mac m1 #21

Closed NorthlaneKek closed 10 months ago

NorthlaneKek commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

michaelmosmann commented 1 year ago

@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 commented 1 year ago

@NorthlaneKek .. is your repo public?

NorthlaneKek commented 1 year ago

@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 commented 1 year ago

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

NorthlaneKek commented 1 year ago

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

michaelmosmann commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@NorthlaneKek ok.. i will try.

michaelmosmann commented 1 year ago

@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 commented 1 year ago

@michaelmosmann I spotted a pretty similar error here: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/issues/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 commented 1 year ago

@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 commented 1 year ago

@michaelmosmann is there any update?

michaelmosmann commented 1 year ago

@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 commented 10 months ago

@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.