administrate icon indicating copy to clipboard operation
administrate copied to clipboard

Undefined variable: "$bold-font-weight".

Open stevepsharpe opened this issue 10 years ago • 47 comments

Hi all

I'm using the gem directly from Github and if I run rails generate administrate:assets:stylesheets. I get the following error Undefined variable: "$bold-font-weight". when trying to load anything in /admin

I also noticed that some of the generators seem to produce different code from the default code. For example 'rails generate administrate:views:new Client' the forms all look broken.

Any ideas how to resolve this?

stevepsharpe avatar Jan 22 '16 17:01 stevepsharpe

Here’s a relevant commit, which added the $bold-font-weight Sass variable: https://github.com/thoughtbot/administrate/commit/28e084f10c7b65f0779ab7e1dc52f1d7b3fe16fe

master is always a bit in flux, and especially the past couple weeks has seen a lot of updates.

Can you look in app/assets/stylesheets/administrate/library/_variables.scss and see if $bold-font-weight is defined in there?

tysongach avatar Jan 22 '16 17:01 tysongach

Yeah, it appears to all be there. It just isn't being read correctly for some reason.

stevepsharpe avatar Jan 22 '16 17:01 stevepsharpe

I just set the gem to cf1e39 and it seems to be working ok now. Maybe it's related to the Bourbon 5 commit?

stevepsharpe avatar Jan 22 '16 17:01 stevepsharpe

Ok, I spoke too soon. It's still doing it. I restarted the server and now it's doing it all of the time.

stevepsharpe avatar Jan 22 '16 17:01 stevepsharpe

@stevepsharpe v0.1.3 was just released a few minutes ago and packages up everything that was on master. Can you swap for this official version and see if the issue persists?

tysongach avatar Jan 22 '16 18:01 tysongach

Ok gem updated, everything works as expected until I run rails generate administrate:assets:stylesheets, then you start to get the Undefined variable: "$bold-font-weight" issue.

stevepsharpe avatar Jan 22 '16 18:01 stevepsharpe

I have the same issue precompiling assets

j-dexx avatar Jan 25 '16 13:01 j-dexx

Ran into the same issue. There seems to be something strange going on. The full error I get on precompile is:

Sass::SyntaxError: Undefined variable: "$bold-font-weight".
app/assets/stylesheets/administrate/base/_forms.scss:9

As a test I removed the line @import "base/**/*"; from app/assets/stylesheets/administrate/application.scss but the error persists. At that point it should not be trying to include _forms.scss, but it does.

commuun avatar Feb 01 '16 21:02 commuun

Same issue here.

I tried running rails d administrate:assets:stylesheets followed by rails g administrate:assets:stylesheets to no avail.

❯ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin15]

❯ rails -v
Rails 4.2.5

Gemfile: gem "administrate", "~> 0.1.3"

Decoherence avatar Feb 08 '16 19:02 Decoherence

damn. I just spent about an hour on this, and I'm not really getting anywhere.

Here's one thing that I did that yielded mildly interesting results:

  • Clone the Administrate repository

  • Run rails generate administrate:assets:stylesheets

  • Remove these lines from spec/example_app/app/assets/stylesheets/administrate/application.scss:

    @import "base/**/*";
    @import "components/**/*";
    
  • Remove the root stylesheet from Administrate:

    rm app/assets/stylesheets/administrate/application.scss
    

After all of those things, the SCSS compiles correctly. Doing any of those individually doesn't work.

To me, this implies that the application.scss contained within the Administrate gem is telling the host application to compile those assets, even when the @import statements are removed from the host's administrate/application.scss.

Is anyone up for creating a minimal reproduction?

c-lliope avatar Feb 14 '16 01:02 c-lliope

Also running into this problem. Any solutions yet?

Rails 4.2.5.1 ruby 2.3.0p0 Gem 0.14

@stevepsharpe did you manage to get past this problem?

chrisedington avatar Mar 02 '16 15:03 chrisedington

This is not very helpful solving the actual problem but for those like me who need to make progress, I worked around the issue by importing the variables at the top of my application.scss

@import 'administrate/library/variables';

Note that this required me to copy-paste two values from the included Bourbon library in app/assets/stylesheets/administrate/library/_variables.scss

$modular-scale-ratio: 1.2;

$base-timing: cubic-bezier(0.215,  0.610, 0.355, 1.000);

commuun avatar Mar 13 '16 17:03 commuun

Confirmed the above workaround lets me progress, thanks @commuun.

chrisedington avatar Mar 14 '16 07:03 chrisedington

Actually still struggling with this issue, @commuun's fix made the pre-compilation succeed on my dev environment but as soon as I try do a asset pre-compilation in production it shows the same error again.

bundle exec rake assets:precompile

Result:

Undefined variable: "$bold-font-weight"

@graysonwright any ideas what I can try?

chrisedington avatar Mar 29 '16 07:03 chrisedington

@chriscapetown Strange, fwiw I was able to deploy to production given the above workaround.

commuun avatar Mar 30 '16 14:03 commuun

Interesting, thanks for letting me know, will dig a little more.

Would you be able to share a gist of your production.rb file? Maybe that will shed some light.

chrisedington avatar Mar 30 '16 15:03 chrisedington

Not sure it will do much good, I'm not even sure I changed anything in the environment so far. (edit: I should say, this is a staging environment but it uses a copy of the production env)

https://gist.github.com/commuun/32e81d1c3edbf89275241820c4a12f48

commuun avatar Mar 30 '16 15:03 commuun

This happened to me becouse initializer assets.rb had this line:

Rails.application.config.assets.precompile += %w( *.css *.js )

pmaojo avatar Apr 07 '16 23:04 pmaojo

I just checked, my app doesn't have this wildcard precompile include. Mine is

Rails.application.config.assets.precompile += %w( docs.js docs.css )

But the problem persists (as long as I don't apply the above workaround.)

commuun avatar Apr 08 '16 12:04 commuun

The wildcard interfered in our side too. We removed it completely.

If I remember rightly we ended up renaming the application.css to application.css.scss and adding a wildcard in there, will post the exact steps but this works in a prod environment too.

chrisedington avatar Apr 09 '16 20:04 chrisedington