Rails derailed again (and again)

Executive summary (aka TL;DR)

  1. Rails docs suck… erm, no. I mean they are great but most probably written by people who never actually had to use them.
  2. If you want to follow Rails Guides and install a fresh Rails environment on a vanilla Ubuntu 16.04LTS you need at least the following dependencies installed before you start:
    • ruby-dev
    • zlib1g-dev
    • libsqlite3-dev
    • gcc
    • make
    • g++

The full rant

When the first Rails happened to Ruby, it was a pure revelation. A big gulp of fresh air after all the Java stuff we had to deal with for years. First Rails was something to be truly happy with. At freakin’ last, building a simple web application became actually, well… simple. One could spawn a basic CRUD webapp in a timespan narrower than it would take to configure only the most vital XMLs for an application in one of the prominent Java Application Servers of the time. And I don’t even want to mention the dreadful experiences of pre-V5 PHP. Rails was different in a most positive way. Also because it was using a beautiful, “post-modernistic” language of Ruby. I quickly became “early adopter” as well as “advocate” of RoR (Ruby on Rails).

Still – at some point – realities started to get through the cloud of excitement. Like “OK – I have my beautiful application but where am I going to host it?”.  Ruby aware hosting services were scarce. Terribly scarce. You can imagine they were not the least expensive either. With some notable exception all the typical hosting companies of the time (of Rails 1 & 2) neither supported nor allowed self-installation of non-supported software. Things changed with the advent of VPS solutions but even today a typical, shared  LAMP hosting with everything you need to run your PHP/MySQL thing, costs about one tenth (if not less) than a minimal VPS capable of running your Rails. Yes, I know that there are some companies that specialise in Rails applications deployment and hosting without VPS, yet this doesn’t change the big picture much. The working ones are more expensive and not necessarily have the local reach a client needs. P. S. I know there is Heroku. I do 🙂

Another thing, and probably one of the reasons it’s always been hard to sway hosting companies to support Rails: Rails evolved, Ruby evolved, but it seems that both Ruby and Rails communities continue to nurture the “We are opinionated – deal with it” attitude, and don’t really care about making it easy for companies that would be willing to host and support Rails. The stubborn refusal (quote: we know Ruby better than any package maintainer and we know better how Ruby stuff should be installed and managed :unquote) to find a solution for proper inter-working between major OS distributors (Debian/Ubuntu/RedHat/..) packaging systems and Ruby made it a PITA for anyone trying provide this kind of support. Gosh, it became non-trivial even for skilled developers to create and maintain development environments for different versions of Ruby/Rails, which led to creation of specialised tools just for this purpose. Summing up – it became increasingly difficult to sell Rails development. “Why would I go for this if I can have half the costs, an order of magnitude more choices and far less vendor lock-in with PHP based solution?!”

I remember how for years I kept saying “if there is one language that I loathe more than PHP, it would be Javascript” and guess what (fate – it seems – is not without a sense of irony™) I ended up building applications using PHP and Javascript for several years after using Rails 1 and Rails 2. I still kept an eye on Rails’ development though and things didn’t change much in terms of “installability”, “maintainability” and “sellability”. One still couldn’t do a simple “apt-get install ruby” followed by “gem install rails” to have a ready Rails environment.

Years kept passing and an all new Rails 5(!)  is out there. Since the customer is going to use a VPS anyway – let’s build the application using the latest Rails. I am sure things must have changed since I left! I use the all fresh installation of Ubuntu’s 16.04LTS server distribution – something I humbly believe that not only /me is going to use for server-side development efforts over the next couple of years. The official Rails guide located at:

http://guides.rubyonrails.org/getting_started.html

states that I need to verify the version of Ruby installed. OK – obviously I need to install Ruby as the vanilla Ubuntu server installation doesn’t include any.

silverdr@ubuntu:~$ sudo apt-get install ruby

does the trick. Now:

silverdr@ubuntu:~$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

Looks good enough, doesn’t it? As next I should verify my sqlite3 version… WTH? I am not planning to use sqlite! So..? Oh, all right – let’s not spoil the fun before it even started. Let’s do the

