Installing Jekyll on Ubuntu 14.04

2019-01-14 09:49发布

问题:

I've been having some issues installing Jekyll on Ubuntu. Here are some of the versions I have:

trevor~$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
trevor~$ gem -v
2.5.1
trevor~$ rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

However, when I try to install Jekyll, I get these errors:

trevor~$ gem install jekyll
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.

    current directory: /home/trevor/.rvm/gems/ruby-2.2.4/gems/ffi-1.9.10/ext/ffi_c
/home/trevor/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20151229-11854-1czjp2r.rb extconf.rb
*** 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=/home/trevor/.rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/home/trevor/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /home/trevor/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
    from /home/trevor/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
    from /home/trevor/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:637:in `try_ldflags'
    from /home/trevor/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:1780:in `pkg_config'
    from extconf.rb:15:in `<main>'

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

  /home/trevor/.rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0/ffi-1.9.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/trevor/.rvm/gems/ruby-2.2.4/gems/ffi-1.9.10 for inspection.
Results logged to /home/trevor/.rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0/ffi-1.9.10/gem_make.out

Or if I use sudo:

trevor~$ sudo gem install jekyll
ERROR:  Error installing jekyll:
    jekyll requires Ruby version >= 2.0.0.

I have tried installing multiple versions of ruby-dev as recommended by others with a similar issue, but this hasn't seemed to help either.

trevor~$ sudo apt-get install ruby2.2.4-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ruby2.2.4-dev
E: Couldn't find any package by regex 'ruby2.2.4-dev'

Same thing happens with ruby2.0.0-dev. Running sudo apt-get install ruby-dev seems to install 1.9.3.4. Regardless, I still run into the same issues above.

Any ideas?

EDIT

Here is my rvm list:

trevor~$ rvm list

rvm rubies

   ruby-2.0.0-p643 [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.4 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

I did try installing a couple different versions. Would this cause a problem?

回答1:

I did try installing a couple different versions. Would this cause a
problem?

No

Follow the given step would help.

1: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

2: \curl -sSL https://get.rvm.io | bash # install RVM (development version)

3: rvm get head # Make Sure RVM up to date

4: rvm install ruby # will install latest version of ruby

5: rvm list # Listing install rubies will you get versions of ruby which is installed by RVM

6: rvm use < ruby-version > # for instances ruby-1.9.3-p125

7: gem install jekyll

Edit Update As you edited answer in your senerio

trevor~$ rvm list

rvm rubies

   ruby-2.0.0-p643 [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.4 [ x86_64 ]

rvm use 2.2.1
gem install jekyll

Would work !!!



回答2:

The error you are getting says it all ERROR: Error installing jekyll: jekyll requires Ruby version >= 2.0.0. You need a version of Ruby that is at least 2.0.0 or greater. I always recommend the latest version unless you need a different version for a specific reason.

So what you need to do is to compile a newer version of ruby. I recommend the latest version 2.3.0. You can download it from ruby-lang.org/en/download. Compiling isn't as hard as everyone says it is, there is a great write up from Compiling Easy HowTo. Once you have it compiled you should be able to install jekyll with the gem and get it up and running. If you have any problems or get any errors come back and I will do my best to help you.