简体   繁体   English

Rails:使用gem'bootstrap-sass'安装gem文件/软件包

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

I added the line to the gem file: 我将这一行添加到了gem文件中:

gem 'bootstrap-sass'        '3.3.2.0'

then I got: 然后我得到:

$ 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.

so I downloaded and installed it from rubygems.org: 所以我从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

Then tried: 然后尝试:

$bundle install
or/and
$bundle update

And still getting the message: 仍然得到消息:

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

What should I do? 我该怎么办?

You forgot the comma between gem name, and version. 您忘记了宝石名称和版本之间的逗号。

gem 'bootstrap-sass', '3.3.2.0'

Refer to the documentation , you need to specify your optional parameters separated by , . 请参考文档 ,您需要指定可选参数,并以,分隔。

If you are installing any gem with perticular version you should have to give a comma in between gem and version (or any other parameter its optional). 如果要安装特定版本的gem,则必须在gem和version(或其他任何参数,可选)之间输入逗号。 like, 喜欢,

gem 'bootstrap-sass','3.3.2.0'

but if you want to install only gem without any version you need to give only gem file name,that enough 但是,如果您只想安装没有任何版本的gem,则只需要提供gem文件名即可

like, 喜欢,

 gem 'bootstrap-sass'

The benefit of above declaring gem is that it's version independent,because bundle installer will automatically download latest version gem, for our project. 上面声明gem的好处是它是独立于版本的,因为bundle installer会自动为我们的项目下载最新版本的gem。

In the below code you can see that i used Rails with 4.2.1 version and i separated with it comma, but for further gems I did not mentioned any version. 在下面的代码中,您可以看到我使用的Rails版本为4.2.1,并且用逗号分隔,但是对于其他的gem我没有提到任何版本。 so bundle installer will automatically install latest version for you are Rails project. 因此,捆绑安装程序将自动为您的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