silverdr@ubuntu:~$ sudo apt-get install sqlite3

just not to let anyone tell me that I didn’t follow the official guide…

silverdr@ubuntu:~$ sqlite3  --version
3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f

And this is all what the official guide says about prerequisites. Having both of those in place I should be ready to roll [the installation of Rails]. The guide says:

To install Rails, use the gem install command provided by RubyGems:

Since I don’t want to install things system-wide, I don’t use sudo…
$ gem install rails
Fetching: i18n-0.7.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.

Uh, oh… OK – let’s retry – surely nobody can account for every possible distribution and its configuration idiosyncrasies, can anyone? <sarcasm>Obviously Ubuntu is one of those obscure ones nobody uses for anything serious</sarcasm>. I give up my non-system-wide requirement and go with:

silverdr@ubuntu:~$ sudo gem install rails
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.gem (100%)
Successfully installed activesupport-5.0.0
Fetching: rack-2.0.1.gem (100%)
Successfully installed rack-2.0.1
Fetching: rack-test-0.6.3.gem (100%)
Successfully installed rack-test-0.6.3
Fetching: mini_portile2-2.1.0.gem (100%)
Successfully installed mini_portile2-2.1.0
Fetching: pkg-config-1.1.7.gem (100%)
Successfully installed pkg-config-1.1.7
Fetching: nokogiri-1.6.8.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
 ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20160804-3182-eo1yhv.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out

Uh, Oh… (2)… Let’s see what happened…

[…] mkmf.rb can’t find header files for ruby at /usr/lib/ruby/include/ruby.h […]

Seems having Ruby installed is not enough? Seems I still need something like Ruby development files, even if I don’t plan on developing anything compilable in Ruby dev-space? Let’s try:

silverdr@ubuntu:~$ sudo apt-get install ruby-dev

and let’s retry

silverdr@ubuntu:~$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20160804-3300-15qeff1.rb extconf.rb
Using pkg-config version 1.1.7
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
 --help
 --clean
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
 from /usr/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
 from /usr/lib/ruby/2.3.0/mkmf.rb:522:in `with_werror'
 from /usr/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
 from extconf.rb:138:in `nokogiri_try_compile'
 from extconf.rb:162:in `block in add_cflags'
 from /usr/lib/ruby/2.3.0/mkmf.rb:629:in `with_cflags'
 from extconf.rb:161:in `add_cflags'
 from extconf.rb:414:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out

Huh… ?

[…] You have to install development tools first.[…]

OK – which development tools? Since it says “Building native extensions” – then (probably!) it wants some kind of C compiler? Why not a Pascal or Fortran one? Don’t know – just guess out of the “checking if the C compiler accepts”.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/mkmf.log

The said file contains:

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC  conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3  -lpthread -lgmp -ldl -lcrypt -lm   -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Which obviously doesn’t say a damned thing about “why this extension failed to compile” but at least gives a hint that it tried to use gcc. Nice – gcc has support not only for C but also for Pascal and Fortran if that happens to be the case 🙂

silverdr@ubuntu:~$ sudo apt-get install gcc

and let’s retry

silverdr@ubuntu:~$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20160801-7575-t98pm.rb extconf.rb
Using pkg-config version 1.1.7
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
 --help
 --clean
 --use-system-libraries
 --enable-static
 --disable-static
 --with-zlib-dir
 --without-zlib-dir
 --with-zlib-include
 --without-zlib-include=${zlib-dir}/include
 --with-zlib-lib
 --without-zlib-lib=${zlib-dir}/lib
 --enable-cross-build
 --disable-cross-build

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out

Uh, Oh (3)…

"zlib is missing; necessary for building libxml2"

Ok, at this moment I have no damned idea what nokogiri is but I am sure I shouldn’t need to build libxml2!

But since I have no idea how to work this around, I guess I need to install zlib.

silverdr@ubuntu:~$ sudo apt-get install zlib1g
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g is already the newest version (1:1.2.8.dfsg-2ubuntu4).

Uh, Oh (4) – but zlib is there. Can’t you see that? Maybe (since it wants to build libxml2) it wants not only zlib but it’s dev files as well (Yeah, my bad. I should have guessed but why not to say that explicitly?).

silverdr@ubuntu:~$ sudo apt-get install zlib1g-dev

and let’s retry

silverdr@ubuntu:~$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20160801-9086-36hu2y.rb extconf.rb
Using pkg-config version 1.1.7
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.4.
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process andreinstall nokogiri as follows:

   gem install nokogiri -- --use-system-libraries
       [--with-xml2-config=/path/to/xml2-config]
       [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.4.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.4... OK
Running 'configure' for libxml2 2.9.4... OK
Running 'compile' for libxml2 2.9.4... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:344:in `spawn': No such file or directory - make (Errno::ENOENT)
from /var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:344:in `block in execute'
from /var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
from /var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
from /var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
from /var/lib/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
from extconf.rb:364:in `block (2 levels) in process_recipe'
from extconf.rb:257:in `block in chdir_for_build'
from extconf.rb:256:in `chdir'
from extconf.rb:256:in `chdir_for_build'
from extconf.rb:363:in `block in process_recipe'
from extconf.rb:262:in `tap'
from extconf.rb:262:in `process_recipe'
from extconf.rb:555:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out

