简体   繁体   中英

Sass::SyntaxError: File to import not found or unreadable: bourbon/bourbon

I've installed rvm and bourbon. I then installed bourbon into my /css directory. However when I try

@import 'bourbon/bourbon'; 

I get this error:

Sass::SyntaxError: File to import not found or unreadable: bourbon/bourbon.

I've checked out other threads with the same issue but none seemed to solve my problem. How can I get this error to go away and for bourbon to import correctly?

try this out:

In your Gemfile:

gem 'bourbon'

Then run:

bundle install

from github documentation of bouron

Non-Rails projects

Bourbon includes an easy way to generate a directory with all the necessary files. For command line help: $ bourbon help or visit the Command line tools wiki Install (Bourbon v3.0+)

gem install bourbon

Install Bourbon into the current directory by generating the bourbon folder:

bourbon install

The generated folder will contain all the mixins and other necessary Bourbon files. It is recommended not to add or modify the Bourbon files so that you can update Bourbon easily.

You can specify a target directory using the path flag:

bourbon install --path my/custom/path/

Import

Lastly, import the mixins at the beginning of your stylesheet(s):

@import 'bourbon/bourbon';

Note: Bourbon no longer requires a custom sass --watch command for Bourbon v3.0+

It is important to note where the installation of bourbon is (assuming you're working on your local machine). When installing you can determine a custom install like this:

bourbon install --path my/custom/path/

It would be a good idea to place it in the directory that you usually save your local web files for easy access. I have mine installed in the user directory currently which is sort of pain, but I have to call in my bourbon like this in my sass files:

@import '/Users/myusername/rubygems/bourbon/_bourbon.scss';

Yes this is actually late, just got into the same problem using Rails 4.2.5.1 . I think in your own case, the problem being you didn't rename your asset pipeline (css file) to carry the extension .scss .

Here is how I fixed it :

How to get around it Bourbon for Ruby on Rails 4.2+

  1. Add Bourbon to your Gemfile:

    gem 'bourbon'

    Then run:

    bundle install

    Note : In your asset pipeline, if your stylesheet is still asset named application.css , you need to rename it to to application.scss .

    In my own case my pipeline is named application.css.scss and it worked because I have my extension still append to .scss extension.

  2. Delete all Sprockets directives in application.scss (require, require_tree and require_self) and use Sass's native @import instead. The reason being as it is explained here . Such that your application.scss will Import Bourbon at the beginning like this below:

    Example:

      @import "bourbon"; @import "bourbon"; @import "bootstrap-sprockets"; @import "bootstrap"; @import "social-share-button"; 
  3. Then restart your server by running

    rails server

With all these, you should be up and running. For more info, see https://github.com/thoughtbot/bourbon

I came across this issue when I upgraded versions of Rails (3.2 -> 5.0). During the process, I left behind group :assets in the Gemfile. Taking bourbon and other gems out of that group fixed the issue.

Try this (if you are using Rails) :

  1. Open your Gemfile
  2. Make sure gem bourbon exists but is not in any groups
  3. Run bundle install

This happened to a colleague of mine when he upgraded versions of Rails (3.2 -> 5.0): he accidentally left some gems in the group :assets , which was deprecated in Rails 4.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM