簡體   English   中英

Rails:使用gem'bootstrap-sass'安裝gem文件/軟件包

[英]Rails: gem file/ bundle install with gem 'bootstrap-sass'

我將這一行添加到了gem文件中:

gem 'bootstrap-sass'        '3.3.2.0'

然后我得到:

$ bundle install 
Fetching gem metadata from https://rubygems.org/........... 
Fetching additional metadata from https://rubygems.org/.. 
Resolving dependencies... 
Could not find gem 'bootstrap-sass3.3.2.0 (>= 0) ruby' in the gems available on this machine.

所以我從rubygems.org下載並安裝了它:

$ gem install bootstrap-sass -v 3.3.2.0
Fetching: autoprefixer-rails-5.1.11.gem (100%)
Successfully installed autoprefixer-rails-5.1.11
Fetching: bootstrap-sass-3.3.2.0.gem (100%)
Successfully installed bootstrap-sass-3.3.2.0
2 gems installed

然后嘗試:

$bundle install
or/and
$bundle update

仍然得到消息:

Could not find gem 'bootstrap-sass3.3.2.0 (>= 0) ruby' in the gems available on this machine.

我該怎么辦?

您忘記了寶石名稱和版本之間的逗號。

gem 'bootstrap-sass', '3.3.2.0'

請參考文檔 ,您需要指定可選參數,並以,分隔。

如果要安裝特定版本的gem,則必須在gem和version(或其他任何參數,可選)之間輸入逗號。 喜歡,

gem 'bootstrap-sass','3.3.2.0'

但是,如果您只想安裝沒有任何版本的gem,則只需要提供gem文件名即可

喜歡,

 gem 'bootstrap-sass'

上面聲明gem的好處是它是獨立於版本的,因為bundle installer會自動為我們的項目下載最新版本的gem。

在下面的代碼中,您可以看到我使用的Rails版本為4.2.1,並且用逗號分隔,但是對於其他的gem我沒有提到任何版本。 因此,捆綁安裝程序將自動為您的Rails項目安裝最新版本。

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM