文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ====== Ruby のインストール ====== ===== 最新の Ruby のインストール ===== ==== rpmbuild 環境を整える ==== <code> $ sudo dnf groupinstall "Development Tools" $ sudo dnf install fedora-packager </code> ==== rpmbuild を行うためのディレクトリ構造を作成 ==== <code> $ rpmdev-setuptree </code> ==== ruby の srpm をダウンロード ==== [[https://docs.fedoraproject.org/en-US/releases/rawhide/|Rawhide]] とは Fedora の開発バージョンである🤔\\ 以下の URL より開発バージョンのパッケージソースを取得できる。最新のパッケージ名は随時更新されるので直接確認する😉\\ [[https://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/development/rawhide/Everything/source/tree/Packages/r/|]]\\ <WRAP prewrap 100%> <code> $ curl -O http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/development/rawhide/Everything/source/tree/Packages/r/ruby-2.6.1-112.fc30.src.rpm </code> </WRAP> ==== srpm のインストール ==== <code> $ rpm -ivh ruby-2.6.1-112.fc30.src.rpm </code> ==== ビルドに必要なパッケージのインストール ==== <code> $ sudo dnf builddep ~/rpmbuild/SPECS/ruby.spec </code> ==== RPM パッケージのビルドと署名 ==== パッケージに署名をする準備については [[linux:fedora:rpmbuild|rpmbuild]] を参照。 <code> $ rpmbuild --sign -ba ~/rpmbuild/SPECS/ruby.spec </code> ==== RPM パッケージのインストール ==== <WRAP prewrap 100%> <code> $ createrepo -v ~/rpmbuild/RPMS/ $ sudo dnf install --nogpgcheck --repofrompath=local,/home/tomoyan/rpmbuild/RPMS/ ruby ruby-devel </code> </WRAP> ==== ruby のバージョン確認 ==== <code> $ ruby -v ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux] </code> ===== パッケージのインストール ===== ==== Fedora の場合 ==== <code> $ sudo dnf install ruby $ ruby -v ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux] </code> ==== Windows の場合 ==== - [[http://rubyinstaller.org/downloads/|RubyInstaller Downloads]]より Ruby Installer for Windows をダウンロードする。\\ ※ここでは Windows x64 用の rubyinstaller-2.5.3-1-x64.exe をダウンロード。 - ダウンロードしたファイルを実行して、NetBeans IDE をインストールする。 ※Ruby Installer for Windows はパスを通したり拡張子関連付けを行ってくれるオプションがあるので、手間を掛けずに簡単にRuby環境を整えることができる。 ==== Mac OS X Lion の場合 ==== - Ruby Version Manager(RVM)をインストールする。<code> $ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) </code> - RVM のインストール確認を行う。<code> $ rvm -v rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/] </code> - Shell環境をリロードする。<code> $ source ~/.bash_profile</code> - インストールを行う前に依存関係を調べる。<code> $ rvm requirements Notes for Mac OS X 10.7.2, No Xcode. For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26" For IronRuby: Install Mono >= 2.6 For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba' You can use & download osx-gcc-installer: https://github.com/kennethreitz/osx-gcc-installer ** NOTE: Currently, Node.js is having issues building with osx-gcc-installer. The only fix is to install Xcode over osx-gcc-installer. To use an RVM installed Ruby as default, instead of the system ruby: rvm install 1.8.7 # installs patch 357: closest supported version rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems rvm alias create default 1.8.7 And reopen your terminal windows. Xcode 4.2: * is only supported by ruby 1.9.3+ using command line flag: --with-gcc=clang * it breaks gems with native extensions, especially DB drivers. </code> - Xcodeをインストールするために、アップルメニューから[App Store...]をクリックする。 - App Store ウィンドウ右上の検索ボックスで「xcode」を検索する。 - Xcode開発ツールの[無料]をクリックし[APPをインストール]をクリックする。 - Apple IDとパスワードを入力してサインインするとインストーラがインストールされる。 - LaunchpadよりInstall Xcodeを実行する。 - Homebrewをインストールする。<code> $ ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"</code> - Homebrew のインストール確認を行う。<code> $ brew -v 0.8.1 </code> - RubyGemsを更新する。<code> sudo gem update --system</code> - Rakeを更新する。<code> $ sudo gem update rake</code> - ruby 1.9.3 をインストールする。<code> $ rvm install 1.9.3 --with-gcc=clang Fetching yaml-0.1.4.tar.gz to /Users/tomoyan/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 460k 100 460k 0 0 98665 0 0:00:04 0:00:04 --:--:-- 104k Extracting yaml-0.1.4.tar.gz to /Users/tomoyan/.rvm/src Configuring yaml in /Users/tomoyan/.rvm/src/yaml-0.1.4. Compiling yaml in /Users/tomoyan/.rvm/src/yaml-0.1.4. Installing yaml to /Users/tomoyan/.rvm/usr Installing Ruby from source to: /Users/tomoyan/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)... ruby-1.9.3-p0 - #fetching ruby-1.9.3-p0 - #downloading ruby-1.9.3-p0, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9330k 100 9330k 0 0 790k 0 0:00:11 0:00:11 --:--:-- 1120k ruby-1.9.3-p0 - #extracting ruby-1.9.3-p0 to /Users/tomoyan/.rvm/src/ruby-1.9.3-p0 ruby-1.9.3-p0 - #extracted to /Users/tomoyan/.rvm/src/ruby-1.9.3-p0 ruby-1.9.3-p0 - #configuring ruby-1.9.3-p0 - #compiling ruby-1.9.3-p0 - #installing Retrieving rubygems-1.8.15 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 245k 100 245k 0 0 708k 0 --:--:-- --:--:-- --:--:-- 831k Extracting rubygems-1.8.15 ... Removing old Rubygems files... Installing rubygems-1.8.15 for ruby-1.9.3-p0 ... Installation of rubygems completed successfully. ruby-1.9.3-p0 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake). ruby-1.9.3-p0 - #importing default gemsets (/Users/tomoyan/.rvm/gemsets/) Install of ruby-1.9.3-p0 - #complete </code> ===== Ruby のバージョンを切り替える ===== 一時的に Ruby 1.9.3 に切り替える。 <code> $ rvm use 1.9.3 Using /Users/tomoyan/.rvm/gems/ruby-1.9.3-p0 </code> Ruby 1.9.3 をデフォルトにする。 <code> $ rvm use 1.9.3 --default Using /Users/tomoyan/.rvm/gems/ruby-1.9.3-p0 </code> ===== gemset の生成 ===== - gemset を生成する。<code> $ rvm gemset create RailsEnv 'RailsEnv' gemset created (/Users/tomoyan/.rvm/gems/ruby-1.9.3-p0@RailsEnv). </code> - gemset を選択する。<code> $ rvm gemset use RailsEnv Using /Users/tomoyan/.rvm/gems/ruby-1.9.3-p0 with gemset RailsEnv </code> - Rails をインストールする。<code> $ sudo gem install rails Fetching: i18n-0.6.0.gem (100%) Fetching: multi_json-1.0.4.gem (100%) Fetching: activesupport-3.2.1.gem (100%) 〜省略〜 Installing RDoc documentation for rdoc-3.12... Installing RDoc documentation for railties-3.2.1... Installing RDoc documentation for rails-3.2.1... </code> - bundler をインストールする。<code> $ gem install bundler Fetching: bundler-1.0.22.gem (100%) Successfully installed bundler-1.0.22 1 gem installed Installing ri documentation for bundler-1.0.22... Installing RDoc documentation for bundler-1.0.22... </code> ===== プロジェクト ディレクトリごとに環境を切り替える ===== プロジェクトのディレクトリで以下のコマンドを実行して、Rubyのバージョンとgemsetが自動選択されるようにする。<code> $ rvm --rvmrc --create ruby-1.9.3-p0@RailsEnv </code>コマンドを実行するとプロジェクトのフォルダに以下の内容で .rvmrc が生成される。<code> #!/usr/bin/env bash # This is an RVM Project .rvmrc file, used to automatically load the ruby # development environment upon cd'ing into the directory # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional. environment_id="ruby-1.9.3-p0@RailsEnv" # # Uncomment the following lines if you want to verify rvm version per project # # rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || { # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading." # return 1 # } # # # Uncomment following line if you want options to be set only for given project. # # PROJECT_JRUBY_OPTS=( --1.9 ) # # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell: # # chmod +x ${rvm_path}/hooks/after_use_jruby_opts # # # First we attempt to load the desired environment directly from the environment # file. This is very fast and efficient compared to running through the entire # CLI and selector. If you want feedback on which environment was used then # insert the word 'use' after --create as this triggers verbose mode. # if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] then \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] then . "${rvm_path:-$HOME/.rvm}/hooks/after_use" fi else # If the environment file has not yet been created, use the RVM CLI to select. if ! rvm --create "$environment_id" then echo "Failed to create RVM environment '${environment_id}'." return 1 fi fi # # If you use an RVM gemset file to install a list of gems (*.gems), you can have # it be automatically loaded. Uncomment the following and adjust the filename if # necessary. # # filename=".gems" # if [[ -s "$filename" ]] # then # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d' # fi # If you use bundler, this might be useful to you: # if [[info_arrange:s_gemfile]] && ! command -v bundle >/dev/null # then # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n" # gem install bundler # fi # if [[info_arrange:s_gemfile]] && command -v bundle # then # bundle install # fi if [[ $- == *i* ]] # check for interactive shells then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green else echo "Using: $GEM_HOME" # don't use colors in interactive shells fi </code> ===== 参考文献 ===== [[https://rvm.io/rvm/install|RVM: Ruby Version Manager - Installing RVM]]\\ [[http://www.oiax.jp/rails/zakkan/rails_3_1_installation_on_macosx.html|Ruby on Rails 3.1 を Mac OS X にインストールする手順をかなり丁寧に説明してみました - Rails 雑感 - Ruby on Rails with OIAX]]\\ ruby/ruby_install.txt 最終更新: 2024/04/18 22:15by 非ログインユーザー