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

can not start for mac, #127

Open
cayden-cheng opened this issue Jul 20, 2021 · 12 comments
Open

can not start for mac, #127

cayden-cheng opened this issue Jul 20, 2021 · 12 comments

Comments

@cayden-cheng
Copy link

can not start for mac
os version: mac os big sur 11.4
but when start in mac os catalina is ok。
is this the problem with m1 cpu or mac os ?

@lahmXu
Copy link

lahmXu commented Aug 2, 2021

+1

1 similar comment
@ruipeng110
Copy link

+1

@cayden-cheng
Copy link
Author

I think it's a big sur system problem, please give up
embedded-redis, try using brew to install redis

@idontusenumbers
Copy link

Seems the embedded redis binary isn't m1 and doesn't work with rosetta

@cayden-cheng
Copy link
Author

do you want say apple's arm64??

@idontusenumbers
Copy link

Apple M1 runs Mach-O 64-bit executable arm64 natively, yes.

@cayden-cheng
Copy link
Author

just want say,the apple m1 is terrible,just like bull shit....hope the laste version can be change it

@mmazurovsky
Copy link

mmazurovsky commented Dec 1, 2021

Hello!
This package ships with outdated Redis version that does not have support for Apple Silicon (M1). As can be seen from here, only Redis 6.0+ supports Apple Silicon.

So here is what you need to do to make embedded redis working:

  1. Follow the instruction, download and build Redis that supports Apple Silicon.
  2. Open the Redis directory, open src directory, find redis-server and get its absolute path, for example mine is "/Users/username/Code/Redis/redis-6.2.6/src/redis-server".
  3. In your code you will need to use the Redis executable that you have just obtained. For that create RedisExecProvider object and override redis executable that is used by default for the macOS:
    private val customRedisProvider: RedisExecProvider = RedisExecProvider.defaultProvider().override(OS.MAC_OS_X, Architecture.x86_64, "obtained/path/to/your/redis").override(OS.MAC_OS_X, Architecture.x86, "obtained/path/to/your/redis")
  4. Create RedisServer object with the RedisExecProvider you created previously.
    private val redisServer = RedisServer(customRedisProvider, redisPort)
  5. Just do redisServer.start(). This way you don't need to do additional setup for the Unix server as it will still use default Redis, not the one with Apple Silicon support.
    Hope this helps.

@idontusenumbers
Copy link

idontusenumbers commented Dec 3, 2021

I moved to using a TestContainer which can pull the docker image that has all architectures.

@HyunAh-iia
Copy link

HyunAh-iia commented Feb 24, 2022

Update your Mac OS Bigsur to Monterey

Before you try trying the @mmazurovsky 's solution, update your OS if you're using Bigsur.
I hava M1 Macbook pro 13 and used Bigsur OS.
After update, it works without any code changes!
It's a bigsur problem.

Still error?

Try @mmazurovsky 's solution. It's working well on Bigsur.

  1. Get redis binary file (arm)
    • $ wget https://download.redis.io/releases/redis-6.2.6.tar.gz
    • $ tar xzf redis-6.2.6.tar.gz
    • $ cd redis-6.2.6
    • $ make
    • Copy redis-6.2.6/src/redis-server file to your project.
  2. Running Redis server with redis binary file
    in my case, the file path is src/test/resources/binary/redis-server
@TestConfiguration
public class TestRedisConfig {
    private RedisServer redisServer;

    @PostConstruct
    public void setUp() throws IOException {
        final int redisDefaultPort = 6379;
        this.redisServer = getRedisServer(redisDefaultPort);
        redisServer.start();
    }

    @PreDestroy
    public void stopRedis() {
        if (Objects.nonNull(redisServer) && redisServer.isActive()) {
            redisServer.stop();
        }
    }

    private RedisServer getRedisServer(int port) throws IOException {
        if (isMacM1()) {
            return new RedisServer(
                    RedisExecProvider.defaultProvider()
                            .override(OS.MAC_OS_X, Architecture.x86_64, "binary/redis-server"),
                    redisPort);
        } else {
            return new RedisServer(redisPort);
        }
    }

    private boolean isMacM1() {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            return false;
        }

        return System.getProperty("os.arch").equals("aarch64") || System.getProperty("os.arch").equals("x86_64");
    }
}

@vjsantojaca
Copy link

This comment #135 (comment)

@coiouhkc
Copy link

coiouhkc commented Jun 28, 2024

Rosetta 2 support the Mach-0 x64 binary and starts it without problems under M2 Mac, still, using Testcontainers should be (imo) the better/preferred option.

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

No branches or pull requests

8 participants