0

So I am installing Redmine and after installing all the prerequisites, the next step was (my home is /home/sbh/)

/home/sbh/SW/Ruby/dev/execprefix/bin/bundle install --path vendor/bundle --without development test

which resulted in (several) erros such as;

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/sbh/SW/Redmine/redmine/vendor/bundle/ruby/2.4.0
  /gems/sqlite3-1.3.11/ext/sqlite3
/home/sbh/SW/Ruby/dev/execprefix/bin/ruby -r 
./siteconf20160904-12703-1l1dktl.rb extconf.rb
mkmf.rb can't find header files for ruby at /home/sbh/SW/Ruby
  /dev/execprefix/lib/ruby/include/ruby.h
extconf failed, exit code 1

Gem files will remain installed in /home/sbh/SW/Redmine/redmine/vendor
  /bundle/ruby/2.4.0/gems/sqlite3-1.3.11 for inspection.
Results logged to /home/sbh/SW/Redmine/redmine/vendor/bundle/ruby/2.4.0
  /extensions/x86_64-linux/2.4.0-static/sqlite3-1.3.11/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

(I use vendor/bundle because I'm trying to keep the Ruby stuff dealing with redmine local - if I understand gem help install correctly) So I try this;

sbh@sbh-laptop-M18 ~/SW/Redmine/redmine $ /home/sbh/SW/Ruby
  /dev/execprefix/bin/gem install json -v '1.8.3'
Building native extensions.  This could take a while...
ERROR:  Error installing json:
ERROR: Failed to build gem native extension.

current directory: /home/sbh/SW/Ruby/dev/execprefix/lib/ruby/gems/2.4.0
  /gems/json-1.8.3/ext/json/ext/generator
/home/sbh/SW/Ruby/dev/execprefix/bin/ruby -r 
./siteconf20160904-13928-17xfuw8.rb extconf.rb
mkmf.rb can't find header files for ruby at /home/sbh/SW/Ruby
  /dev/execprefix/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/sbh/SW/Ruby/dev/execprefix
  /lib/ruby/gems/2.4.0/gems/json-1.8.3 for inspection.
Results logged to /home/sbh/SW/Ruby/dev/execprefix/lib/ruby/gems/2.4.0
  /extensions/x86_64-linux/2.4.0-static/json-1.8.3/gem_make.out

I did check that that location is not good, even the lowest folder doesn't exist, i.e. (no /include/);

sbh@sbh-MacBookPro ~ $ ls /home/sbh/SW/Ruby/dev/execprefix/lib/ruby/
2.4.0  gems  site_ruby  vendor_ruby

Also the make check succeeded in the build of Ruby from the svn (I understand this to be the dev branch and so I don't see why I would need to apt-get install any ruby-devs);

 svn co https://svn.ruby-lang.org/repos/ruby/trunk ruby

So I did this;

find . -name ruby.h -print -exec ls -Alrt {} \;

resulting in four files;

sbh@sbh-laptop-M18 ~/SW/Ruby $ find . -name ruby.h -print -exec ls 
  -Alrt {} \;
./dev/ruby/include/ruby.h
  -rw-r--r-- 1 sbh sbh 868 Sep  4 20:29 ./dev/ruby/include/ruby.h
./dev/ruby/include/ruby/ruby.h
  -rw-r--r-- 1 sbh sbh 77600 Sep  4 20:29 ./dev/ruby/include/ruby/ruby.h
./dev/prefix/include/ruby-2.4.0/ruby.h
  -rw-r--r-- 1 sbh sbh 868 Sep  4 20:29 ./dev/prefix/include/ruby-
  2.4.0/ruby.h
./dev/prefix/include/ruby-2.4.0/ruby/ruby.h
  -rw-r--r-- 1 sbh sbh 77600 Sep  4 20:29 ./dev/prefix/include/ruby-
   2.4.0/ruby/ruby.h

I don't know why there are four, or two judging by the size, though I don't see them as links...(?) So I added to ~/.profile, at the bottom;

export LD_LIBRARY_PATH=/home/sbh/SW/Ruby/dev/prefix/include/ruby-
  2.4.0/ruby/
export LD_LIBRARY_PATH=/home/sbh/SW/Ruby/dev/ruby/include/ruby/

and then ran sudo ldconfig and source ~/.profile. But it still didn't work after closing out terminal and starting it again.


Internet resulted in these ideas;

Error while installing json gem 'mkmf.rb can't find header files for ruby',

nokogiri will not install - ERROR: Failed to build gem native extension,

`require': no such file to load -- mkmf (LoadError)

but they all seem to want the OP to sudo apt-get install ruby-dev, and I only want to work off my 'local tree' - so no apt-get.

Shouldn't this be super simple? Or does Redmine somehow expect a certain path for these header files? Something maybe hardcoded for a default Ruby install?

Any ideas?

P.S. I want a 'local' build of Ruby much like Anaconda/Python...

P.P.S. I also realize that I could also use apt-get to only download the package to the archive, then use either dpkg or ar to extract the files, and then move them somewhere into my Ruby installation (I suppose a path too), but without adding any new PPAs, my default sources only cover up to ruby2.3-dev and my svn pulled 2.4. I don't know if there is any difference but I don't see why I can't get everything from ruby-lang.org...

P.P.P.S. When building Ruby, I put everything here;

./configure --prefix=/home/sbh/SW/Ruby/dev/prefix 
  --exec-prefix=/home/sbh/SW/Ruby/dev/execprefix 
  --oldincludedir=/home/sbh/SW/Ruby/dev/oldincludedir
Community
  • 1
  • 1
nate
  • 269
  • 2
  • 11
  • There is a package in apt called ruby-dev or ruby2.x-dev. It's s simple fix – max pleaner Sep 05 '16 at 05:32
  • So doesn't the svn co pull everything that would be in both rubyX and rubyX-dev? I want to avoid packages if at all possible, which I think it should be. – nate Sep 05 '16 at 05:45
  • I don't know about pulling from svn. But ruby and ruby-dev are separate packages. When the second is missing you get the error here. – max pleaner Sep 05 '16 at 05:48
  • Yeah, I'm sure... But still, it's not what I want - to use apt and install outside the directory tree. I now guess that neither the trunk nor the branch have all the needed files. I hope I don't have to ask ruby. – nate Sep 05 '16 at 05:52

1 Answers1

1

You're using the new-and-shiny 2.4.0.

It recently got a "unified Integer type", which combined BigDecimal and Fixnum into Integer.

Your project relies on the json rubygem, which is also a C-based extension. The json gem v1.8.3 doesn't know about the new way of handling numbers.

Here's how to demand a newer version of the json gem:

In your Gemfile, add:

gem 'json', '~> 2.0', '>= 2.0.2'

(That can be read as "at least the 2.0.x series", and also "at least 2.0.2".)

Hope this helps!

PS: Here is a typical patch which updates a C-based extension to this new way of handling numbers.

PPS: A workaround is to use ruby-build and build yourself a Ruby 2.3.1, which will support the gem versions that Redmine would install by default.

olleolleolle
  • 1,918
  • 16
  • 20