Uh, Oh (5)… after going through the tons of useless information, the only one that seems to make some sense in the context of this particular failure is:

"2.1.0/lib/mini_portile2/mini_portile.rb:344:in `spawn': No such file or directory - make (Errno::ENOENT)"

Ah, obviously. It’s only my fault that I’ve been so braindead…

silverdr@ubuntu:~$ sudo apt-get install make

There are also some other pieces of information:

Building Nokogiri with a packaged version of libxml2-2.9.4.
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you […]

Of course it is a concern, isn’t it? Because of lack of a solution for inter-working between system  packages and Ruby gems I need to follow security updates on two levels and within two environments instead of one for the same piece of software! And obviously I have no idea what “doing their best” means to Team Nokogiri and how long is this Team Nokogiri going to be around, having any interest in providing security updates.

[…] and want to use the system library instead; abort this installation process andreinstall nokogiri as follows:
[…]
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.

Hello? Anybody home? That’s what versioning is about, isn’t it? How about the good, old way of checking for a compatible library version and using it if available, falling back to an own one only when compatible version is not present in the system and only when requested by the user/administrator to do so, NOT the other way around?

Make installed – let’s retry (again)

silverdr@ubuntu:~$ sudo gem install rails
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.8
[…]

Whoaaah!

Done installing [...]  rails after 58 seconds
28 gems installed

Whoa… (well) it took 58 seconds to install rails. After many, many times too many of them trying to do so.

The “Getting Started” guide now says:

To verify that you have everything installed correctly, you should be able to run the following:

$ rails –version

If it says something like “Rails 5.0.0”, you are ready to continue.

silverdr@ubuntu:~$ rails --version
Rails 5.0.0

Yesss!! I finally have a working Rails installation and am ready to continue! Hoorray! I am ready to continue (hopefully not more of the same?). OK. Now, let’s rock the world!

