Issue on installing a own written logstash plugin - ruby

I am doing my firts steps on writing my own logstash filter plugins. I followed the instructions of https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html but I do not get it done.
I do this on my windows machine. The following has been ensured
Proper JAVA_HOME is set and its bin folder is added to PATH
JRuby is installed
Proper JRUBY_HOME is set and its bin folder is added to PATH
I did the following
Cloned and did NO source code changes on https://github.com/logstash-plugins/logstash-filter-example.git
Did a successful gem build which created the file logstash-filter-example-3.0.0.gem
Wanted to see if the plugin is working and tried to install it
Got this error message
logstash-plugin.bat install logstash-filter-example-3.0.0.gem
LoadError: no such file to load -- clamp
require at org/jruby/RubyKernel.java:956
require at C:/jruby-9.1.5.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
<main> at D:\hust\playground\logstash_filter_plugin\logstash-2.4.0\logstash-2.4.0\lib\pluginmanager\main.rb:14
I am a newbie to this world. Any suggestions what I am doing wrong here?
BW Hubert

Related

How to fix "s3_website" issue while pushing Jekyll site on CloudFront through gitlab CI/CD?

I have created Pipeline in GitLabs and I am using docker as gitlab-runner. I want to push Jekyll website on s3 website. And to do so, I am using s3_website gem. I have 4 stages defined in my pipeline. Where I am building Jekyll, creating Artifacts using Gulp, executing test on my jekyll site and then deploying.
All steps are working fine but while doing deployment, I'm getting following error. And i could not figure it how to get this solve.
[fail] Could not load the site: Failed to parse ERB in /builds/myproject/s3_website.yml:
(SyntaxError) /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_warn.rb:15: syntax error, unexpected tLABEL
module_function define_method(:warn) {|*messages, uplevel: nil|
It is working perfectly fine on my local machine when I'm not on Docker. But when I try to do the same thing using docker. It is giving me above error.
I tried it with ruby 2.3, 2.4, 2.5, 2.6 on my docker machine. However no luck.
bundle exec s3_website push
I am expecting this to deploy the site on S3 bucket and corresponding cloudfront.
Any clue would be appreciated.
We ran into this same error on CircleCI. If I understand correctly, the s3_website gem wraps a Java .jar that's using JRuby 1.7, and something must have changed in one of the Docker images or Ruby gems that causes it to start inheriting the system's Ruby 2+ path. As a result, its JRuby 1.7 tries to load Ruby gems that only work in Ruby 2.0 and above, so it runs into errors.
As a workaround, instead of letting the s3_website gem invoke the .jar file itself, I tell the s3_website gem to only download the .jar file, then I manually invoke it:
bundle exec s3_website install
java -cp $(bundle show s3_website)/*.jar s3.website.Push
I reported this on the s3_website project's GitHub page.
Same error message but different solution.
The root of my problem was that the S3_ACCESS_KEY_ID wasn't set properly. I source'd my .env file
source .env
And that loaded the access key variable and the deploy worked.

Could not find 'flat-ui.css' in any of your source paths while generating Flat UI Pro in rails app

I am integrating licensed version of flat-ui-pro with my Rails app.
For this, I am using 'designmodo-flatuipro-rails' gem
My environments are:-
OS - Windows7 32-bit
Ruby - 1.9.3p327
Rails - 4.0.0
twitter-bootstrap-rails - 2.2.8
jquery-ui-rails - 4.0.5
designmodo-flatuipro-rails - 1.1.4.2
I have generated "bootstrap_and_overrides.css" file by bootstrap generator at location "app/assets/stylesheets/". I am not using ".less" files for bootstrap.
I am also not getting Cannot detect twitter-bootstrap-rails install error
and Invalid Flat UI Pro directory error while running the flatUI generating command. It means I am inside the right FlatUI directory.
When I run the flat-ui-pro generate command rails g flatuipro:install ./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4, It is throwing a error
Could not find "./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4/css/flat-ui.css" in any of yo
ur source paths. Your current source paths are:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/designmodo-flatuipro-rails-1.1.4.2/lib/gener
ators/flatuipro/install/templates
I am getting the same error while passing the FlatUI directory containing PSD and HTML both.
I am not understanding why generator can not recognizing flat-ui.css in the right directory.
I used differ version of gem "designmodo-flatuipro-rails", "~> 1.2.2.0.branch" with the other version of FlatUI-Pro directory (1.2.2) but also getting the same error.
This is tree of FlatUiPro directory:-
Please reply with good suggestions.
Thanks.
Try changing your relative-path to the Flat-UI Pro Directory to "absolute" in the rails "generate" command, seems to work only for absolute paths!
After getting stuck very much, I found the solution.
I was hitting command in cmd-prompt:-
rails g flatuipro:install ./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4
It will work with Mac/Ubuntu OS as creator of flatui-gem explained in the issue created on github <<Link of Github Issue>>
In Windows, it is mandatory to put the flatui directory out of the project folder.
For example:-
My FlatUIPro directory saved in "D:" drive, so my command will be
rails g flatuipro:install D:/FlatUI
or
rails g flatuipro:install D:/FlatUI/HTML/UI/Flat-UI-Pro-1.1.4
Please check your Flat UI Pro directory... you really are missing demo.css for some reason. Try re-downloading the Flat UI Pro assets from designmodo

I get a LoadError when trying to about anything with a new Ruby install on Windows

I installed Ruby on Windows via RubyInstaller, with the associated DevKit.
I'm trying to run various scripts (mainly Jekyll), and I'm getting all sorts of errors about paths. For instance:
...cannot load such file -- redcarpet.so (LoadError)
Or:
...cannot load such file -- 2.0/redcloth_scan (LoadError)
Specifically, in both those cases, I'm trying to run "redcloth.bat" and "redcarpet.bat" in the bin directory of the Ruby directory.
I feel like I'm missing something basic with paths. Note that this has never worked -- I installed the RubyInstaller, then the DevKit, then the Jekyll gem...and this is what happened.
Is there something basic about this installation that I failed to set?
We ran into the RedCloth side of this error today.
We started with this error
How to install RedCloth on Windows?
What we found was we had installed the mswin32 version of RedCloth, we first got the no such file to load.
We then went to our
C:\ruby200/lib/ruby/gems/1.9.1/gems/RedCloth-mswin32
Directory , added the 2.0 file and copied the redcloth_scan.so file into the 2.0 directory.
We started getting another error that was similar.
We decided we would just uninstall the precompiled version of the gem, and start with the normal RedCloth-2.4.9.gem to be compiled locally with devkit.
Once this was installed, we again went to the lib dir for the gem.
CD C:/ruby200/lib/ruby/gems/1.9.1/gems/RedCloth-2.4.9/lib
We created a 2.0 directory
We then copied the file redcloth_scan.so file into the 2.0 directory and we no longer had the error. The server came up fine and we

mvn and the make package error

OK. Here's the problem and it's driving me crazy!!!
I followed the instruction online, installed hadoop and when running the text it said snappy local library can't be loaded.
It's said I have to install snappy first and then install hadoop-snappy.
I download snappy-1.0.4 from google code and do the following:
cd ../snappy-1.0.4
./configure
make
sudo make install
Then it's the problem when:
mvn package -Dsnappy.prefix=/usr/local
The post online said by default the snappy should be installed in the /usr/local.
But I got the following error and no matter what I change the path, still get erro:
The goal you specified required a project to execute but there's no POM in the directory. Please verify you invoked the maven from the correct directory.
It's the wrong directory of mvn? Or improper of snappy? And it said lack of pom that should be a .xml that in no where I can find..
Please help!
Alright, so looking at that page, you are in the wrong directory.
The directory you should be in for that step is "hadoop-snappy" which you can see has a pom.xml, you can verify by looking at the github, https://github.com/electrum/hadoop-snappy.
So after you follow these steps from the guide you showed me.
Download it(hadoop-snappy) from GitHub
Install libtool, make sure ‘libtoolize’ works
Install Maven 3 if necessary
Change your directory to hadoop-snappy and run the command you were trying before.

How do I resolve a Cucumber 'can't load such file' warning?

I'm trying to work through 'The Cucumber Book', but Cucumber is not behaving as expected.
I'm on Windows 7 (32-bit), and I'm reasonably confident I have Ruby and the necessary gems installed properly.
However, when I run cucumber I get the following message:
WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/bin/../lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6-x86-mingw32/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/builder-3.2.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.1/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib
This continues for a bit, listing more paths that were checked, and then a 'Reverting to Ruby lexer', and a message 'No lexer was found for en (cannot load such file --gherkin/lexer/en)...'
Based on the path it is checking it seems like it wants a '2.0' folder in the 'gherkin-2.11.6-x86-mingw32/lib' folder, which obviously doesn't exist. There are, however, '1.8' and '1.9' folders which appear to have the 'gherkin_lexer_en' file (actually 'gherkin_lexer_en.so').
As a wild guess, I duplicated the 1.9 folder and named it 2.0. I didn't really expect that would work, but figured it was worth a shot.
How do I get cucumber to look in one of the folders I have, or alternatively get a 2.0 folder in place that it will accept?
$ gem install gherkin --platform ruby
go to below folder inside your ruby installation directory
{rubyDir}\lib\ruby\gems\2.0.0\gems\gherkin-2.12.2\lib\gherkin
may be different path for you guys
Modify *lib/gherkin/c_lexer.rb:7
change the value of prefix as below:
prefix = ''
Found answer at below link
https://github.com/cucumber/gherkin/issues/273
with reply
mscharley commented on Jan 18, 2014
worked for me like charm..
On Windows, you will have to use Ruby 1.9 for the time being. There isn't a Ruby 2.0 build of gherkin published yet.
If you are using gherkin ver 2.12.1, you should be able to use cucumber with ruby 2.0 on Windows now.
 
First, install gherkin-2.12.1 with --ignore-dependencies option.
The reson --ignore-dependencies option is required is that without specifying it, it will install json 1.4.X which is very old version and fail to install on ruby 2.0.
 
At this point, you should be able to ruby cucumber on ruby 2.0, but you'll see the error message like above as warning message. This means you can still use cucumber although you are seeing the message.
 
If you want to remove the error, follow the step below.
 
create [2.0] folder on [ruby installed dir]\lib\ruby\gems\2.0.0\gems\gherkin-2.12.1\lib (This folder includes gherkin_lexer_XX.so).
copy all the contents in [ruby installed dir]\lib\ruby\gems\2.0.0\gems\gherkin-2.12.1\lib to the created [2.0] folder (you don't need to copy [2.0] folder you created).

Resources