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

Huginn failing with error "Asset was not declared to be precompiled in production" #1201

Closed
Androoz opened this issue Dec 30, 2015 · 8 comments

Comments

@Androoz
Copy link

Androoz commented Dec 30, 2015

Hi there!

I'm new to Huginn and Ruby, and trying to get it everything up and running. But almost at the finish line, I've run into a problem when trying to edit and/or add an agent. I immediately get a Rails error stating:

Sprockets::Rails::Helper::AssetNotPrecompiled in Agents#new
Showing /Users/MiniMe/Desktop/huginn/app/views/agents/_form.html.erb where line #1 raised:

Asset was not declared to be precompiled in production.
Add `Rails.application.config.assets.precompile += %w( ace.js )` to `config/initializers/assets.rb` and restart your server

...

See also attached screen grab.

I can't find any config/initializers/assets.rband what I can see is config.assets.precompile += %w( ace.js )already stated in config/environments/production.rb together with the rest of javascripts?

I have precompiled the assets manually by running RAILS_ENV=production bundle exec rake assets:precompile with success but I still get the same error when running Huginn...

Can somebody please give me some ideas :) because I'm totally stuck...

Regards,
Anders

skarmavbild 2015-12-30 kl 21 46 54

@Androoz
Copy link
Author

Androoz commented Jan 1, 2016

Hi again!

I solved it myself, and in retrospect I had the solution already as stated in the error message:

Add `Rails.application.config.assets.precompile += %w( ace.js )` to `config/initializers/assets.rb`

But config/initializers/assets.rb did not exist, so I had to create it and then add the following strings:

Rails.application.config.assets.precompile += %w( ace.js )
Rails.application.config.assets.precompile += %w( diagram.js )
Rails.application.config.assets.precompile += %w( graphing.js )
Rails.application.config.assets.precompile += %w( map_marker.js )

But I still don't understand why I needed to create assets.rb and add these strings? I couldn't find this in any documentation or tutorials, so why did I need to add this for my installation?

Thanks in advance :)

Regards,
Anders

@dsander
Copy link
Collaborator

dsander commented Jan 1, 2016

Hi @Androoz,

the initializer should not be needed, additional static files are configured in config/environments/production.rb, did you set the RAILS_ENV in your .env file?

@Androoz
Copy link
Author

Androoz commented Jan 1, 2016

RAILS_ENV is commented out and not defined in my .env file. I defined it as "production" the other day and got the error to disappear but I reverted back because the stylesheets was not loading correctly. Should I define again and try to re-run bundle exec rake assets:precompile?

I'm also little confused about the difference between "production" and "development" deployments?

@dsander
Copy link
Collaborator

dsander commented Jan 1, 2016

Yes, when you want to precompile the assets and run in the production environment RAILS_ENV=production should be enabled.

The environments change the way rails behaves, development is for development where you want to change the code and instantly see the changes, it includes code reloading and on the fly asset compilation. (make sure to delete the public/assets directory if you switch from production to development)
production is for deployments on servers, precompiling assets and caching classes (the code) improves the performance put also does not allow to apply changes without restarting the server and precompiling the assets again.

@Androoz
Copy link
Author

Androoz commented Jan 4, 2016

Thanks @dsander! I will give RAILS_ENV=production another chance then :)

@cantino
Copy link
Member

cantino commented Feb 14, 2016

Did that work for you @Androoz?

@Androoz
Copy link
Author

Androoz commented Feb 21, 2016

Sorry for late reply @cantino and @dsander.

It did work sort of, but I yet again got the CSS problem where the stylesheets won't load correctly. So I reverted back to my previous solution using a config/initializers/assets.rb file. After that I got Huginn to work and I haven't looked further into it.

@cantino
Copy link
Member

cantino commented Feb 21, 2016

Thanks for letting us know! Please re-open if you have any issues.

@cantino cantino closed this as completed Feb 21, 2016
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

3 participants