silverdr@ubuntu:~$ rails new myworldrockingproject
 create 
 create README.md
 create Rakefile
 create config.ru
 create .gitignore
 create Gemfile
 create app
 create app/assets/config/manifest.js
 create app/assets/javascripts/application.js
 create app/assets/javascripts/cable.js
 create app/assets/stylesheets/application.css
 create app/channels/application_cable/channel.rb
 create app/channels/application_cable/connection.rb
 create app/controllers/application_controller.rb
 create app/helpers/application_helper.rb
 create app/jobs/application_job.rb
 create app/mailers/application_mailer.rb
 create app/models/application_record.rb
 create app/views/layouts/application.html.erb
 create app/views/layouts/mailer.html.erb
 create app/views/layouts/mailer.text.erb
 create app/assets/images/.keep
 create app/assets/javascripts/channels
 create app/assets/javascripts/channels/.keep
 create app/controllers/concerns/.keep
 create app/models/concerns/.keep
 create bin
 create bin/bundle
 create bin/rails
 create bin/rake
 create bin/setup
 create bin/update
 create config
 create config/routes.rb
 create config/application.rb
 create config/environment.rb
 create config/secrets.yml
 create config/cable.yml
 create config/puma.rb
 create config/spring.rb
 create config/environments
 create config/environments/development.rb
 create config/environments/production.rb
 create config/environments/test.rb
 create config/initializers
 create config/initializers/application_controller_renderer.rb
 create config/initializers/assets.rb
 create config/initializers/backtrace_silencers.rb
 create config/initializers/cookies_serializer.rb
 create config/initializers/cors.rb
 create config/initializers/filter_parameter_logging.rb
 create config/initializers/inflections.rb
 create config/initializers/mime_types.rb
 create config/initializers/new_framework_defaults.rb
 create config/initializers/session_store.rb
 create config/initializers/wrap_parameters.rb
 create config/locales
 create config/locales/en.yml
 create config/boot.rb
 create config/database.yml
 create db
 create db/seeds.rb
 create lib
 create lib/tasks
 create lib/tasks/.keep
 create lib/assets
 create lib/assets/.keep
 create log
 create log/.keep
 create public
 create public/404.html
 create public/422.html
 create public/500.html
 create public/apple-touch-icon-precomposed.png
 create public/apple-touch-icon.png
 create public/favicon.ico
 create public/robots.txt
 create test/fixtures
 create test/fixtures/.keep
 create test/fixtures/files
 create test/fixtures/files/.keep
 create test/controllers
 create test/controllers/.keep
 create test/mailers
 create test/mailers/.keep
 create test/models
 create test/models/.keep
 create test/helpers
 create test/helpers/.keep
 create test/integration
 create test/integration/.keep
 create test/test_helper.rb
 create tmp
 create tmp/.keep
 create tmp/cache
 create tmp/cache/assets
 create vendor/assets/javascripts
 create vendor/assets/javascripts/.keep
 create vendor/assets/stylesheets
 create vendor/assets/stylesheets/.keep
 remove config/initializers/cors.rb
 run bundle install
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies......


Your user account isn't allowed to install to the system Rubygems.
 You can cancel this installation and run:

 bundle install --path vendor/bundle

 to install the gems into ./vendor/bundle/, or you can enter your password
 and install the bundled gems to Rubygems using sudo.

 Password:

Errmm… what? I thought I was already done “installing to the system Rubygems” after those “58 seconds”. Now I am no longer the admin. I am a developer that wants to use what the admin has already installed and verified according to the “Getting Started” guide! What else do I have to install to “system Rubygems” in order to get the thing create a basic application structure?!

Oh, boy… I give up and give down [the administrative password].

Installing rake 11.2.2
Using concurrent-ruby 1.0.2
Using i18n 0.7.0
Installing minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 2.0.1
Using nio4r 1.2.1
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.1
Using bundler 1.12.5
Installing byebug 9.0.5 with native extensions
Installing coffee-script-source 1.10.0
Installing execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.1
Installing debug_inspector 0.0.2 with native extensions
Installing ffi 1.9.14 with native extensions
Installing multi_json 1.12.1
Installing rb-fsevent 0.9.7
Installing puma 3.6.0 with native extensions
Installing sass 3.4.22
Installing tilt 2.0.5
Installing spring 1.7.2
Installing sqlite3 1.3.11 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 current directory: /tmp/bundler20160804-25167-125cccxsqlite3-1.3.11/gems/sqlite3-1.3.11/ext/sqlite3
/usr/bin/ruby2.3 -r ./siteconf20160804-25167-cc2c7o.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
 --with-sqlite3-dir
 --without-sqlite3-dir
 --with-sqlite3-include
 --without-sqlite3-include=${sqlite3-dir}/include
 --with-sqlite3-lib
 --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

 /tmp/bundler20160804-25167-125cccxsqlite3-1.3.11/extensions/x86_64-linux/2.3.0/sqlite3-1.3.11/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20160804-25167-125cccxsqlite3-1.3.11/gems/sqlite3-1.3.11 for inspection.
