[英]Why Bundle Install is installing gems in vendor/bundle?
[英]Why “bundle install” try to install outdated version of gems?
我有不同的寶石
> rvm gemset list
gemsets for ruby-2.0.0-p247 (found in /Users/kai/.rvm/gems/ruby-2.0.0-p247)
=> (default)
global
rails4
> rvm gemset use rails4
Using ruby-2.0.0-p247 with gemset rails4
> rails -v
/Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (>= 0) among 43 total gem(s) (Gem::LoadError)
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247@rails4/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247@rails4/bin/ruby_noexec_wrapper:14:in `<main>'
當我在做的時候:
> bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Installing i18n (0.6.4)
Installing multi_json (1.7.9)
Installing activesupport (3.2.7)
Installing builder (3.0.4)
Installing activemodel (3.2.7)
Installing erubis (2.7.0)
Installing journey (1.0.4)
Installing rack (1.4.5)
Installing rack-cache (1.2)
Installing rack-test (0.6.2)
Installing hike (1.2.3)
Installing tilt (1.4.1)
Installing sprockets (2.1.3)
Installing actionpack (3.2.7)
Installing mime-types (1.23)
Installing polyglot (0.3.3)
Installing treetop (1.4.14)
Installing mail (2.4.4)
Installing actionmailer (3.2.7)
Installing arel (3.0.2)
Installing tzinfo (0.3.37)
Installing activerecord (3.2.7)
Installing activeresource (3.2.7)
Installing coffee-script-source (1.6.3)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Installing rack-ssl (1.3.3)
Installing json (1.8.0)
Installing rdoc (3.12.2)
Installing thor (0.18.1)
Installing railties (3.2.7)
Installing coffee-rails (3.2.2)
Installing jquery-rails (3.0.4)
Using bundler (1.3.5)
Installing rails (3.2.7)
Installing sass (3.2.10)
Installing sass-rails (3.2.6)
Installing sqlite3 (1.3.7)
Installing uglifier (2.1.2)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
但我有紅寶石2.0! 為什么它不安裝rails 4.0和activesupport 4.0?
bundler
基於兩個文件安裝gem:
Gemfile.lock
嚴格版本, Gemfile
松散版聲明。 當你生成rails
項目時,首先生成Gemfile
,如下所示:
gem 'rails', '~> 3.2'
生成文件后運行bundle install
,生成Gemfile.lock
,其中記錄了嚴格版本的gem,從現在開始,對bundle install
任何后續調用都只會安裝Gemfile.lock
保存的版本。
要將Gems更新為更新版本:
Gemfile
是否有任何版本限制 - 這可能會阻止安裝您想要的版本 bundle update <gem_name>
只更新這個gem以及它需要什么 - 但是將更改的范圍最小化到盡可能小的更改集。 bundle update
以將所有gem bundle update
為Gemfile
允許的最新版本 bundle install
或者short bundle
不會安裝最新的gem,除非你遺漏了Gemfile中的版本。 例如
gem 'rails'
但通常情況並非如此,我們指定版本以防止應用程序在某些寶石更新時“崩潰”並且我們無意中運行bundle update
,或者就此而言移動應用程序來說測試或生產服務器。 通常在向Gemfile添加gem時,我們會:
gem 'rails', '~> 3.2.7'
請注意版本號中的前導~>
。 這表示:在版本3.2.7
和小於3.3.0
之間使用rails gem。
為了使您的bundle命令能夠獲取rails 4.0,您需要更改該行以讀取以下任一項:
gem 'rails', '>= 3.2.7'
要么
gem 'rails', '4.0.0'
如果您使用gem 'rails', '>= 3.2.7'
那么您的rails應用程序將使用您系統中可用的最新gem。 請注意, 3.2.7
只是我在這里使用的一個例子。 如果您使用gem 'rails', '4.0.0'
那么您的rails應用程序將使用rails版本4.0.0。
請注意,此更改可能會破壞您現有的rails 3.2應用程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.