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

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

Related

Yamllint exclude # symbol check in application.yaml file

I have used linter to lint spring-boot framework application.yaml file:
---
spring:
application:
name: #project.name#
#project.name# value allows spring-boot application to resolve application name from pom.xml file.
However when I run linter (yamllint ./src/main/) I get an error:
Error: ./src/main/resources/application.yaml:4:11: [error] syntax error: found character '#' that cannot start any token (syntax)
Is there any rule how can I exclude special characters check?
That's a syntax error. yamllint uses PyYAML for parsing, which yields this error. PyYAML obviously cannot ignore a syntax error, and by extension, yamllint cannot ignore it.
Your best bet is to preprocess the file to replace all referenced variables, e.g.
sed -E 's/#([^#]*)#/_\1_/g' application.yaml | yamllint -
This replaces the # characters around variable references with _, which keeps the line length.

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

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.

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.

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$"

symfony2 assetics yui compressor on windows (path syntax)

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.
Now I want to add the yui compressor and my config.yml looks like this:
assetic:
debug: %kernel.debug%
use_controller: false
filters:
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar
Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):
[RuntimeException]
The syntax for filename, directory name or drive name is wrong
I found an article telling me to specify the path to java.exe, so I add this to config.yml:
assetic:
..
java: C:/Program Files (x86)/Java/jre6/bin/java.exe
..
Now assetic:dump tells me:
[RuntimeException]
The COMMAND "C:/Program" is either written wrong or
I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.
Ok, I figured it out. Man, this one was brutal.
Let's start with the easy stuff. A working version of the config.yml can look like this:
assetic:
debug: false
use_controller: false
java: C:\Program Files (x86)\Java\jre6\bin\java.exe
sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
filters:
scss: ~
yui_js:
jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.
And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.
The Assetic\Util\ProcessBuilder has to be changed on line 95
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
,line 103
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
and line 110
return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.
Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)
Now it works on windows. Thanks!
Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7
For other users who use window server 2008 r2 :
Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user
please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :
ruby -S gem install sass
so that you will get the sass.bat in that position
It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

Resources