Results logged to /tmp/bundler20160804-25167-125cccxsqlite3-1.3.11/extensions/x86_64-linux/2.3.0/sqlite3-1.3.11/gem_make.out
Installing turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.6.8
Using rack-test 0.6.3
Using sprockets 3.7.0
Using websocket-driver 0.6.4
Using mime-types 3.1
Installing coffee-script 2.4.1
Installing uglifier 3.0.1
Installing rb-inotify 0.9.7
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
 run bundle exec spring binstub --all
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.

Uh, Oh (6)… I mean – really? Couldn’t you guys *really* check all the dependencies for a *working* installation when I first issued “gem install rails”? Something like: “this, this and that is missing on your system” and stop? Couldn’t you install all the stuff when doing “gem install rails”? Really? Couldn’t you do that so that once the administrator is gone home (or doing other important stuff) the developer can just follow your guide and have things *working*?!

At least here (hidden among tons of other things) you tell me in plain English what I need to install, without making me do another guessing round.

silverdr@ubuntu:~$ sudo apt-get install libsqlite3-dev
silverdr@ubuntu:~$ rails new myworldrockingproject
 create 
 create README.md
 create Rakefile
 create config.ru
 create .gitignore
 create Gemfile
 create app
 create app/assets/config/manifest.js
 create app/assets/javascripts/application.js
 create app/assets/javascripts/cable.js
 create app/assets/stylesheets/application.css
 create app/channels/application_cable/channel.rb
 create app/channels/application_cable/connection.rb
 create app/controllers/application_controller.rb
 create app/helpers/application_helper.rb
 create app/jobs/application_job.rb
 create app/mailers/application_mailer.rb
 create app/models/application_record.rb
 create app/views/layouts/application.html.erb
 create app/views/layouts/mailer.html.erb
 create app/views/layouts/mailer.text.erb
 create app/assets/images/.keep
 create app/assets/javascripts/channels
 create app/assets/javascripts/channels/.keep
 create app/controllers/concerns/.keep
 create app/models/concerns/.keep
 create bin
 create bin/bundle
 create bin/rails
 create bin/rake
 create bin/setup
 create bin/update
 create config
 create config/routes.rb
 create config/application.rb
 create config/environment.rb
 create config/secrets.yml
 create config/cable.yml
 create config/puma.rb
 create config/spring.rb
 create config/environments
 create config/environments/development.rb
 create config/environments/production.rb
 create config/environments/test.rb
 create config/initializers
 create config/initializers/application_controller_renderer.rb
 create config/initializers/assets.rb
 create config/initializers/backtrace_silencers.rb
 create config/initializers/cookies_serializer.rb
 create config/initializers/cors.rb
 create config/initializers/filter_parameter_logging.rb
 create config/initializers/inflections.rb
 create config/initializers/mime_types.rb
 create config/initializers/new_framework_defaults.rb
 create config/initializers/session_store.rb
 create config/initializers/wrap_parameters.rb
 create config/locales
 create config/locales/en.yml
 create config/boot.rb
 create config/database.yml
 create db
 create db/seeds.rb
 create lib
 create lib/tasks
 create lib/tasks/.keep
 create lib/assets
 create lib/assets/.keep
 create log
 create log/.keep
 create public
 create public/404.html
 create public/422.html
 create public/500.html
 create public/apple-touch-icon-precomposed.png
 create public/apple-touch-icon.png
 create public/favicon.ico
 create public/robots.txt
 create test/fixtures
 create test/fixtures/.keep
 create test/fixtures/files
 create test/fixtures/files/.keep
 create test/controllers
 create test/controllers/.keep
 create test/mailers
 create test/mailers/.keep
 create test/models
 create test/models/.keep
 create test/helpers
 create test/helpers/.keep
 create test/integration
 create test/integration/.keep
 create test/test_helper.rb
 create tmp
 create tmp/.keep
 create tmp/cache
 create tmp/cache/assets
 create vendor/assets/javascripts
 create vendor/assets/javascripts/.keep
 create vendor/assets/stylesheets
 create vendor/assets/stylesheets/.keep
 remove config/initializers/cors.rb
 run bundle install
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies......
Using rake 11.2.2
Using concurrent-ruby 1.0.2
Using i18n 0.7.0
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 2.0.1
Using nio4r 1.2.1
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.1
Using bundler 1.12.5
Using byebug 9.0.5
Using coffee-script-source 1.10.0
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.1
Using debug_inspector 0.0.2
Using ffi 1.9.14
Using multi_json 1.12.1
Using rb-fsevent 0.9.7
Using puma 3.6.0
Using sass 3.4.22
Using tilt 2.0.5
Using spring 1.7.2
Installing sqlite3 1.3.11 with native extensions
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.6.8
Using rack-test 0.6.3
Using sprockets 3.7.0
Using websocket-driver 0.6.4
Using mime-types 3.1
Using coffee-script 2.4.1
Using uglifier 3.0.1
Using rb-inotify 0.9.7
Installing turbolinks 5.0.1
Using activesupport 5.0.0
Using loofah 2.0.3
Using mail 2.6.4
Installing listen 3.0.8
Using rails-dom-testing 2.0.1
Using globalid 0.3.7
Using activemodel 5.0.0
Installing jbuilder 2.6.0
Using rails-html-sanitizer 1.0.3
Installing spring-watcher-listen 2.0.0
Using activejob 5.0.0
Using activerecord 5.0.0
Using actionview 5.0.0
Using actionpack 5.0.0
Using actioncable 5.0.0
Using actionmailer 5.0.0
Using railties 5.0.0
Using sprockets-rails 3.1.1
Installing coffee-rails 4.2.1
Installing jquery-rails 4.1.1
Installing web-console 3.3.1
Using rails 5.0.0
Installing sass-rails 5.0.6
Bundle complete! 15 Gemfile dependencies, 63 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
 run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted

