Undefined variable: "$bold-font-weight".
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?
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?
Yeah, it appears to all be there. It just isn't being read correctly for some reason.
I just set the gem to cf1e39 and it seems to be working ok now. Maybe it's related to the Bourbon 5 commit?
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 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?
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.
I have the same issue precompiling assets
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.
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"
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?
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?
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);
Confirmed the above workaround lets me progress, thanks @commuun.
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?
@chriscapetown Strange, fwiw I was able to deploy to production given the above workaround.
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.
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
This happened to me becouse initializer assets.rb had this line:
Rails.application.config.assets.precompile += %w( *.css *.js )
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.)
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.