chruby
chruby
since 2017-08-13
https://hiroshimarb.connpass.com/event/58400/ で教えてもらった
https://speakerdeck.com/jmettraux/chruby
https://github.com/postmodern/chruby
- rbenv はメンテナンスされている
Linux Subsystem for Windows
Ubuntu 14.04 相当の環境。
システムに 2.3 が入っていて、ソースから 2.4.1 を新たにインストールして、これらを使い分けられるようにする。
書いてあるとおりにセットアップ。
$ wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz $ tar -xzvf chruby-0.3.9.tar.gz $ cd chruby-0.3.9/ $ sudo make install $ tail ~/.bashrc source /usr/local/share/chruby/chruby.sh source /usr/local/share/chruby/auto.sh
ruby 2.4.1 のインストール
$ sudo apt-get install -y --force-yes build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libffi-dev $ wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2 $ tar -xjvf ruby-2.4.1.tar.bz2 $ cd ruby-2.4.1/ $ ./configure --prefix=/opt/rubies/ruby-2.4.1 $ make $ sudo make install
$ /usr/bin/ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux-gnu] $ chruby ruby-2.4.1 $ chruby system $ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux-gnu] $ chruby 2.4.1 $ ruby -v ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
gem
gem から yard を入れたいのだが。。
下記のように sudo しないで gem を実行すると home にバージョンごとに区別されて yardoc が入る。
-E は –env-shebang オプションで、 #!/usr/bin/env ruby が処理系に指定される。
$ chruby 2.4.1 $ gem install -E yard Fetching: yard-0.9.9.gem (100%) -------------------------------------------------------------------------------- As of YARD v0.9.2: RubyGems "--document=yri,yard" hooks are now supported. You can auto-configure YARD to automatically build the yri index for installed gems by typing: $ yard config --gem-install-yri See `yard config --help` for more information on RubyGems install hooks. You can also add the following to your .gemspec to have YARD document your gem on install: spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs. -------------------------------------------------------------------------------- Successfully installed yard-0.9.9 Parsing documentation for yard-0.9.9 Installing ri documentation for yard-0.9.9 Done installing documentation for yard after 11 seconds 1 gem installed <code> $ which yardoc /home/nishimotz/.gem/ruby/2.4.1/bin/yardoc $ yardoc Files: 0 Modules: 0 ( 0 undocumented) Classes: 0 ( 0 undocumented) Constants: 0 ( 0 undocumented) Attributes: 0 ( 0 undocumented) Methods: 0 ( 0 undocumented) 100.00% documented
system ruby には yardoc は入っていない
$ chruby system $ which yardoc
sudo gem = 失敗
gem から yard を入れたいのだが。。
下記のやり方をすると動かない yardoc が入ってしまう。
$ which gem /opt/rubies/ruby-2.4.1/bin/gem $ sudo gem install yard [sudo] password for nishimotz: Fetching: yard-0.9.9.gem (100%) -------------------------------------------------------------------------------- As of YARD v0.9.2: RubyGems "--document=yri,yard" hooks are now supported. You can auto-configure YARD to automatically build the yri index for installed gems by typing: $ yard config --gem-install-yri See `yard config --help` for more information on RubyGems install hooks. You can also add the following to your .gemspec to have YARD document your gem on install: spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs. -------------------------------------------------------------------------------- Successfully installed yard-0.9.9 Parsing documentation for yard-0.9.9 Installing ri documentation for yard-0.9.9 Done installing documentation for yard after 12 seconds 1 gem installed
$ which yardoc /usr/local/bin/yardoc $ head /usr/local/bin/yardoc #!/usr/bin/ruby2.3 # # This file was generated by RubyGems. # # The application 'yard' is installed as part of a gem, and # this file is here to facilitate running it. # require 'rubygems'
$ yardoc /usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem yard (>= 0.a) (Gem::GemNotFoundException) from /usr/local/bin/yardoc:22:in `<main>'
chruby.txt · 最終更新: 2022/11/19 18:29 by Takuya Nishimoto