programing

Sass :: SyntaxError : 가져올 파일을 찾을 수 없거나 읽을 수 없음 : bootstrap-sprockets

copysource 2021. 1. 16. 20:39
반응형

Sass :: SyntaxError : 가져올 파일을 찾을 수 없거나 읽을 수 없음 : bootstrap-sprockets


개발 및 배포시 프로덕션에서 갑자기이 오류가 발생합니다.

custom.css.scss

@import "bootstrap-sprockets";
@import "bootstrap";

오류 (생산 중)

rake aborted!
Sass::SyntaxError: File to import not found or unreadable: bootstrap-sprockets.
Load paths:
/srv/www/myapp/releases/20141001060418/app/assets/images
/srv/www/myapp/releases/20141001060418/app/assets/javascripts
/srv/www/myapp/releases/20141001060418/app/assets/stylesheets
/srv/www/myapp/releases/20141001060418/vendor/assets/javascripts
/srv/www/myapp/releases/20141001060418/vendor/assets/stylesheets

Gemfile을 변경 한 후 다음을 사용하여 서버를 다시 시작하는 것을 잊지 마십시오. rails s

Rails 서버를 다시 시작하는 것이 매력처럼 작동했습니다! :디


이 문제는 bootstrap-sass를 업그레이드하여 해결했습니다.

gem 'bootstrap-sass', '3.2.0.2'

Gemfile을 변경할 때마다 레일스 서버를 다시 시작하십시오.

rails server

없는지 확인하십시오

gem 'bootstrap'  # Remove this line
gem 'bootstrap-sass'

그것은 단지

gem 'bootstrap-sass'

다음 단계로 해결했습니다.

  1. 목록 항목
  2. 내 "app / assets / stylesheets /에서"bootstrap.css "복사 (누락 됨)
  3. gem install autoprefixer-rails (Gemfile도 수정)
  4. gem install sprockets (Gemfile도 수정)
  5. 번들 설치
  6. RESTART 서버 (단지 새로 고침 페이지가 아님)

이것이 제가 문제를 해결 한 방법입니다.

Sass Github 용 부트 스트랩 페이지로 이동 하여 지침을 따르십시오.

  1. Gemfile에 다음을 추가하십시오.

    gem 'bootstrap-sass', '~> 3.3.6'gem 'sass-rails', '> = 3.2'

  2. 명령 실행 bundle install

  3. 서버 시작 / 다시 시작

    레일 s

또한 파일의 확장자가 .scss (또는 Sass 구문의 경우 .sass)인지 확인하십시오. 새 Rails 앱을 방금 생성 한 경우 대신 .css 파일이 함께 제공 될 수 있습니다. 이 파일이있는 경우 Sass 대신 제공되므로 이름을 바꿉니다. 그런 다음 모든 * = require_self 및 * = require_tree를 제거하십시오. sass 파일의 문. 대신 @import를 사용하여 Sass 파일을 가져 오십시오.


나는 같은 행동을 관찰했습니다. 제 경우에는 'bootstap-sass'보석 버전을 제거했으며 작동했습니다. 문제를 일으키는 gem 버전과의 호환성 문제가있을 수 있습니다.

보석 파일

gem 'bootstrap-sass'

gem 파일을 변경 한 후 다음 명령을 수행하십시오.

bundle install

서버가 이미 실행중인 경우 " CTRL + C " 로 중지 하고 서버를 다시 시작하십시오.

rails s

Gemfile에서 bootstrap-sass gem을 추가하고 sass-rails gem이 있는지 확인해야합니다. 기본적으로 새로운 Rails 애플리케이션에 추가됩니다.

gem 'bootstrap-sass', '3.3.7'
gem 'sass-rails', '5.0.6'
gem 'rails', '5.0.0'

번들을 설치하고 서버를 다시 시작하여 파이프 라인을 통해 파일을 사용할 수 있도록합니다. app / assets / stylesheets / application.scss 에서 부트 스트랩 스타일을 가져옵니다 .

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";

