LoginSignup
2
3

More than 5 years have passed since last update.

Ruby on Rails チュートリアル sample_appのクローンと立ち上げ rails server のエラー

Last updated at Posted at 2018-09-27

Ruby on Rails チュートリアル sample_appのクローンと立ち上げ

 前提

Rails チュートリアル第4版 5.1完了
AWS Cloud9でのサーバーの立ち上げ方はわかる

作業

githubから(Bitbucket)クローンしたものを新しく立ち上げたプロジェクトに移す
(HTTPS用のURLを使用)

ec2-user:~/environment $git clone (自分のリモートポジトリURL)

例 

ec2-user:~/environment $git clone https://github.com/hirokisuganuma/we-love-coffee.git

クローンしたディレクトリに移動したら (ec2-user:~/environment $cd we-love-coffee)
rails serverをすると

Could not find proper version of railties (5.1.6) in any of the sources
Run bundle install to install missing gems.

とエラーが出るので
bundle installすると

Fetching gem metadata from https://rubygems.org/.......
Fetching rake 12.3.1
Installing rake 12.3.1
Fetching CFPropertyList 2.3.6
Installing CFPropertyList 2.3.6
Using concurrent-ruby 1.0.5
・
・
・
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.2.4/ext/ovirtsdk4c
/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20180927-4922-1am659j.rb extconf.rb
checking for xml2-config... no
*** 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/local/rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
        --with-libxml2-config
        --without-libxml2-config
        --with-pkg-config
        --without-pkg-config
extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)

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

  /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/ovirt-engine-sdk-4.2.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.4.1/gems/ovirt-engine-sdk-4.2.4 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/ovirt-engine-sdk-4.2.4/gem_make.out

An error occurred while installing ovirt-engine-sdk (4.2.4), and Bundler cannot continue.
Make sure that `gem install ovirt-engine-sdk -v '4.2.4' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  fog was resolved to 1.42.0, which depends on
    fog-ovirt was resolved to 1.1.2, which depends on
      ovirt-engine-sdk

おぉ。。チュートリアルやってた中では出会わなかったエラー
プログラミングを教わっている方に相談しつつ
gem install ovirt-engine-sdk -v '4.2.4'をしてもエラーになってしまう

gemfileの

group :production do
  gem 'pg',   '0.20.0'
  gem 'fog',  '1.42'
end

をコメントアウトして再度bundle install

次は通常通りできました!

そのあとは

$ rails db:migrate

serverが無事に立ち上がりました!

よくよく自分で調べてみたら
チュートリアル内のリスト 3.3に

Ruby on Rails チュートリアルのサンプルアプリケーション

これは、次の教材で作られたサンプルアプリケーションです。

Ruby on Rails チュートリアル
Michael Hartl

ライセンス

Ruby on Rails チュートリアル内にある
ソースコードはMITライセンスとBeerwareライセンスのもとで公開されています。
詳細は LICENSE.md をご覧ください。

使い方

このアプリケーションを動かす場合は、まずはリポジトリを手元にクローンしてください。
その後、次のコマンドで必要になる RubyGems をインストールします。

$ bundle install --without production

その後、データベースへのマイグレーションを実行します。

$ rails db:migrate

最後に、テストを実行してうまく動いているかどうか確認してください。

$ rails test

テストが無事に通ったら、Railsサーバーを立ち上げる準備が整っているはずです。

$ rails server

詳しくは、Ruby on Rails チュートリアル
を参考にしてください。

bundle install --without productionとproduction用のgemは省いてインストールしてました、、、
確かにこんなことしてたなーと思いだしたのでわからないことはチュートリアルも読み直してやろうと思います

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3