ES6 + Uglifier with Jekyll: Uglifier::Error: Unexpected token: keyword (const) - ruby

Here is the complete error:
Liquid Exception: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). in /_layouts/base.html
I found online that the solution should be to use:
Uglifier.compile(js, harmony: true)
in a production.rb file, which I don't have since I'm using Jekyll and all I can set is in config.yml:
...
assets:
js_compressor: uglifier
...

Try this one in your _config.yml: https://github.com/dart-lang/site-www/issues/502#issuecomment-365955221
assets:
...
external:
uglifier:
harmony: true

Get rid of Uglifier. It doesn't support ES6, or at least it doesn't with the configuration that ships with Rails.

Related

Rails 5: undefined method `megabytes' for 64:Integer when using in config/environment/staging.rb

As explained in Caching with Rails Guide I added the following line to config/environment/staging.rb:
Rails.application.configure do
...
config.cache_store = :memory_store, { size: 64.megabytes }
...
end
This raised the error when starting Puma server:
undefined method `megabytes' for 64:Integer
Requiring the corresponding acctive_suport module on the top of staging.rb:
require 'active_support/core_ext/numeric/bytes'
...
solved the issue.
What am I missing ? Thank you.
Used Rails version: 5.2.2, API mode.
Ruby: 2.6.1.

don't have related_posts.rb or one of its dependencies installed

I am trying to implement related_posts-jekyll_plugin plugin to show the related post based on post tag on jekyll blog. When running jekyll server I got following error, how can I solve it?
$ jekyll serve
Configuration file: D:/git/blog/_config.yml
Dependency Error: Yikes! It looks like you don't have D:/git/blog/_plugins/related_posts.rb or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll/post' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.6.0 | Error: D:/git/blog/_plugins/related_posts.rb
My _config.yml file contains following content.
title: Kiran's blog | Kiran Shahi is a .NET developer from Nepal
email: mail#example.com
description: > # this means to ignore newlines until "baseurl:"
Welcome to kiran's blog. Kiran Shahi is a .NET guy. He is passionate about technology.
baseurl: "/blog" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: itskirans
github_username: kiranshahi
future: true
paginate: 5
# Build settings
markdown: kramdown
gems:
- jekyll-feed
- jekyll-paginate
exclude:
- Gemfile
- Gemfile.lock
Although we can't see your config file, It Looks like you have related_posts.rb in your gem list in your config file. As this plugin is not a gem but just a plugin file you do not need to list it there. Just remove it from that section.

Yaml Exception : Unable to parse (near "apply_to: "\.css$"")

Since I have migrated to Symfony3 (from Symfony 2.8), I have an exception when the config.yml is parsing :
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The file "/home/public_html/app/config/config.yml"
does not contain valid YAML.
[Symfony\Component\Yaml\Exception\ParseException]
Unable to parse at line 60 (near "apply_to: "\.css$"").
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: ["MyBundle"]
java: /usr/bin/java
ruby: /usr/bin/ruby
filters:
cssrewrite: ~
sass:
bin: /usr/bin/sass
compass:
bin: /usr/bin/compass
yui_css:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
apply_to: "\.css$"
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
apply_to: "\.js$"
During my passage to SF2.8 to SF3.0 this code has not changed. The documentation has not changed too : http://symfony.com/doc/current/cookbook/assetic/apply_to_option.html
If I replace:
apply_to: "\.css$"
By:
apply_to: ".css$"
I have not error, but this is not the good result.
Do you know why I couldn't wrote apply_to: ".css$" as the doc?
Sorry for my bad English...
The S3 yaml implementation now follows the yaml standards a bit more closely. http://symfony.com/doc/current/components/yaml/yaml_format.html#strings
So replace your double quotes with single quotes and all should be well. Or use \. Keep in mind that S3 is not backwards compatible with S2 so you will probably run into a bunch of these issues when trying to upgrade existing projects.
And be sure to quote any #service_ids

Syntax error with rubygem elasticsearch

I have a problem using the rubygem for elasticsearch
When I try to execute the following code :
#!/usr/bin/env ruby
require 'rubygems'
require 'elasticsearch'
client = Elasticsearch::Client.new log: true
I get the following error :
syntax error, unexpected ':', expecting $end
client = Elasticsearch::Client.new log: true
^
Any ideas about this ?
Thanks
You seem to use Ruby prior to 1.9 version. If so, either update Ruby (which is recommended), or use old rocket-hash syntax:
client = Elasticsearch.new :log => true

Symfony2 can't find ruby.xml in assetic filters

need your help.
Just installed compass and sass, and after reloading page, I've got this error:
InvalidArgumentException: The file "filters/ruby.xml" does not exist (in: /var/www/ProjectName/Symfony/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/DependencyInjection/../Resources/config).
How can I reinstall or create the file.?
Looks like your Assetic config is incorrect, and it tries to load configuration for a non-existent ruby filter. I assume that assetic.filters section of your configuration looks like this:
assetic:
# ...
filters:
ruby:
apply_to: "\.sass$"
Assetic looks up a filter configuration that matches the filters array keys, and it sure cannot find a ruby filter. You should use sass filter instead:
assetic:
# ...
filters:
sass:
apply_to: "\.scss$"

Resources