UbuntuにRailsの開発環境を構築(Vundlerも試してみる)

会社には長い時間いるので、直接関係なくてもちょっとした時にチョロっと
試したくなったりするものです。
プライベートではMac使ってますが、そんな諸事情で今回はUbuntuになります。
 
■ Rubyのインストール
Rubyのダウンロードページ(http://www.ruby-lang.org/en/downloads/)をみると、

The most popular tool to install Ruby is RVM, for “Ruby Version Manager.

ってことで↓の”Install RVM with ruby”に沿って叩いたら、

↓さっそくこんなメッセージ。。

It looks you are one of the happy Ubuntu users,
RVM packaged by Ubuntu is old and broken,
follow this link for details how to fix:

http://stackoverflow.com/a/9056395/497756

んでみたら、なんか一回パッケージマネージャ使って消して、
↓しなさいって事みたいなので、そうしますよ、と。

curl -L get.rvm.io | bash -s stable –auto

んでもって↓したら、、

$ rvm install ruby-head

↓あら、そうですか、、、と。

Installation of rubygems did not complete successfully.

↓rubygems.install.log をみると。あー、どっかで見た事あんなぁ。。

To eliminate this warning, please install libyaml and reinstall your ruby.

ってことで。

$ rvm package install libyaml
Unrecognized command line argument: ‘package’ ( see: ‘rvm usage’ )

↓ん…。usageみたらpackageではなくpkgなのねんと。。

$ rvm pkg install libyaml

そしたら↓ですよ、と。

Please note that it’s required to reinstall all rubies:

ってことで。。

$ rvm reinstall all –force

↓そしたら、、、

fatal: unable to connect to github.com:
github.com[0: 207.97.227.239]: errno=Connection timed out

んー、んま、それでも、なんか終わったっぽくて、

$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

1.8.7になるんですかねぇ。。1.9系がいいなってことで、

$ rvm reinstall 1.9.2
$ rvm use 1.9.2 –default
Using /home/hoge/.rvm/gems/ruby-1.9.2-p320
$ ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [i686-linux]

無事Ruby入った予感です。。ついでにgemも大丈夫っぽい。。

$ gem -v
1.8.24
$ which gem
/home/hoge/.rvm/rubies/ruby-1.9.2-p320/bin/gem

 
■ Railsのインストール
そのままの勢いでRails入れますよー、と。

$ gem install rails
ERROR: While executing gem … (Gem::DependencyError)
Unable to resolve dependencies: railties requires rack-ssl (~> 1.3.2), thor (< 2.0, >= 0.14.6), rdoc (~> 3.4); actionmailer requires mail (~> 2.4.4); activerecord requires tzinfo (~> 0.3.29); sprockets requires hike (~> 1.2), tilt (!= 1.3.0, ~> 1.1)

んあぁぁ。。。
↓してみます、、。

$ gem update –system
WARNING: Error fetching data: SocketError: getaddrinfo: Name or service not known (http://rubygems.org/latest_specs.4.8.gz)
Latest version currently installed. Aborting.

そうですか、、、それでは、、

$ gem install rails –include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use –ignore-dependencies to install only the gems you list
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.8.gem (100%)
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.1.3.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.8.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.34.gem (100%)
Fetching: activerecord-3.2.8.gem (100%)
Fetching: activeresource-3.2.8.gem (100%)
Fetching: mime-types-1.19.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.12.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.8.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: thor-0.16.0.gem (100%)
Fetching: json-1.7.5.gem (100%)
Building native extensions. This could take a while…
Fetching: rdoc-3.12.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

= 1.9.2 : nothing to do! Yay!
Fetching: railties-3.2.8.gem (100%)
Fetching: rails-3.2.8.gem (100%)
Successfully installed i18n-0.6.1
Successfully installed multi_json-1.3.6
Successfully installed activesupport-3.2.8
Successfully installed builder-3.0.4
Successfully installed activemodel-3.2.8
Successfully installed rack-1.4.1
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.2
Successfully installed journey-1.0.4
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.1.3
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.8
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.34
Successfully installed activerecord-3.2.8
Successfully installed activeresource-3.2.8
Successfully installed mime-types-1.19
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.12
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.8
Successfully installed rack-ssl-1.3.2
Successfully installed thor-0.16.0
Successfully installed json-1.7.5
Successfully installed rdoc-3.12
Successfully installed railties-3.2.8
Successfully installed rails-3.2.8
29 gems installed
Installing ri documentation for i18n-0.6.1…
~略~
Installing ri documentation for rails-3.2.8…
Installing RDoc documentation for i18n-0.6.1…
~略~
Installing RDoc documentation for rails-3.2.8…
$ rails -v
Rails 3.2.8

INFOで何か言ってるけど、なんだかんだでRails入ったみたいです…。
ってかドキュメントは要らなかったな…。無駄に時間かかる。。
んま、そんなこんなでrails newします。。

$ rails new trd
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create lib/assets
create lib/assets/.gitkeep
create log
create log/.gitkeep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create script
create script/rails
create test/fixtures
create test/fixtures/.gitkeep
create test/functional
create test/functional/.gitkeep
create test/integration
create test/integration/.gitkeep
create test/unit
create test/unit/.gitkeep
create test/performance/browsing_test.rb
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.gitkeep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.gitkeep
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/………..
Fetching gem metadata from https://rubygems.org/..
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.8)
Using builder (3.0.4)
Using activemodel (3.2.8)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.8)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.8)
Using arel (3.0.2)
Using tzinfo (0.3.34)
Using activerecord (3.2.8)
Using activeresource (3.2.8)
Using bundler (1.2.1)
Installing coffee-script-source (1.4.0)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.8)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.1.3)
Using rails (3.2.8)
Installing sass (3.2.1)
Installing sass-rails (3.2.5)
Installing sqlite3 (1.3.6) with native extensions
Installing uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

