5

I see something that resembles a C compiler error when I try installing ruby gem json 1.8.3

Here's the command I'm running:

gem install json -v '1.8.3'

And my output is:

Building native extensions.  This could take a while...
ERROR:  Error installing json:
        ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160327-27188-189i1cj.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.so
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.22 internal error, aborting at ../../bfd/reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make: *** [generator.so] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.1/gems/json-1.8.3 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/json-1.8.3/gem_make.out

I tried removing and installing packages binutils and build-essential but this did not fix the issue.

Some facts about my OS:

Debian GNU/Linux 7.9 (wheezy)

uname -a shows:

Linux Prometheus 2.6.32-042stab112.15 #1 SMP Tue Oct 20 17:22:56 MSK 2015 x86_64 GNU/Linux

I'm running this on an OpenVZ virtualized VPS host.

My /etc/apt/sources.list (if it helps):

deb http://ftp.debian.org/debian wheezy main contrib non-free
deb http://security.debian.org wheezy/updates main contrib non-free
deb http://packages.icinga.org/debian icinga-wheezy main
deb http://http.debian.net/debian wheezy-backports main
deb-src http://packages.icinga.org/debian icinga-wheezy main

Google produces zero relevant results for

BFD (GNU Binutils for Debian) 2.22 internal error, aborting at ../../bfd/reloc.c line 443 in bfd_get_reloc_size

If I can't "make" json gem because of linker error, please advise me into the right direction to go, maybe I can replace the compiler/linker with another version, or somehow circumvent installing things from source here? In general, any solution is welcome as soon as it helps install the json gem and proceed with my plan.

Big thanks in advance!

CryptoPiggy
  • 700
  • 2
  • 8
  • 21
  • Try 2.25 or 2.26 `Binutils`. – CryptoPiggy Mar 27 '16 at 08:12
  • Can you show `uname -a`? – AlexD Mar 27 '16 at 08:29
  • @AlexD uname -a: Linux Prometheus 2.6.32-042stab112.15 #1 SMP Tue Oct 20 17:22:56 MSK 2015 x86_64 GNU/Linux – Sergey Neskhodovskiy Mar 27 '16 at 08:36
  • You have outdated kernel for wheezy. Looks like you are running your system under some kind virtualization - google says it is most probably OpenVZ under old rhel6. It is possible that you problem is caused by incompatibility between old kernel and newer user space tools or you are hitting some memory or other limits set by virtualization. – AlexD Mar 27 '16 at 09:27
  • @AlexD thanks for your input, it's true I'm running this on a VPS (I've updated my ticket with the new info), but it has 6GB memory and most of it is free (as the **free** command shows), well I may be not knowledgeable emough in this area but looks like it shouldn't be a matter of memory limitation. On the other point, I am unlikely to get a kernel upgrade on this server, so are there any other things I can try? – Sergey Neskhodovskiy Mar 27 '16 at 11:41
  • @Alxs thanks, this was the clue I needed. I wrote an answer describing how I proceeded with your advise. – Sergey Neskhodovskiy Mar 27 '16 at 11:55
  • @SergeyNeskhodovskiy, I'm glad it helped! Please upvote/select my answer and comment. :) – CryptoPiggy Mar 27 '16 at 13:25
  • @Alxs I seem to not have the privilege to upvote yet, but I have marked your answer as accepted. Thanks once again. – Sergey Neskhodovskiy Mar 27 '16 at 13:54
  • You're welcome. Anytime! – CryptoPiggy Mar 27 '16 at 14:29

2 Answers2

4

Installing a newer version of binutils solved the issue for me.

As per advise by Alxs, I have installed binutils 2.26-8. I had to add this line:

deb http://ftp.de.debian.org/debian sid main

To my /etc/apt/sources.list, then I ran

apt-get update
apt-get install binutils

Which updated binutils to 2.26

Then I ran again:

gem install json -v '1.8.3'

And it went smooth this time.

IMPORTANT: Don't forget to remove this line:

deb http://ftp.de.debian.org/debian sid main

from your /etc/apt/sources.list after you're done, otherwise you'll keep installing future packages from sid repo from now on, which is not probably what you need.

the_storyteller
  • 2,335
  • 1
  • 26
  • 37
  • 1
    See following on how to install single package from unstable http://serverfault.com/questions/22414/how-can-i-run-debian-stable-but-install-some-packages-from-testing – AlexD Mar 27 '16 at 12:47
4

Try 2.25 or 2.26 Binutils as your 2.22 version is quite old.

CryptoPiggy
  • 700
  • 2
  • 8
  • 21