kstyrc / embedded-redis

Redis embedded server for Java integration testing
840 stars 368 forks source link

Permissions denied while trying to start with another Redis installation #59

Open IdanFridman opened 8 years ago

IdanFridman commented 8 years ago

I was trying to init the embedded redis this way on mac. I am using the unstable version so I am pointing it into the dir which I installed it at:

/Users/idan/servers/redis-unstable/

Now in my test class:

@Before public void init() { redisServer = new RedisServer(new File("/Users/idan/servers/redis-unstable/"), 6379); redisServer.start(); }

I am getting this exception:

edis.embedded.exceptions.EmbeddedRedisException: Failed to start Redis instance at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:42) at redis.embedded.RedisServer.start(RedisServer.java:9) at com.zone.world_map_service_web.LocationServiceTest.init(LocationServiceTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: java.io.IOException: Cannot run program "/Users/idan/servers/redis-unstable" (in directory "/Users/idan/servers"): error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:37) ... 29 more Caused by: java.io.IOException: error=13, Permission denied at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(UNIXProcess.java:248) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 30 more

I gave all permissions needed by chmod 777 recursive to the dir:

Idans-MBP:redis-unstable idan$ ls -la total 240 drwxr-xr-x@ 21 idan staff 714 Aug 29 20:31 . drwxr-xr-x 8 idan staff 272 Sep 11 18:27 .. -rwxr-xr-x@ 1 idan staff 8196 Sep 12 10:31 .DS_Store -rwxr-xr-x@ 1 idan staff 363 Aug 21 16:29 .gitignore -rwxr-xr-x@ 1 idan staff 634 Aug 21 16:29 00-RELEASENOTES -rwxr-xr-x@ 1 idan staff 53 Aug 21 16:29 BUGS -rwxr-xr-x@ 1 idan staff 1569 Aug 21 16:29 CONTRIBUTING -rwxr-xr-x@ 1 idan staff 1487 Aug 21 16:29 COPYING -rwxr-xr-x@ 1 idan staff 11 Aug 21 16:29 INSTALL -rwxr-xr-x@ 1 idan staff 4223 Aug 21 16:29 MANIFESTO -rwxr-xr-x@ 1 idan staff 151 Aug 21 16:29 Makefile -rwxr-xr-x@ 1 idan staff 6834 Aug 21 16:29 README.md drwxr-xr-x@ 13 idan staff 442 Sep 12 10:31 deps -rwxr-xr-x@ 1 idan staff 44471 Aug 21 16:29 redis.conf -rwxr-xr-x@ 1 idan staff 271 Aug 21 16:29 runtest -rwxr-xr-x@ 1 idan staff 280 Aug 21 16:29 runtest-cluster -rwxr-xr-x@ 1 idan staff 281 Aug 21 16:29 runtest-sentinel -rwxr-xr-x@ 1 idan staff 7109 Aug 21 16:29 sentinel.conf drwxr-xr-x@ 172 idan staff 5848 Sep 9 16:21 src drwxr-xr-x@ 12 idan staff 408 Aug 21 16:29 tests drwxr-xr-x@ 17 idan staff 578 Aug 21 16:29 utils

Any idea? Thanks.

kstyrc commented 8 years ago

Hi, sorry for a late response, I'm busy with other stuff these days. Try to build redis according to: http://redis.io/download#installation and then provide path to the binary executable:

redisServer = new RedisServer(new File("/Users/idan/servers/redis-unstable/src/redis-server"), 6379);

Hope it helps! ;)

orvyl commented 6 years ago

@kstyrc I'm encountering this same problem. I got your solution tho I'm using you library in my unit test which is running in a ec2 server (spawned by jenkins) and integrating the installation guide would be hassle because it means I really need to explicitly create the redis component outside my unit test code. I prefer using new RedisServer(port) rather than specifying an executable redis. Or did I missed something like I can set where the temporary redis-server can be put and executed instead of the default /tmp?

Caused by: java.io.IOException: Cannot run program "/tmp/1531365128824-0/redis-server-2.8.19" (in directory "/tmp/1531365128824-0"): error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:37)
    ... 24 more
Caused by: java.io.IOException: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 25 more
orvyl commented 6 years ago

I gave up. I think the problem is the os of our jenkins's slave are not compatible with the redis-server that the library is giving by default (alpine issue related?) so I really need to make and compile it within the server.

nmccready commented 5 years ago

My guess this is a permissions problem due to this file https://github.com/kstyrc/embedded-redis/blob/db9a01ba34ca160876cd5ece5c9cfc3e4b4a4dc0/src/main/java/redis/embedded/util/JarUtil.java .

nmccready commented 5 years ago

There is another thread that has the answer, but for me the embedded redis executable for unix is invalid and unable to run in alpine.

DmitryYaroslavtsev commented 4 years ago

In my case I found that /tmp dir was mounted without exec rights. Only as 'rw'. As a solution - change fstab file. 'mount -l' command shows me the following: tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1048576k)