아이콘 글꼴이 작동하려면 부트 스트랩 전에 부트 스트랩 스프로킷을 가져와야합니다. 파일의 확장자가 .scss (또는 Sass 구문의 경우 .sass)인지 확인하십시오. 새 Rails 앱을 방금 생성 한 경우 대신 .css 파일이 함께 제공 될 수 있습니다. 이 파일이있는 경우 Sass 대신 제공되므로 이름을 바꿉니다.

$ mv app / assets / stylesheets / application.css받는 사람 : app / assets / stylesheets / application.scss

그런 다음 sass 파일에서 모든 *= require_self*= require_tree .문을 제거 하십시오. 대신 @importSass 파일을 가져 오는 데 사용 하십시오. 예 :

*= require_tree .
*= require_self

에:

@import require_tree .
@import require_self

*= requireSass에서 사용하지 마십시오. 그렇지 않으면 다른 스타일 시트가 부트 스트랩 믹스 인 또는 변수에 액세스 할 수 없습니다. 부트 스트랩 JavaScript는 jQuery에 의존합니다. 을 사용하는 경우 Rails 5.1+Gemfile에 jquery-rails gem을 추가합니다.

gem 'jquery-rails'

$ bundle install

에서 부트 스트랩 자바 스크립트 필요

app / assets / javascripts / application.js :

//= require jquery
//= require bootstrap-sprockets

bootstrap-sprockets그리고 bootstrap모두에 포함되어서는 안된다

application.js

. bootstrap-sprockets개별 Bootstrap Javascript 파일 (예 : alert.js 또는 dropdown.js)을 bootstrap제공하고 모든 Bootstrap Javascript를 포함하는 연결된 파일 제공합니다.

This will fix the error

Copied @github

This error mostly comes in rails 3.2.x versions. If you are using rails version 3.2 you have to specify a special version in your gem file like below:

gem 'rails', '3.2.0'
gem 'bootstrap-sass', '3.2.0.2'

It will resolve the problem for rails -v '3.2.0'


put this in gem file

gem 'bootstrap-sass', '~> 3.3.5'
gem 'sass-rails', '>= 3.2'

then run $ bundle install

Restart the server.


If you get this message when running integration tests, make sure that your asset gems are included in the test group.

For example, change:

group :assets do gem 'sass-rails', '~> 5.0.3' gem 'uglifier', '>= 1.3.0' end

To:

group :assets, :test do gem 'sass-rails', '~> 5.0.3' gem 'uglifier', '>= 1.3.0' end


I had the same problem

sass::syntaxerror: file to import not found or unreadable: config/variables.

, I opened a new css file (I called it custom.css) then copied all the css to the file. On application.css I removed the

@import "config/variables" plus all the other @imports

This worked for me, I hope it does work for you too!


make sure you run the following commands after adding this gem to your Gemfile put this inside your Gemfile

    gem "bootstrap-sprockets", "~>3.3"
    gem "bootstrap"

now stop your server and run the following:

    bundle install
    rails server

to restart your server. Refresh your browser and you should see changes reflect immediately. In production you may have to run this command to precompile your assets:

    bundle exec bin/rake assets:precompile

It worked for me. Hope this was helpful.


I had same problem but i solved it, you just need to add your gem bootstrap-sass in development group like this:

    group :development do
    gem 'bootstrap-sass'
    end

i hope this will help


I was also facing the similar error in development environment:

Error Image

I solved this problem by-

  1. In my gemfile, I added them -

    gem 'bootstrap', '~> 4.2.1'

    gem 'jquery-rails'

  2. In application.js file,add these -

    //= require jquery3

    //= require popper

    //= require bootstrap-sprockets

  3. In the file with .scss extension, simply add -

    @import "bootstrap";

    After that, just run bundle install

ReferenceURL : https://stackoverflow.com/questions/26135126/sasssyntaxerror-file-to-import-not-found-or-unreadable-bootstrap-sprockets

반응형