11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrantでrailsの環境とHerokuのインストールの忘備録

Last updated at Posted at 2014-09-27

Vagrantの環境構築

vagrant box

まずはvagrantのboxの導入。ubuntuを使用したかったので、次のvagrant boxを使用した。Vagrant cloud便利!!!

vagrantの実行

vagrantの環境を整えるために以下を実行した。

mkdir precise64
cd precise64
vagrant init hashicorp/precise64
vagran up
vagrant ssh

Vagrant仮装環境へのtoolbelt/railsのインストール

heroku toolebeltのインストール

herokuの開発を簡単にするため、heroku toolbeltをインストールした。

sudo wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

仮装環境でのrailsのインストール

railsも必要なのでrailsインストールのために以下を実行。

sudo gem install rails

ERRORが出力

railsインストール中に以下のエラーが出力された。jsonがインストールされていない??
色々と調べるうちにrubyのヘッダファイルや、開発環境などがインストールされていないようだ。

vagrant@precise64:~$ sudo gem install rails
Fetching: i18n-0.6.11.gem (100%)
Fetching: json-1.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
	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>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

対応

対応としては次のコマンドにより、諸々インストール。これによりrailsのインストールも無事成功!!!

sudo apt-get install ruby1.9.1-dev
sudo apt-get install build-essential
sudo gem install json

参照

追記

railsのアプリを作成しようとしたら怒られた

以下のコマンドを実行した。

rails new first_app

エラー内容

エラーは以下のとおり。sqlite3が使えないようだ。sqlite3のライブラリをインストールとgemの実行をした。

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 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/ruby1.9.1
	--with-sqlite3-dir
	--without-sqlite3-dir
	--with-sqlite3-include
	--without-sqlite3-include=${sqlite3-dir}/include
	--with-sqlite3-lib
	--without-sqlite3-lib=${sqlite3-dir}/lib
	--enable-local
	--disable-local


Gem files will remain installed in /tmp/bundler20140927-6701-1g6azeg/sqlite3-1.3.9/gems/sqlite3-1.3.9 for inspection.
Results logged to /tmp/bundler20140927-6701-1g6azeg/sqlite3-1.3.9/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
         run  bundle exec spring binstub --all
/var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/resolver.rb:357:in `resolve': Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/resolver.rb:164:in `start'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/resolver.rb:129:in `resolve'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/definition.rb:193:in `resolve'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/definition.rb:132:in `specs'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/definition.rb:177:in `specs_for'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/definition.rb:166:in `requested_specs'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/environment.rb:18:in `requested_specs'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/runtime.rb:13:in `setup'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler.rb:121:in `setup'
	from /var/lib/gems/1.9.1/gems/bundler-1.7.3/lib/bundler/setup.rb:17:in `<top (required)>'
	from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
	from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

対応

次のコマンドを実行した。その後無事railsが走った。

sudo apt-get install libsqlite3-dev
sudo gem install sqlite3 -v '1.3.9'
11
11
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
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?