본문 바로가기

개발도구/iOS - 아이폰 개발

[아이폰] ruby on rails - 설치 과정

https://developer.apple.com/xcode/


terminal에서

ruby -v

ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11]

무사히 ruby는 설치 완료(Xcode) 설치 완료하면 됨


gem install rails

설치하는 중에

make: command not found 이러한 에러로 인해.. ㅜㅜ

Command Line Tools for Xcode 을 설치한 뒤에 (터미널에서 gcc , cc , make모두 안되어 이상하게 생각했다.) 다시 

다시

gem instal rails 

ERROR:  While executing gem ... (Gem::FilePermissionError)

    You don't have write permissions into the /opt/local/lib/ruby/gems/1.8 directory.

역시나 설치가 제되로 안된거 같아

유닉스를 모르는 나에겐 어려웠다 이렇게 간단한걸.. 
root계정이 아니기 때문에
$ sudo 을 반드시 넣어 줘야 한다. 

This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /opt/local/lib/ruby/gems/1.8 directory.

또 다른 에러

이리하여 설치가 된거 같아 작업을 하는데
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 3.0.1) ruby depends on
      bundler (~> 1.0.0) ruby

  Current Bundler version:
    bundler (1.1.4)

이러한 에러가 나왔고 유닉스를 모르는 나에겐 조금 생소하지만, 이틀을 걸려 검색과 공부하면서 해결점을 보았다.

먼저 ruby 와 rails가 설치 되었다면, update을 반드시 해줘야 

설치 과정 (설치후 반드시 update....!! )
$ sudo gem update ruby
$ sudo gem update rails
(만약 설치가 안되어 있다면 sudo gem install rails)

설치후
$ mkdir rails_projects
$ cd rails_projects
$ rails new first_app
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore

Bundler 설정
$ cd first_app
$ mate Gemfile (TextMate 설치 되어 있어야 하고 경로는 Help -> Terminal usageing -> usr/bin 추가)
(확인하면 아래와 같이 설정되어 있다)

source 'https://rubygems.org'

gem 'rails', '3.2.5'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'json'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

$ bundle install
Fetching source index for http://rubygems.org

rails server 작동시키기
ysparkui-MacBook-Pro:first_app yspark$ rails server
=> Booting WEBrick
=> Rails 3.2.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-06-05 20:41:40] INFO  WEBrick 1.3.1
[2012-06-05 20:41:40] INFO  ruby 1.8.7 (2012-02-08) [i686-darwin11]
[2012-06-05 20:41:40] INFO  WEBrick::HTTPServer#start: pid=18218 port=3000


Started GET "/assets/rails.png" for 127.0.0.1 at Tue Jun 05 20:41:45 +0900 2012
Connecting to database specified by database.yml
Served asset /rails.png - 200 OK (4ms)









--------------------------------------------아래는 추가설명-----------------------------------------------

ruby 는 자동설치되어 문제가 없었지만, rails 설치 가정 가운데 make 의 예약어가 필요한데 잘 설치가 안되어 있는것이다.

이틀밤을 찾던중에 알게 된 사실은 Command Line Tools for Xcode을 설치해야 한다...

그래야 터미널에서 제공하는 예약어를 사용할수 있게 되었다.  ㅜㅜ

아래 그림에 View Downloads -> Downloads for Apple Developers 로 들어가 다운을 받으면 된다.