うまい事いったくせーっす。
 
■ Vundlerでvim用のアレやコレや
続いてRails用のvimの設定。
↓を試してみたいと思っていたのですよ。Vundler。.vimの中身をBundle的に。
vundlerで俺の.vimディレクトリ以下がスッキリ!(http://docs.komagata.org/4778)
上記の設定をまんまパクってGithubのページのREADMEに沿ってやってみます。
https://github.com/gmarik/vundle
vim立ちあげて:BundleInstallすると、、、

” Installing bundles to /home/hoge/.vim/bundle |
+ Bundle ‘rails.vim’ |~
+ Bundle ‘The-NERD-tree’ |~
+ Bundle ‘quickrun’ |~
+ Bundle ‘vim-ruby/vim-ruby’ |~
+ Bundle ‘Shougo/neocomplcache’ |~
* Helptags

おぉ、、シブい…。コレはアツいですね。
んで、ひらいてみたら、、、

Disabling rails.vim: autoload/rails.vim is missing

悲しいときーーって昔ありましたやねぇ。。
が、、日本語でブログあった!↓ってか@sato_ryuじゃんかよw
http://d.hatena.ne.jp/Umeyashiki/20111001/1317488217

Bundle ‘rails.vim’

の設定を↓にしてgithubからシクヨロ的な。

Bundle ‘tpope/vim-rails’

コレで事無きを得ました。ありがとうございやした!助かりました。
んで、rails.vimは↓のパねぇCheetSheetがあるっソヨって事で。
http://homepage3.nifty.com/moro/rails_vim_cheatsheet.pdf
 
■ その後もイロイロありやすね、、
–skip-test-unitでnewしてRspecの定義入れてbundle installしたら
↓とか言われたり。。

An error occurred while installing nokogiri (1.5.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v ‘1.5.5’` succeeds before bundling.

ググったら↓って事だったのでやったら解決しましたが、、

sudo apt-get install libxslt-dev

 
■ 最後に、、
コレ系の作業は過去にも何度かやってて↓のように
なんか毎回ちょっと面倒くさいんだけど、世の中こんなもんなんですかねぇ。
JavaでEclipseでMavenとかの方がやっぱりハマりどころ少ないのかな、と。。
VimでRailsにRide onしてみる=> http://shinodogg.com/?p=3334
Railsで開発できる環境を整える(RVM&諸々インストール編)=> http://shinodogg.com/?p=4209
 

RailsによるアジャイルWebアプリケーション開発 第4版
Sam Ruby Dave Thomas David Heinemeier Hansson
オーム社
売り上げランキング: 39465

コメント

タイトルとURLをコピーしました