Problem with Jekyll and Nokogiri installation - ruby

Im on ubuntu 18.04.2 LTS on Windows, and I have a rudimentary question. My objective is to use github template https://github.com/github/personal-website and publish it to username.github.io
I've a problem with step 4:
Build the site and make it available on a local server
bundle exec jekyll serve
hafidz#LAMBDA05:~/personal-website$ bundle exec jekyll serve
**Could not find nokogiri-1.10.1 in any of the sources**
Run `bundle install` to install missing gems.
It's already a runaround to install bundle, jekyll and nokogori, but i thought have that done. Does it need a path setup?
hafidz#LAMBDA05:~/personal-website$ bundle -v
Bundler version 2.0.1
hafidz#LAMBDA05:~/personal-website$ jekyll -v
Traceback (most recent call last):
12: from /usr/local/bin/jekyll:23:in `<main>'
11: from /usr/local/bin/jekyll:23:in `load'
10: from /var/lib/gems/2.5.0/gems/jekyll-3.8.5/exe/jekyll:11:in `<top (required)>'
9: from /var/lib/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
8: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:107:in `setup'
7: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:20:in `setup'
6: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:108:in `block in definition_method'
5: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:226:in `requested_specs'
4: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:237:in `specs_for'
3: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/definition.rb:170:in `specs'
2: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `materialize'
1: from /var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `map!'
/var/lib/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/spec_set.rb:87:in `block in materialize': Could not find nokogiri-1.10.1 in any of the sources (Bundler::GemNotFound)
hafidz#LAMBDA05:~/personal-website$ nokogiri -v
# Nokogiri (1.10.1)
---
warnings: []
nokogiri: 1.10.1
ruby:
version: 2.5.3
platform: x86_64-linux-gnu
description: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux-gnu]
engine: ruby
libxml:
binding: extension
source: packaged
libxml2_path: "/var/lib/gems/2.5.0/gems/nokogiri-1.10.1/ports/x86_64-pc-linux-gnu/libxml2/2.9.9"
libxslt_path: "/var/lib/gems/2.5.0/gems/nokogiri-1.10.1/ports/x86_64-pc-linux-gnu/libxslt/1.1.33"
libxml2_patches:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
libxslt_patches: []
compiled: 2.9.9
loaded: 2.9.9
appreciate helps

I saw something similar using Ubuntu WSL. I'd been following the Jekyll WSL instructions and got stuck. There was a nice hint on Dave Rupert's blog (link) that recommended the following and unblocked me: apt install zlibc zlib1g-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev
Here's a dump of my bash history for the session:
24 sudo apt install ruby
26 gem update jekyll
27 code .
28 sudo apt-get update -y && sudo apt-get upgrade -y
30 sudo gem update
31 sudo apt-add-repository ppa:brightbox/ruby-ng
32 sudo apt-get update
33 sudo apt-get install ruby2.5 ruby2.5-dev build-essential dh-autoreconf
35 sudo gem update
37 sudo gem install jekyll bundler
38 jekyll -v
40 sudo bundle update
45 sudo bundle install
47 sudo apt install zlibc zlib1g-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev
48 sudo gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'
49 sudo bundle install
51 bundle exec jekyll -v
52 bundle exec jekyll serve
54 sudo bundle update
56 bundle exec jekyll serve
57 history
58 history > history.txt

Related

Unable to install ruby from source in ubuntu 18.04 docker image

