Self summary: Ruby(RVM, gem, bundle)

Establishment of the develop environment:


https://ruby-china.org/wiki/install_ruby_guide


Evolution of bundler: 


Now, the install of ruby will include the gem command for get the others code. And we need to use gem install to get bundle. Here is an interesting link talking about the evolution: https://ruby-china.org/topics/28453


'require' (在某个地址目录名单下,搜索代码并引用)--> setup.rb(把下载下来的代码,统一复制到某个属于名单下的目录,但没有版本控制,容易混淆,犯错) --> gem(引入了版本控制,但是如果程序两条独立的依赖链上,有两个元素依赖同一个库的不同版本,会出现冲突) --> bundler(所以引用了bundler,由gemfile告诉bundler需要什么文件,让计算机去协调版本,帮我们优化dependency link, genfile.lock 就是把这些计算的版本结果记录下来可以直接按照其执行的文件).


Several common gem command: 


gem -v 查看 RubyGems 的版本
gem update --system 升級RubyGems的版本
gem install gem_name 安裝gem包
gem list 列出所有已安裝的gem包
gem update gem_name 更新某个gem包
gem update 更新所有已安裝的gem包
gem install -v x.x.x gemname 安裝特定版本
gem uninstall gem_name 卸载


A useful tool and tricks about using RVM: 


https://ruby-china.org/wiki/rvm-guide


Generally speaking, RVM can let different versions of ruby runs on a computer and you can switch as you want. Also, it contains a gemset which is attached to a particular version of ruby. If you switch to a particular ruby and install some gems under this ruby's gemset, it will only exist in this gemset. 


What is ruby on rail? :


http://guides.rubyonrails.org/getting_started.html 


Quoted: Rails is a web application development framework written in the Ruby language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. 


Two useful hint of ruby:


1) Never never never use sudo. When you are using sudo gem install, you are actually using the ruby of system (if you are using mac). Then it will cause a lot of version problems. It will emerge bugs like: 


$ bundle install

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:269:in `bin_path': can't find gem bundler (>= 0) (Gem::GemNotFoundException)


It may be because you may install the rail on the system ruby but not in the RVM ruby. 


Here is a useful link talking about this: https://robots.thoughtbot.com/psa-do-not-use-system-ruby


Also, a useful link that talks about the solution of this problem: http://stackoverflow.com/questions/16189338/could-not-find-rake-10-0-4-in-any-of-the-sources-bundlergemnotfound


2) If you are in China, you can switch the URL of RubyGem to http://ruby.taobao.org


Two useful links of learning ruby: 


http://www.runoob.com/ruby/ruby-tutorial.html

https://www.ruby-lang.org/zh_cn/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值