Admittedly at this point I feel a little tired and a little too suspicious to say “Hoorray! My world rocking project using Rails 5 is ready to rock!!”

Let’s see if I can at least see the congrats page about me riding Rails… According to the “Getting Started” guide I should:

silverdr@ubuntu:~$ cd myworldrockingproject

followed by

silverdr@ubuntu:~/myworldrockingproject$ bin/rails server

Guess what? Yes, you guessed right. Instead of seeing the message where I should direct my browser to, I see:

silverdr@ubuntu:~/myworldrockingproject$ bin/rails server
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:89:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/var/lib/gems/2.3.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/var/lib/gems/2.3.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/var/lib/gems/2.3.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/var/lib/gems/2.3.0/gems/uglifier-3.0.1/lib/uglifier.rb:5:in `require'
/var/lib/gems/2.3.0/gems/uglifier-3.0.1/lib/uglifier.rb:5:in `<top (required)>'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `require'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
/home/silverdr/myworldrockingproject/config/application.rb:7:in `<top (required)>'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `require'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `block in server'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
/home/silverdr/myworldrockingproject/bin/rails:9:in `require'
/home/silverdr/myworldrockingproject/bin/rails:9:in `<top (required)>'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
/var/lib/gems/2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
/var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/silverdr/myworldrockingproject/bin/spring:13:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:85:in `block (2 levels) in require'
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
 from /var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
 from /home/silverdr/myworldrockingproject/config/application.rb:7:in `<top (required)>'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `require'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `block in server'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
 from /var/lib/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
 from /home/silverdr/myworldrockingproject/bin/rails:9:in `require'
 from /home/silverdr/myworldrockingproject/bin/rails:9:in `<top (required)>'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
 from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /home/silverdr/myworldrockingproject/bin/spring:13:in `<top (required)>'
 from bin/rails:3:in `load'
 from bin/rails:3:in `<main>'

And you know what? At this point I start feeling like I’ve got enough of all the errors and stack traces. I mean – WTF (no, not “WTH” – it’s “WTF”) – everything should have been installed already. And if I wanted to have server-side “JavaScript runtime”, I would go for Node and Sails, rather than Ruby and Rails. And if you need all those things for something, then why on Earth can’t you put up a list of prerequisites / dependencies to follow before even starting to try to guess “why [TF] did it break again this time?”.