I am installing ruby 2.7.2 on a docker container that uses ubuntu:18.04.c I first tried to install rbenv but it did not offer the version I need so I resorted to installing from source. However when installing from source the make install does not pass. This is the method I used to install from source https://coderwall.com/p/3u__pq/install-ruby-from-source-on-ubuntu and this is what I looked at to resolve my issues to no avail Unable to locate package openssl-dev. Also I cannot install rvm as it is not picked up by bash.
docker file
#
# Ubuntu Dockerfile
#
# https://github.com/dockerfile/ubuntu
#
# Pull base image.
FROM ubuntu:18.04
ARG APP_NAME=<appname>
# Install.
RUN \
apt-get update && \
apt-get -y upgrade && \
apt-get install -y build-essential openssl libssl-dev zlib1g-dev&& \
apt-get install -y software-properties-common && \
apt-get install -y byobu curl git htop man unzip vim wget openssl libffi-dev &&\
rm -rf /var/lib/apt/lists/*
RUN \
wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2 &&\
tar -xf ruby-2.7.2.tar.bz2
RUN cd ruby-2.7.2
RUN pwd
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
RUN make
RUN make install
# Set environment variables.
EXPOSE 5000
ENV HOME /root
ENV PATH="${PATH}:/my/ruby/dir"
# Define working directory.
WORKDIR /root
COPY ${APP_NAME}/ ./${APP_NAME}/
# Define default command.
CMD ["bash"]
When I did make install it is complaining that openssl is not installed however I did do apt install openssl
*** Following extensions are not compiled:
openssl:
Could not be configured. It will not be installed.
/ruby-2.7.2/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
dbm:
Could not be configured. It will not be installed.
Check ext/dbm/mkmf.log for more details.
readline:
Could not be configured. It will not be installed.
/ruby-2.7.2/ext/readline/extconf.rb:62: Neither readline nor libedit was found
Check ext/readline/mkmf.log for more details.
gdbm:
Could not be configured. It will not be installed.
Check ext/gdbm/mkmf.log for more details.
zlib:
Could not be configured. It will not be installed.
Check ext/zlib/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
Later on this is the error message
Traceback (most recent call last):
11: from ./tool/rbinstall.rb:947:in `<main>'
10: from ./tool/rbinstall.rb:947:in `each'
9: from ./tool/rbinstall.rb:950:in `block in <main>'
8: from ./tool/rbinstall.rb:799:in `block in <main>'
7: from ./tool/rbinstall.rb:835:in `install_default_gem'
6: from ./tool/rbinstall.rb:835:in `each'
5: from ./tool/rbinstall.rb:845:in `block in install_default_gem'
4: from ./tool/rbinstall.rb:279:in `open_for_install'
3: from ./tool/rbinstall.rb:846:in `block (2 levels) in install_default_gem'
2: from /ruby-2.7.2/lib/rubygems/specification.rb:2430:in `to_ruby'
1: from /ruby-2.7.2/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
/ruby-2.7.2/lib/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- openssl (LoadError)
I think your problem is here
RUN cd ruby-2.7.2
RUN pwd
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
You cd into ruby-2.7.2 then attempt ./ruby-2.7.2/configure ... but you are already in the directory ruby-2.7.2 so this line
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
should fail.
Try replacing
RUN ./ruby-2.7.2/configure --prefix=/my/ruby/dir
with
RUN ./configure --prefix=/my/ruby/dir
You could clean up your Docerfile a bit as well by removing lines like
RUN pwd

You don't have write permissions for the /usr/lib/ruby/gems/2.7.0 directory (Alpine linux docker image)

I can not install ruby's gems on alpine docker image. I've tried different approaches from other questions to solve ERROR: While executing gem ... (Gem::FilePermissionError), but there are solutions either for Ubuntu or for Mac OS.
Part of docker file code:
RUN set -ex \
&& apk add --no-cache --update ruby ruby-dev ruby-bundler \
&& gem install --no-document --source https://rubygems.org --version 3.6.6 inspec
OUTPUT:
+ apk add --no-cache --update ruby ruby-dev ruby-bundler
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/11) Installing yaml (0.2.5-r0)
(2/11) Installing ruby-libs (2.7.3-r1)
(3/11) Installing ruby (2.7.3-r1)
(4/11) Installing ruby-etc (2.7.3-r1)
(5/11) Installing ruby-io-console (2.7.3-r1)
(6/11) Installing ruby-bundler (2.2.20-r0)
(7/11) Installing libgmpxx (6.2.1-r0)
(8/11) Installing gmp-dev (6.2.1-r0)
(9/11) Installing libucontext (1.1-r0)
(10/11) Installing libucontext-dev (1.1-r0)
(11/11) Installing ruby-dev (2.7.3-r1)
Executing busybox-1.33.1-r2.trigger
Executing glibc-bin-2.33-r0.trigger
/usr/glibc-compat/sbin/ldconfig: /usr/glibc-compat/lib/ld-linux-x86-64.so.2 is not a symbolic link
OK: 1409 MiB in 141 packages
+ gem install --no-document --source https://rubygems.org --version 3.6.6 inspec
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/lib/ruby/gems/2.7.0 directory.
The command '/bin/sh -c set -ex && apk add --no-cache --update ruby ruby-dev ruby-bundler && gem install --no-document --source https://rubygems.org --version 3.6.6 inspec' returned a non-zero code: 1 ```
This seems to be a problem with docker versions earlier than 20.10.4, and at the time of writing this, DockerHub runs an older version.
Option 1:
If you have control over the version of your docker engine, upgrade it to the latest version (comments suggest at least version 20.10.4).
Option 2:
Use FROM alpine:3.13.
With the latest alpine (3.14) it breaks.
Option 3:
Use the official ruby alpine image. I tested with FROM ruby:3-alpine.
References:
The issue opened on alpine/aports
The relevant release notes section for alpine 3.14

Installing libssl-dev on ubuntu for ruby 2.0

I tryed to install ruby 2.0 with rbenv on Ubuntu 12.04:
rbenv install 2.0.0-p247
Now I got the following error message:
Installing ruby-2.0.0-p247...
BUILD FAILED
Inspect or clean up the working tree at /tmp/ruby-build.20130801100032.13868
Results logged to /tmp/ruby-build.20130801100032.13868.log
Last 10 log lines:
installing default gems: /home/chris/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
bigdecimal 1.2.0
io-console 0.4.2
json 1.7.7
minitest 4.3.2
psych 2.0.0
rake 0.9.6
rdoc 4.0.0
test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?
In this Question Sam Ruby said I should install libssl-dev and I try it with:
sudo apt-get install libssl-dev
Now I got this error:
dpkg: Fehler: Parsen der Datei »/var/lib/dpkg/available«, nahe Zeile 10:
package name fehlt
E: Sub-process /usr/bin/dpkg returned an error code (2)
Could somebody explain me what is the problem and how can I solve it, please.
Your /var/lib/dpkg/available file got corrupted. You can fix it with the following:
Backup your existing /var/lib/dpkg/available via: sudo cp /var/lib/dpkg/available /var/lib/dpkg/available.backup
Then run the following, this will clear the file:
sudo dpkg --clear-avail
You should be able to install packages again as usual: sudo apt-get update && sudo install libssl-dev
Source: Ubuntu dpkg manpage
If none of the above helps, try asking on AskUbuntu

getting undefined symbol: rb_Digest_SHA1_Init error on rbenv installed ruby 2.0.0-p195

I am on ubuntu 12.04 and using ruby 2.0.0-p195 enabled by rbenv v0.4.0.
when I run below,
$ruby -rdigest/sha1 -e '1'
I get this error.
/home/ktsuji/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': /home/ktsuji/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/x86_64-linux/digest/sha1.so: undefined symbol: rb_Digest_SHA1_Init - /home/ktsuji/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/x86_64-linux/digest/sha1.so (LoadError)
from /home/ktsuji/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
I know this is really similar to issue described here:
Faulty ruby compilation with rvm: getting 'undefined symbol: rb_Digest_MD5_Init' while running racku
but I've already tried the answer in above thread and ran below:
$ sudo apt-get install zlib1g-dev libreadline6-dev libssl-dev libxml2-dev
and even tried reinstall:
$ sudo apt-get install --reinstall zlib1g-dev libreadline6-dev libssl-dev libxml2-dev
$ (rbenv uninstall -f 2.0.0-p195 && rbenv install 2.0.0-p195)
but had no luck. I've also tried other ruby versions with rbenv:
1.8.7-p371 works fine.
1.9.3-p429 got similar error as above.
Any idea on resolving this issue?

Failed to build gem native extension when install RedCloth-4.2.9 install Linux

I want to install Octopress in my computer.
I try to do it like
Octopress document.
When I run
bundle install
I got error message
An error occured while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
So, I run
sudo gem install RedCloth -v '4.2.9'
then, I got a error message again:
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
I hadn't learn any knowledge about ruby.
My ubuntu 12.04 solution is install the ruby1.9.1-full version, that can resolve this issue.
sudo apt-get install ruby1.9.1-full
you can execute command:
sudo update-alternatives --config ruby
to select the altiernative ruby which you have installed.
and then, execute below commands to finish the octopress deploy:
git clone https://github.com/erizhang/octopress.git octopress
cd octopress/
sudo gem install bundler
sudo gem install RedCloth -v '4.2.9'
bundle install
rake install
below commands you can find from octopress deploy guideline page:
rake setup_github_pages
sudo rake setup_github_pages
sudo rake generate
sudo rake deploy
Hope it's helpful for you, thanks
I was installing Octopress too and got the same problem as yours. After checking the mkmf.log file I figured out that gcc-4.2 had not been found. I Even installed xcode with the command line tools. It worked when I made a symlink like this:
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
$ bundle install
I fixed this issue by running
sudo apt-get install ruby-dev
as described in this blog post.
You've probably upgraded to Mountain Lion and have not rebuilt your ruby-1.9.2 install yet with the new development packages.
rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install
If you don't have the Mountain Lion dev packages installed correctly, use the ThoughtBot instructions.
For Ubuntu 14.04 simply do this:
sudo apt-get install ruby1.9.3
Should work for 13.10 and 13.04 too. (Not tested)
it apears you are not using rvm for managing your ruby installation. I think best would be to try rvm, here's a very good guide, you can stop without installing rails: ruby with rvm
Then simply
$gem install RedCloth
Unmanaged ruby gems are a pain, I try to avoid them.
None of the answers worked on my Ubuntu 14.04.1 LTS. Upgrade to ruby 2.0 fixed the problem for me:
sudo apt-get install ruby2.0 ruby2.0-dev
sudo ln -s /usr/bin/ruby2.0 /usr/bin/ruby
sudo ln -s /usr/bin/gem2.0 /usr/bin/gem
sudo gem install bundler
Make sure you also have the build-essential package installed. You can check using
dpkg -l | grep build-essential
or simply install it without checking
sudo apt-get install build-essential
For me on Ubuntu 14.04.1 LTS, after making sure build-essential is installed, the bundle install command works/builds fine also with Ruby 1.9.3.

Resources