heroku throwing bourbon `Undefined mixin 'transform'` - heroku

i'm deploying a rails 4 app to heroku, getting
Running: rake assets:precompile
I, [2013-10-31T13:50:45.980969 #699] INFO -- : Writing /tmp/build_66fd87fd-a9f1-442b-88b3-ccbc9f7f6e28/public/assets/application-ffa1a91721fb49b9c6414032f35a7045.js
rake aborted!
Undefined mixin 'transform'.
(in /tmp/build_66fd87fd-a9f1-442b-88b3-ccbc9f7f6e28/app/assets/stylesheets/main.css.scss:29)
/tmp/build_66fd87fd-a9f1-442b-88b3-ccbc9f7f6e28/app/assets/stylesheets/main.css.scss:29:in `transform'
/tmp/build_66fd87fd-a9f1-442b-88b3-ccbc9f7f6e28/app/assets/stylesheets/main.css.scss:29
everything is working locally including the style that mixin is associate with so I'm confused about this. Not seeing much documentation on google:foo about what the problem is. I've got
config.assets.initialize_on_precompile = false
in application.rb
Any thoughts on what to do here ?

It looks like your application.css.scss includes a main.css.scss which references bourbon mixins. You need add #import 'bourbon' to the top of your main.css.scss file and any other scss file that references the mixins.

Related

Gem development can't add new file

I'm having what seems to be some very basic problems getting started with Gem development in ruby.
I've created a new project with this command.
bundle gem foobar
I can now run
bundle && bundle exec rake spec
and everything is fine.
However I try to add a new part to my spec
expect(Foobar::BAR).not_to be nil
and then define this in ./lib/foobar/error.rb
module Foobar
BAR="bar"
end
It just does not find this file. Error is NameError: uninitialized constant. I can require_relative in spec_helper.rb but that's clearly not right or sustainable.
I've seen the issue here Missing File in Gem after Build I've added the new file to git. That does not help, adding the files directly in the gemspec file does not help either.
The whole project is here https://github.com/ollyjshaw/broken_gem
What am I doing wrong? It's gotta be something trivial, but I can't see it.
Answer:
Answer is in Antony's comment
"You're not requiring your error file when your gem is loaded: github.com/ollyjshaw/broken_gem/blob/master/lib/foobar.rb#L1"
"You'd load your main module and that module would load other modules/classes it needs and down the tree it goes"
Typically you'd add all the class/module files to the load path in the spec_helper.rb file:
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "your_gem"

Trying to get Sass and Bundler to work cross team?

I created a project that is working and compiling sass as expected. My setup is just using sass, compass, & susy with Netbeans. I had another team member pull it from source control and he is unable to compile with the error:
Syntax error: File to import not found or unreadable: susy.
Load paths:
C:/wamp/www/77864nl2014/wp-content/themes/nl (DEPRECATED)
C:/wamp/www/77864nl2014/wp-content/themes/nl/sass
C:/Program Files (x86)/Prepros/gems/gems/bourbon-3.1.8/app/assets/stylesheets
C:/Program Files (x86)/Prepros/gems/gems/neat-1.4.0/app/assets/stylesheets
C:/wamp/www/77864nl2014/wp-content/themes/nl/sass
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-core-1.0.0.alpha.19/stylesheets
Compass::SpriteImporter
on line 2 of C:\wamp\www\77864nl2014\wp-content\themes\nl\sass\main.scss
Use --trace for backtrace.
He is using prepros and has a watch setup on the projects sass directory. He says that prepros is setup with the compass option and configured to use ruby. He has also already installed bundler.
The project config.rb looks like this:
http_path = '/'
css_dir = '/wp-content/themes/nl/styles'
sass_dir = '/wp-content/themes/nl/sass'
images_dir = '/wp-content/themes/nl/images'
javascripts_dir = '/wp-content/themes/nl/scripts'
require 'bundler/setup'
require 'susy'
The Gemfile looks like:
source 'https://rubygems.org'
gem 'sass', '3.3.4'
gem 'compass','1.0.0.alpha.19'
gem 'susy','1.0.9'
I'm not sure what's going on exactly but have several things to try, but hope asking here could expedite the process. We have numerous developers in my office using PCs and Macs, with various IDEs and I was hoping bundler could help solve some issues we have been having. I want to be able to set the specific gems and versions used for a project and commit that with the rest of the project in source control. If another developer needs to work on that project I was hoping bundler would use or pull down the proper gems for the project and the developer would be off and running without having to update configs, gems, etc. Is this how bundler can work once we figure this out? If not is there another better solution for our situation and goals?
The key was to prepend your "compass watch" with "bundle exec". So in command prompt, start your watch using "bundle exec compass watch" on the project directory.

File to import not found or unreadable when using Rails asset gem

I'm trying to create a rails asset gem whose source is here. The problem is that when I use the gem in try to require or import the asset files in my Rails 4 project, I get the error:
File to import not found or unreadable: jquery.xdan.datetimepicker
I've inspected the paths it is looking through, and it looks like it's not actually looking in the assets directory for my gem (the gem folder isn't anywhere in the list). So, it seems like the gem isn't getting required, since if it was, the Engine would be getting loaded, indicating to Rails that I have an assets folder somewhere. Can anyone see what I'm missing? From what I can tell, I'm doing everything that other asset gems are doing.
I looked at your Gem. In order to get it working, rename lib/xdan_datetimepicker_rails.rb to lib/xdan-datetimepicker-rails.rb.
In your Rails project, uninstall your old gem and install the new one. To make sure it's installed properly:
$ rails c
> pp MyRailsApp::Application.assets.paths
You should see an array of paths that are in the asset pipeline. Look for:
/gem/path/to/xdan-datetimepicker-rails-0.0.1/app/assets/javascripts
/gem/path/to/xdan-datetimepicker-rails-0.0.1/app/assets/stylesheets
NOTE: Restart rails c and/or rails s if you're not seeing it.
Finally, in order to use the assets:
app/assets/javascript/application.js
//= require jquery.xdan.datetimepicker
app/assets/stylesheets/stylesheet.css.scss
*= require jquery.xdan.datetimepicker

susy 'Manual Start' - does it actually work?

On the Susy Getting Started page, there's a section marked 'Manual Start', which says :
"You can use this method if you're not using Compass from Terminal and/or Rails".
It then explains how to copy Susy's Sass definitions and #import "susy", after which (it claims), "you're good to go".
I'm trying to use Susy as part of my own build system, which uses the 'sass' command-line command to compile my stylesheets. Obviously, the Susy Sass mixins and includes depend on Compass, so I extracted the Compass Sass definitions from the Compass distribution, and put them where they could be accessed by Susy. I then tried to compile my stylesheets with:
sass -I scss/compass scss/foobar.scss ${CSSDIR}/foobar.css
When I do this, Susy throws a warning:
"You need to provide either a valid layout (number of columns) or a valid media-query min-width breakpoint (length)".
Digging into the code, it appears that the issue is that Susy calls the 'compact' function provided by Compass. The actual call is something like:
compact(false,false,false,...)
which - I presume - should evaluate to:
false
But 'compact' isn't a Sass feature; it's a Compass function, implemented in Ruby as part of Compass. If Compass's Ruby extensions aren't available, that call is left unchanged, so the Susy mixin is getting handed:
compact(false,false,false,...)
which is not 'false' ... and so things go pear-shaped. (The trouble happens at line 93 of susy/_grid.scss).
It looks to me as if using Susy without Compass is not actually possible. What's my best solution to this issue? Do I just use 'compass compile ...'instead of 'sass' to compile my stylesheet? Or can I somehow provide the 'compact' function to 'sass' in some other way?
You can add this function yourself, though I really recommend using Compass. All it requires is a config.rb file so that Compass knows where files are supposed to live for various helper functions. The command for compiling with Compass is more compact since the output location is already defined in the config file: compass watch or compass compile
If you don't want to use Compass, you can add the function yourself. First you'll need the custom function, which comes from here: https://github.com/chriseppstein/compass/blob/stable/lib/compass/sass_extensions/functions/lists.rb#L18
def compact(*args)
sep = :comma
if args.size == 1 && args.first.is_a?(Sass::Script::List)
list = args.first
args = list.value
sep = list.separator
end
Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep)
end
Place it in a ruby file wherever makes sense.
Your sass command now just needs to add this flag: -r ./path/to/functions.rb

generating css file from new sass format (scss) with sinatra and haml

I am writing a sinatra app with haml and sass. When I try to link in the stylesheet with a scss extension located in my views folder I get the following error: NoMethodError at /nav.css undefined method `scss'
Here is my get method
get '/nav.css' do
content_type 'text/css', :charset => 'utf-8'
scss :nav
end
I have only gotten this to work when I switch to the older sass syntax. I also have to change the nav.scss to nav.sass and the get method to sass :nav
I have also tried just having sass :nav with nav.scss and sass :nav with nav.sass but still scss syntax
I don't use the above code from the README, just put the following in your app.rb file after updating your gem.
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss(:"stylesheets/#{params[:name]}")
end
Restart your server and you're all set. Happy Scssing.
Excerpt from Sinatra README
## You'll need to require haml or sass in your app
require 'sass'
get '/stylesheet.css' do
scss :stylesheet
end
Are you required the sass gem?
What version of Sinatra you use. Support for scss was added in 2010.09.01 (same day version was increased from 1.0 to 1.1), perhaps you need and update.

Resources