Rbenv BUILD FAILED (Raspbian 11 using ruby-build 20230717-7-gf170c16)

149 Views Asked by At

I am trying to install ruby 3.2.2 on a raspberry pi 4. I followed all the steps using the GitHub repository, git clone method but when I get to the rbenv install 3.2.2 I get what I assume to be an ARM related error which says this:

Logs

pi@raspberrypi:~ $ rbenv install 3.2.2
To follow progress, use 'tail -f /tmp/ruby-build.20230804022323.9672.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...

BUILD FAILED (Raspbian 11 using ruby-build 20230717-7-gf170c16)

Inspect or clean up the working tree at /tmp/ruby-build.20230804022323.9672.8D2OlO
Results logged to /tmp/ruby-build.20230804022323.9672.log

Last 10 log lines:
coroutine/arm64/Context.S:56: Error: bad instruction `ldp x21,x22,[sp,0x50]'
coroutine/arm64/Context.S:57: Error: bad instruction `ldp x23,x24,[sp,0x60]'
coroutine/arm64/Context.S:58: Error: bad instruction `ldp x25,x26,[sp,0x70]'
coroutine/arm64/Context.S:59: Error: bad instruction `ldp x27,x28,[sp,0x80]'
coroutine/arm64/Context.S:60: Error: bad instruction `ldp x29,x30,[sp,0x90]'
coroutine/arm64/Context.S:63: Error: ARM register expected -- `ldr x4,[sp,0xa0]'
coroutine/arm64/Context.S:66: Error: shift expression expected -- `add sp,sp,0xb0'
coroutine/arm64/Context.S:69: Error: bad instruction `ret x4'
make: *** [Makefile:468: coroutine/arm64/Context.o] Error 1
make: *** Waiting for unfinished jobs....

I found out it had something to do with trying to install armv7 on an aarch64 (what I am using). So I checked some things related to it and got this information:

User build

pi@raspberrypi:~ $ uname -m
aarch64

Toolchain

pi@raspberrypi:~ $ gcc -v
...
Target: arm-linux-gnueabihf
...

Made sure the toolchain was in my system path

pi@raspberrypi:~ $ which arm-linux-gnueabihf-gcc
/usr/bin/arm-linux-gnueabihf-gcc

With these informations confirmed, I tried installing it like this:

pi@raspberrypi1:~ $ CC=arm-linux-gnueabihf-gcc rbenv install 3.2.2
To follow progress, use 'tail -f /tmp/ruby-build.20230804035531.14026.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...

BUILD FAILED (Raspbian 11 using ruby-build 20230717-7-gf170c16)

Inspect or clean up the working tree at /tmp/ruby-build.20230804035531.14026.Mf7gAz
Results logged to /tmp/ruby-build.20230804035531.14026.log

Last 10 log lines:
coroutine/arm64/Context.S:56: Error: bad instruction `ldp x21,x22,[sp,0x50]'
coroutine/arm64/Context.S:57: Error: bad instruction `ldp x23,x24,[sp,0x60]'
coroutine/arm64/Context.S:58: Error: bad instruction `ldp x25,x26,[sp,0x70]'
coroutine/arm64/Context.S:59: Error: bad instruction `ldp x27,x28,[sp,0x80]'
coroutine/arm64/Context.S:60: Error: bad instruction `ldp x29,x30,[sp,0x90]'
coroutine/arm64/Context.S:63: Error: ARM register expected -- `ldr x4,[sp,0xa0]'
coroutine/arm64/Context.S:66: Error: shift expression expected -- `add sp,sp,0xb0'
coroutine/arm64/Context.S:69: Error: bad instruction `ret x4'
make: *** [Makefile:468: coroutine/arm64/Context.o] Error 1
make: *** Waiting for unfinished jobs....

Once that failed, I tried another method like this:

pi@raspberrypi:~ $ export CC=arm-linux-gnueabihf-gcc
pi@raspberrypi:~ $ rbenv install 3.2.2
To follow progress, use 'tail -f /tmp/ruby-build.20230804040854.7501.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...

BUILD FAILED (Raspbian 11 using ruby-build 20230717-7-gf170c16)

Inspect or clean up the working tree at /tmp/ruby-build.20230804040854.7501.FKpHuL
Results logged to /tmp/ruby-build.20230804040854.7501.log

Last 10 log lines:
coroutine/arm64/Context.S:56: Error: bad instruction `ldp x21,x22,[sp,0x50]'
coroutine/arm64/Context.S:57: Error: bad instruction `ldp x23,x24,[sp,0x60]'
coroutine/arm64/Context.S:58: Error: bad instruction `ldp x25,x26,[sp,0x70]'
coroutine/arm64/Context.S:59: Error: bad instruction `ldp x27,x28,[sp,0x80]'
coroutine/arm64/Context.S:60: Error: bad instruction `ldp x29,x30,[sp,0x90]'
coroutine/arm64/Context.S:63: Error: ARM register expected -- `ldr x4,[sp,0xa0]'
coroutine/arm64/Context.S:66: Error: shift expression expected -- `add sp,sp,0xb0'
coroutine/arm64/Context.S:69: Error: bad instruction `ret x4'
make: *** [Makefile:468: coroutine/arm64/Context.o] Error 1
make: *** Waiting for unfinished jobs....

That also failed and now I dont know how to install ruby using rbenv.

1

There are 1 best solutions below

0
David Grellscheid On

You probably are running a 32-bit userland on a 64-bit kernel, and the build script picks up the wrong architecture from uname -a. Setting the arch explicitly to 32 bit makes the build script pick up the right one.

setarch armv7l bash  # child shell now reports 32bit arch
rbenv install 3.2.2 # in the child shell

The explicit arch setting is only needed for the installation itself.