Grunt / Bundler不会使用指定的sass版本

我们有一个Grunt和Bundler设置的项目。 所有这些安装没有问题。 生成Gemfile.lock,下拉正确的gem,以及使用npm创建的grunt文件。 我们开始监视项目并且它在sass编译时爆炸,因为它使用了错误版本的sass而不是gemfile中指定的版本。

顺便说一句,这是在窗户上……

的Gemfile

source 'https://rubygems.org' gem 'sass', '~> 3.2' gem 'compass', '~> 0.12' gem 'susy', '~> 1.0' 

Gemfile.lock的

 GEM remote: https://rubygems.org/ specs: chunky_png (1.3.1) compass (0.12.6) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.2.19) fssm (0.2.10) sass (3.2.19) susy (1.0.9) compass (>= 0.12.2) sass (>= 3.2.0) PLATFORMS x86-mingw32 DEPENDENCIES compass (~> 0.12) sass (~> 3.2) susy (~> 1.0) 

如果你想将你的gems限制在你的包中的那些(在你的Gemfile中列出),你应该在终端中运行它们时使用bundle exec前缀。

例如。 如果您正在运行sass --watch那么您将运行bundle exec sass --watch以确保您使用捆绑包中的版本。

有关bundle exec文档: http : //bundler.io/man/bundle-exec.1.html

基于非正式实验(在我的Grunt文件的同一级别向我的项目添加GEMFILE),如果您正在使用Compass任务并将任务选项“bundleExec”设置为true,则任务应依赖于bundler来处理版本和依赖。 使用此设置,仅在运行“grunt server”(而不是“bundle exec grunt server”)时创建了一个lockfile。 如果这是错误的或误导性的建议,请任何人纠正我。 这两种方法似乎都适用于我的环境。

在unix上,您可以使用以下命令进行检查:

which sass

哪个应该返回类似的东西:

/Users/[username]/.rbenv/shims/sass

如果它类似于/usr/bin/sass那么你需要在bundle exec中添加命令作为@sevenseacat提及。