Skip to Content
Technical Articles
Author's profile photo Witalij Rudnicki

Running hdbcli on an Apple M1 chip: an alternative way with using arch command

Last week I switch from using Intel-based MacBook laptop (x86 architecture) to the one with Apple M1 (ARM64 architecture).

Recently Mathias Kemeter shared one approach of running hdbcli on an Apple M1 Chip: creating a copy of a terminal app that starts using Rosetta.

A look at arch command

I tried an alternative approach, that I would like to share here. It does not involve making a copy of the terminal application, but instead using arch command.

As man arch explains:

By default, the operating system will select the architecture that most closely matches the processor type. … The arch command can be used to alter the operating system’s normal selection order.

The arch command with no arguments, displays the machine’s architecture type.

Let’s run the command without any parameters on a new laptop with an Apple chip. It should return arm64 value.

To run a command that supports x86_64 translation mode, you can execute:

/usr/bin/arch -arch x86_64 <command>

One more helpful command will be sysctl to display, if a process is native or translated.

sysctl sysctl.proc_translated
/usr/bin/arch -arch x86_64 sysctl sysctl.proc_translated

A command or a binary you are running needs to support a given architecture as can be checked using file /path/to/binary:

file $(which sysctl)
file $(which zsh)

Interestingly, MacOS default’s Python is a universal library…

file $(which python3)
python3 -V
arch -arch x86_64 python3 -V

…which Python installed with conda is ARM64-only:

file $(which python)
python -V
arch -arch x86_64 python -V

Attempt to install hdbcli using pip on Apple silicon

If I try to install hdbcli using pip today (with no “universal” version of HDBCLI for Apple M1 available yet), then I get:

ERROR: Could not find a version that satisfies the requirement hdbcli (from versions: none)
ERROR: No matching distribution found for hdbcli

And what about the Miniconda?

Let us create a separate myhana Conda’s environment…

conda create -n myhana python=3.9
conda activate myhana

Still the same.

Start a shell as the x86_64 process

Let’s start a shell with x86_64 compatible architecture…

arch -x86_64 zsh
export PS1='x86$ '

…and check the architecture set for the session.

arch
uname -m

🤔 I must admit this i386 vs x86_64 is still confusing me. I will appreciate, if you share your explanation in comments, should you know why these two values are different.

Install hdbcli in x86_64 process

Now that we are in the x86_64 translated process, let’s try installing hdbcli using pip.

python3 -m pip install hdbcli
python3 -m pip show hdbcli

And what about Miniconda environment?

Unfortunately it does not work.

I assume, it is because it got arm64-compatible binary of Python only — as we have checked above. And I have not found a way yet to install universal binary of Python into a conda’s environment yet. Have you?

Bonus: Create a profile in a terminal application for an x86 translated mode

To streamline invoking a shell in an x86 translated mode you can create a separate profile.

I am using iTerm2 application, so this is how my setup looks like.

  1. Make a copy of the Default profile and called it “Rosetta Shell”,
  2. Change Command setting from “Login Shell” to “Command” with the value /usr/bin/arch -x86_64 /bin/zs.

As always, please share your ideas and feedback in comments below!

Thank you,
-Vitaliy

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Michael Eaton
      Michael Eaton

      My new M1 MacBook Pro arrived and I was so excited to get it! However, I'm still using my old intel MacBook as well! At this point in time, I would say that not many SAP ecosystem developers can make the switch.

      My M1 certainly uses less power, as it's turned off most of the time! 🙂

      Michael

      Author's profile photo Witalij Rudnicki
      Witalij Rudnicki
      Blog Post Author

      Looking forward to your tips and tricks with M1, Michael Eaton!

      Author's profile photo Piotr Tesny
      Piotr Tesny

      Hello, I do not have access to M1 hardware yet. But judging from other people's experience it looks like when it comes to running x86_64 tools or docker images on M1 the UTM is the way to go.

      You may also check this other blog https://blogs.sap.com/2021/12/16/how-to-install-abap-1909-on-mac-m1-apple-silicon/

      I hope that helps; cheers;Piotr

      Author's profile photo dylan drummond
      dylan drummond

      Nice blog Witalij. I never knew about any of this before so thanks for the information.

      Here is also one more UTM-based blog for Apple M1 users who want to run SAP NetWeaver Developer Edition (a.k.a. mini-SAP), which is of course an x86_64 application...

      https://blogs.sap.com/2022/03/31/qemu-and-sap-dev-edition-via-utm-for-macbook-m1/

       

      Author's profile photo Piotr Tesny
      Piotr Tesny

      Hello Dylan, nice blog of yours:)

      Yet another deployment option is k8s. This is what I have been doing ever since with, for instance, the likes of HANA Express (https://blogs.sap.com/2022/01/11/taming-sap-hana-express-database-docker-edition-with-k8s-gardener/) and, time permitting, might try it out with hdbcli...Why not?