Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nib (again) #29

Open
jney opened this issue Jul 6, 2012 · 15 comments
Open

nib (again) #29

jney opened this issue Jul 6, 2012 · 15 comments

Comments

@jney
Copy link

jney commented Jul 6, 2012

Hello Lucas,

Just a question, i'm using this gem for first time in rails assets
Got an initializer with following code :

Stylus.use(:nib) unless Rails.env == 'production'

and got this in a styl file

@import "nib"

but got the following error

ActionView::Template::Error (Error: Cannot find module 'nib'

what's wrong in the call of nib ?

thank you

@lucasmazza
Copy link
Contributor

How are you triggering this error? Is it with rake assets:precompile ?

@jney
Copy link
Author

jney commented Jul 6, 2012

it's triggered with the standard assets render
but it happens calling this rake task too :

$ RAILS_ENV=development rake assets:precompile

=>

Error: Cannot find module 'nib'

@lucasmazza
Copy link
Contributor

rake assets:precompile won't run any initializers unless the you set config.assets.initialize_on_precompile = true. But turning this on might raise other issues since it might attempt to connect to your database or something like that. It's better to wrap your setup on your application.rb or development.rb file.

@jney
Copy link
Author

jney commented Jul 6, 2012

i put Stylus.use(:nib) in application.rb but got the same error.

stylus and nib are installed :

$ node 
> var stylus = require("stylus")
undefined
> var nib = require("nib")
undefined
> typeof stylus
'function'
> typeof nib
'function'

@lucasmazza lucasmazza reopened this Jul 6, 2012
@lucasmazza
Copy link
Contributor

I'll try to replicate this into a new fresh app later.

@jney
Copy link
Author

jney commented Jul 6, 2012

ok.
anyway, thank you for the help.

@lucasmazza
Copy link
Contributor

So, I've tried to replicate your issue with this sample app that's deployed at Heroku, but It worked as expected. I've pushed these changes and bundle nib inside the Rails app.

Do you have nib installed somewhere else than ./node_modules or I'm missing something?

@bluestrike2
Copy link
Contributor

I had some similar issues a while back that was ticking me off quite a bit deploying to Heroku; ended up having to add require 'stylus' to application.rb in order to avoid the same error.

@jney
Copy link
Author

jney commented Jul 9, 2012

thanks for your help guys, but i still have the problem.

got stylus and nib installed locally :

$ ls -1 ./node_modules
nib
stylus

got this in my application.rb :

if Rails.env != 'production'
  require 'stylus'
  Stylus.use(:nib)
  Stylus.debug = true
end

got the @import in my *.styl.css file

but still got the same ExecJS::ProgramError error

@lucasmazza
Copy link
Contributor

I'm curious: why the != 'production' check? How you're handling precompilation and deploy of your assets?

@jney
Copy link
Author

jney commented Jul 9, 2012

i'm not really aware about rails 3 assets, i thought assets would be compiled before production deployment.
anyway, i that's not the issue

@lucasmazza
Copy link
Contributor

A better approach would use if defined? Stylus, because the assets group in your Gemfile (I suppose that's where you added gem 'stylus') is loaded conditionally by Rails when booting the app or precompiling the assets. So you would be querying based on if Rails required stylus or not, instead of which env it's running at the moment.

@bluestrike2
Copy link
Contributor

Hmm that's peculiar; fresh app with zero changes from base config using the exact same block you posted caused no issues. Do you have any other changes to your configs (app or env files) that would affect the pipeline? They'd be namespaced under config.assets.... if that helps.

@esamattis
Copy link

I had similar issues with precompiling. It seems that Stylus.use(:nib) does not work with Stylus.debug = true during precompile.

So I worked around it by doing this in my application.rb after the bundler require calls:

if defined? Stylus                        
  Stylus.use(:nib)                        
  Stylus.debug = Rails.env != "production"
end                                       

@cmtonkinson
Copy link
Member

Is this thread still relevant or may I close the issue? I'll close in about 2 weeks if no one responds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants