Question

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)
Was it helpful?

Solution

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

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top