Do I have to show how little, compared to this, does it take to have a working application stub with PHP5 and Laravel (probably the best PHP based Rails copycat) on the very same server?

And now what? I already have tons of stuff I don’t want. I installed many packages I shouldn’t need to install – we are talking about server environment here, where every unnecessary piece of code can at some point turn itself into an attack vector and now I seemingly should install another heavyweight because people around the net say that I need to install node.js – damn, NO!

Fortunately not everyone suggests installing Node:

In your Gemfile, you’ll notice that there is the therubyracer gem referenced (but commented out). It is one of the supported runtimes.

Thus, you could just uncomment this gem, run bundle install and be set.

I uncommented the gem in my Gemfile and ran bundle install in order to “be set”:

silverdr@ubuntu:~/myworldrockingproject$ bundle install
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies...
Using rake 11.2.2
Using concurrent-ruby 1.0.2
Using i18n 0.7.0
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 2.0.1
Using nio4r 1.2.1
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.1
Using bundler 1.12.5
Using byebug 9.0.5
Using coffee-script-source 1.10.0
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.1
Using debug_inspector 0.0.2
Using ffi 1.9.14
Using multi_json 1.12.1


Your user account isn't allowed to install to the system Rubygems.
 You can cancel this installation and run:

 bundle install --path vendor/bundle

 to install the gems into ./vendor/bundle/, or you can enter your password
 and install the bundled gems to Rubygems using sudo.

 Password: 
Installing libv8 3.16.14.15
Using rb-fsevent 0.9.7
Using puma 3.6.0
Installing ref 2.0.0
Using sass 3.4.22
Using tilt 2.0.5
Using spring 1.7.2
Using sqlite3 1.3.11
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.6.8
Using rack-test 0.6.3
Using sprockets 3.7.0
Using websocket-driver 0.6.4
Using mime-types 3.1
Using coffee-script 2.4.1
Using uglifier 3.0.1
Using rb-inotify 0.9.7
Installing therubyracer 0.12.2 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 current directory: /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
/usr/bin/ruby2.3 -r ./siteconf20160804-29493-1ejo91s.rb extconf.rb
checking for main() in -lpthread... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

 /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/mkmf.log

current directory: /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
make "DESTDIR=" clean

current directory: /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
make "DESTDIR="
compiling accessor.cc
make: g++: Command not found
Makefile:207: recipe for target 'accessor.o' failed
make: *** [accessor.o] Error 127

make failed, exit code 2

Gem files will remain installed in /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/gems/therubyracer-0.12.2 for inspection.
Results logged to /tmp/bundler20160804-29493-jefatxtherubyracer-0.12.2/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/gem_make.out
Using turbolinks 5.0.1
Using activesupport 5.0.0
Using loofah 2.0.3
Using mail 2.6.4
Using listen 3.0.8
An error occurred while installing therubyracer (0.12.2), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.2'` succeeds before bundling.

Nice. Do I really still want to rock the world with Rails 5 based project?

 

Advertisements
This entry was posted in Rails, Rants and tagged , , , , . Bookmark the permalink.

4 Responses to Rails derailed again (and again)

  1. I tired of RoR says:

    Welcome back to RoR world, I am looking a possibility to leave it and hopefully never be back, it is hopeless.
    I do not remember where did I found it, but couple of years ago I read a post, which said that therubyracer pretty slow and resource intensive, so one should prefer node for javascript environment.

  2. It’s Feb 2017 and I have almost exactly the same errors using the latest Ubuntu. Hard to believe this is so bad, and Jekyll iis easier to install on Windows 10 that Linux !!!

    • silverdrs says:

      It is only for one environment/application. I haven’t even touched the subject of running multiple applications, especially with different versions of Ruby/Rails on one server… With one version and application, once you know all the prerequisites, it is not THAT difficult. Yet the key part is “once you know all the prerequisites”. And how is one supposed to know them if only two listed in the official docs are ruby and sqlite, the latter of which I for example don’t need/use at all? Once I am done with the project, I plan on giving them a pull request. Maybe they accept it. If not and until then people need to lose lots of unnecessary time and hunt installation bugs on their own.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s