ruby-install アプリケーションを使用して Ubuntu 12.04 に ruby​​ 2.1 をインストールする

ruby-install アプリケーションを使用して Ubuntu 12.04 に ruby​​ 2.1 をインストールする

私は Ruby 2.1 のインストール方法に関するチュートリアルをいくつか見てきました。* 私のシステムには現在 Ruby 1.9.3 がインストールされていますが、最新のものが欲しいです。ここからインストールする方法について、次のチュートリアルに従っています。ruby のインストール

これまでに実行できたコマンドは次のとおりです。

sudo apt-get install build-essential

wget -O ruby-install-0.5.0.tar.gz \
  https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
tar -xzvf ruby-install-0.5.0.tar.gz
cd ruby-install-0.5.0/
sudo make install

ruby-install ruby 2.1.3
DEPENDENCY ERRORS

ruby-install ruby​​ 2.1.3 を実行すると、次のようなエラーが表示されます。

>>> Installing ruby 2.1.3 into /opt/rubies/ruby-2.1.3 ...
>>> Installing dependencies for ruby 2.1.3 ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libyaml-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libgdbm-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libncurses5-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libffi-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libyaml-dev' has no installation candidate
E: Package 'libgdbm-dev' has no installation candidate
E: Unable to locate package libreadline-dev
E: Package 'libncurses5-dev' has no installation candidate
E: Package 'libffi-dev' has no installation candidate
!!! Installing dependencies failed!

わかりました。これらすべての依存関係が不足していると表示されます。どうすればインストールして、文句を言わずに済むでしょうか? 「これらの依存関係が不足しています。インストールしましょう (はい/いいえ)」というだけのコマンドがないのはなぜでしょうか?

答え1

以下は、公式のRuby 2.1に従ってDebianベースのシステムにRuby 2.1をインストールするためのコマンドです。Ruby Dockerファイルちなみに、Docker を使用するとこの苦労を回避できます。

# Update your system packages
apt-get update 

# Install some basic dependencies
# Few of thems aren't needed but won't hurt anyway
apt-get install -y \
    autoconf \
    build-essential \
    imagemagick \
    libbz2-dev \
    libcurl4-openssl-dev \
    libevent-dev \
    libffi-dev \
    libglib2.0-dev \
    libjpeg-dev \
    libmagickcore-dev \
    libmagickwand-dev \
    libmysqlclient-dev \
    libncurses-dev \
    libpq-dev \
    libreadline-dev \
    libsqlite3-dev \
    libssl-dev \
    libxml2-dev \
    libxslt-dev \
    libyaml-dev \
    zlib1g-dev \

apt-get install -y curl procps

RUBY_MAJOR="2.1"
RUBY_VERSION="2.1.5"

apt-get install -y bison ruby

mkdir -p /usr/src/ruby
curl -SL "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.bz2" | tar -xjC /usr/src/ruby --strip-components=1
cd /usr/src/ruby
autoconf
./configure --disable-install-doc
make -j"$(nproc)"
apt-get purge -y --auto-remove bison ruby
make install
rm -r /usr/src/ruby

GEM_HOME="/usr/local/bundle"
PATH=$PATH:$GEM_HOME/bin
gem install bundler
bundle config --global path "$GEM_HOME"
bundle config --global bin "$GEM_HOME/bin"

ご想像のとおり、一部のコマンドは sudo モードで入力する必要があります。

この時点で、Ruby 2.1.5 がインストールされているはずです。確認するには、 と入力しますruby -v

注: まだテストしていないので、フィードバックをお気軽にお寄せください。

関連情報