@import 'bootstrap' error on win7 , showin

2020-07-09 06:46发布

I am building a simple rails app and when I load the home page I get:

    Completed 500 Internal Server Error in 59ms
    ActionView::Template::Error (different prefix: "c:/" and
    "D:/workspaceRor/jrpappthree/ ssets/stylesheets" 
    (in D:/workspaceRor/jrpappthree/app/assets/stylesheets/custom.css.scss)):
2: <html>
3:   <head>
4:     <title><%= full_title(yield(:title)) %></title>
5:     <%= stylesheet_link_tag    "application", media: "all" %>
6:     <%= javascript_include_tag "application" %>
7:     <%= csrf_meta_tags %>
8:     <%= render 'layouts/shim' %>

my gem file

gem 'rails'
gem 'bootstrap-sass'
gem 'bcrypt-ruby'
gem 'faker'
gem 'will_paginate'
gem 'bootstrap-will_paginate'
gem 'pg'
group :development, :test do
gem 'mysql2'
gem 'annotate'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do

gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'railties'
end
gem 'jquery-rails'
group :test do

end

group :production do
#  gem 'pg'
end

in D:/workspaceRor/jrpappthree/app/assets/stylesheets/custom.css.scss

@import "bootstrap";


body {
   padding-top: 60px;
}
.
.
.

In development environment, it shows the above error, but in production it works fine. I even tried

# config/environments/production.rb
...
config.assets.compile = true
...

but it didnt solve my problem. So what will be the solution for running the app in development env. successfully?

3条回答
你好瞎i
2楼-- · 2020-07-09 07:05

Another solution is to create a junction point (like a hard link but works on directories) from the C: drive to the D: drive and run the rails server in the linked directory on the C: drive. AFAIK the command varies with OS version, but on Vista this works:

mklink /J c:\<linkdir> d:\<targetdir>

I believe there is an app called "Junction" available on-line for older OS versions. On my system, I held the application on a USB stick so I could move it readily between desktop and laptop systems and thus did not want to move it to C:. The application is called "orders", so I executed:

mklink /J c:\ordersapp d:\sites\orders

Then to run the rails server:

c:\> cd \ordersapp

c:\ordersapp> rails s

And everything works. The code now appears to be running on c:.

查看更多
成全新的幸福
3楼-- · 2020-07-09 07:18

This is actually an issue in Rails - see this: https://github.com/rails/rails/issues/660

查看更多
ゆ 、 Hurt°
4楼-- · 2020-07-09 07:31

Looks like it is a bug in the bootstrap.sass gem on windows.

I have seen people move the project to the C Drive and then it starts working.

查看更多
登录 后发表回答