Grunt/Bundler wont use specified sass version

≡放荡痞女 提交于 2020-01-03 16:36:05

问题


We have a project with Grunt and Bundler setup. All of these installed without issue. Gemfile.lock generated, proper gems pulled down, and grunt files created with npm. We start our watch on the project and it bombs on sass compile because it's using the wrong version of sass and not the one specified in the gemfile.

This is on windows by the way...

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)

回答1:


If you want to limit your gems to only those in your bundle (listed in your Gemfile), you should prefix your commands with bundle exec when running them in the terminal.

eg. if you were running sass --watch then you would run bundle exec sass --watch to make sure you use the version in your bundle.

Documentation on bundle exec: http://bundler.io/man/bundle-exec.1.html




回答2:


Based on an informal experiment (adding a GEMFILE to my project at the same level of my Gruntfile), if you're using a Compass task and set the task option "bundleExec" to true, the task should rely on bundler to handle versions and dependencies. With this setup, a lockfile was created when just running "grunt server" (not "bundle exec grunt server"). Anyone please correct me if this is wrong or misleading advice. Either method seems to work in my environment.




回答3:


On unix, you can check with the command:

which sass

Which should return something like:

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

If it is something like /usr/bin/sass then you need to prepend your command with bundle exec as @sevenseacat mentions.



来源:https://stackoverflow.com/questions/23388261/grunt-bundler-wont-use-specified-sass-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!