Gem Problems with running Warbler under Maven - ruby-on-rails-3.1

I am seeing something odd with our build management server (we are using Jenkins CI). Projects are built using Maven (version 3.0.3)
Other environment details:
Rails 3.1.3
Jruby 1.6.7
Ruby 1.9.2
Bundler 1.0.22 for rails gem management
warbler 1.3.5
We have a bash script which runs a bundle install, assets:precompile (rake task) and the rake war task:
jruby -S bundle install
jruby -S bundle exec rake assets:precompile
jruby -S bundle exec rake war RAILS_ENV=production
The pom.xml file for the project has a task called package which basically runs the above bash script, among some other post-build cleanup stuff.
My question:
If I run mvn package I get the following error:
[INFO] ..... Previous output of maven stuff .....
[INFO] + jruby -S bundle exec rake war RAILS_ENV=production
[INFO] Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
[INFO] materialize at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/spec_set.rb:88
[INFO] map! at org/jruby/RubyArray.java:2371
[INFO] materialize at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/spec_set.rb:82
[INFO] specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:107
[INFO] specs_for at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:152
[INFO] requested_specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:141
[INFO] requested_specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/environment.rb:23
[INFO] setup at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:11
[INFO] setup at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler.rb:110
[INFO] (root) at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/setup.rb:17
However if I simply run, in the command line in the project folder:
jruby -S bundle exec rake war RAILS_ENV=production
(which is essentially the command it seems to be barfing on) - everything succeeds, and it builds the WAR no problems, finds all the gem files, etc.
I am wondering if anyone would have any suggestions as to what the problem might be. I have done a jruby -S gem install rake -v '0.9.2.2' and also, just in case, a gem install rake -v '0.9.2.2' - however it has made no difference.
Any advice is appreciated :) Thanks!

Related

jekyll-multiple-languages-plugin cannot be found

I'm newbie to Ruby and Jekyll. Recently I've tried to install Jekyll Multiple Languages Plugin onto my GitLab Pages instance. I've managed to successfully add
'gem install jekyll-multiple-languages-plugin
bundle install'
into the .gitlab-ci.yml but when I try to add
gems:
jekyll-multiple-languages-plugin
into _config.yml in order to use it on the site my commit fails with the following error:
Using jekyll-watch 1.5.0
Using jekyll 3.4.3
Bundle complete! 3 Gemfile dependencies, 20 gems now installed.
Bundled gems are installed into /usr/local/bundle.
$ jekyll build -d public
Configuration file: /builds/myusername/forty-jekyll-theme/_config.yml
Dependency Error: Yikes! It looks like you don't have jekyll-multiple-languages-plugin 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-multiple-languages-plugin' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.4.3 | Error: jekyll-multiple-languages-plugin
ERROR: Job failed: exit code 1
I have used this method because any attempt to edit Gemfile ends up in commit error. I've also tried to do all presented steps except adding bundle install. In that case I get the same error, but the beginning looks like:
18 gems installed
$ gem install jekyll-multiple-languages-plugin
Successfully installed jekyll-multiple-languages-plugin-1.5.1
1 gem installed
$ jekyll build -d public
I did not manage to find the way to solve it on Stack Overflow nor other sites. For example this did not help
With the awesome support of allejo from Jekyll's IRC channel I've managed to solve the problem. Here are the steps:
I've used Gemfile. Now it looks like
source 'https://rubygems.org'
gem 'jekyll'
group :jekyll_plugins do
gem 'jekyll-multiple-languages-plugin'
end
The second modified thing was .gitlab-ci.yml (the first line - image: ruby - is also included)
image: ruby
pages:
stage: build
script:
# - gem install jekyll
- gem install bundler
# - gem install jekyll-multiple-languages-plugin
- bundle install
- bundle exec jekyll build -d public
# - jekyll build -d public
artifacts:
paths:
- public
only:
- master
It produced a bug, but it was only caused by the lack of declared language which is part of standard plugin configuration.

Locally install a gem built with platform=java | JRuby 1.7.18

It seems that the workflow that I use to build and install gems locally does not translate when the gemspec has platform = "java".
I am using Jruby 1.7.18, installed with rvm
$ which gem
/Users/USERNAME/.rvm/rubies/jruby-1.7.18/bin/gem
When I build a gem with the default platform, everything goes according to plan:
$ grep platform batching_core.gemspec
# spec.platform = "java"
$ gem build batching_core.gemspec
Successfully built RubyGem
Name: batching_core
Version: 0.1.0
File: batching_core-0.1.0.gem
$ gem install batching_core-0.1.0.gem
jar dependencies found on non-java platform gem - do not install jars
Successfully installed batching_core-0.1.0
1 gem installed
Note the success message of "Successfully installed batching_core-0.1.0"
But when my project requires me to use platform=java so that I can require some jar files. I can build the gem, but I cannot install it. The installation ends without the success message, and I cannot require the gem in irb:
$ grep platform batching_core.gemspec
spec.platform = "java"
$ gem build batching_core.gemspec
Successfully built RubyGem
Name: batching_core
Version: 0.1.0
File: batching_core-0.1.0-java.gem
$ gem install batching_core-0.1.0-java.gem
$
^^ Note the lack of output. No success message, no output at all.
$ irb
jruby-1.7.18 :001 > require 'batching_core'
LoadError: no such file to load -- batching_core
from org/jruby/RubyKernel.java:1071:in `require'
from /Users/USERNAME/.rvm/rubies/jruby-1.7.18/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55:in `require'
I tried the solution suggested here, but got the same result.
Creating a gem using Jruby and not Ruby
EDIT: Here's the project that causes the issue:
https://github.com/ValerieAnne563/so34754484
It looks to me like the gem does not contain the file you're trying to require. Can you check the contents to see if "batching_core.rb" is in the gem's lib dir?
As for the warning...I'm confused about your environment. This is a gem with a jar in it being installed on JRuby? Maybe it would clarify some things if you link to the project or post the gemspec.

jenkins can't locate rake installation even though path is given explicitly

EDIT: After correcting my job configuration, I now receive the following error when running this job:
[workspace] $ /usr/local/bin/bin/rake kickoff
/usr/bin/env: ruby: No such file or directory
Build step 'Invoke Rake' marked build as failure
Finished: FAILURE
I am trying to set up a Jenkins server to run cucumber tests via a rake task.
I have the rake plugin installed, ruby 2.0.0 installed, and all necessary gems installed. I also have Rubygems installed.
Rake is installed here:
/usr/local/bin/rake
Ruby is installed here:
/usr/local/bin/ruby
Here is a screenshot of the Rake configuration for Jenkins:
Here is a screenshot of the Ruby configuration for Jenkins:
Despite what that warning says, Rubygems is installed to:
/usr/local/bin/gem
When I try to run a simple test (that just evaluates to true always), I get the following error:
Building in workspace /webdata/jenkins/jobs/kickoff_build/workspace
Updating https://svnprod.x.net/svn/x/trunk/inside_automation at revision '2015-07-10T09:50:36.495 -0400'
At revision 9227
no change for https://svnprod.x.net/svn/x/trunk/inside_automation since the previous build
FATAL: /usr/bin/rake doesn't exist
Build step 'Invoke Rake' marked build as failure
Finished: FAILURE
Why is it looking for rake in /usr/bin ???? I pointed this job directly to the directory of the rake file, /usr/local/bin/rake?
I was able to correct this issue, and several others, by creating a symlink to the rake executable.

JRuby project structure and jar creation

I have to create a JRuby jar file for my project. Below I provided details about my directory structure and files.
Top level directory - Project1
Under Project1 – I have bin, lib, src folders
Under Project1/bin – I have wrapper shell script from where I am calling jruby jar.
Under Project1/lib – I have jruby-complete-1.6.7.2.jar and ojdbc6.jar
Under Project1/src – I have lib and tool folders
Under Project1/src/lib – I have main.rb file and utilfolder
Under Project1/src/lib/util - I have 2-ruby scripts which are getting called in main.rb.
Under Project1/src/tool- I have Tool.java from where I call main.rb.
Now I have couple of questions -
Do I need to bundle all the gems which I used in my ruby scripts (for example: colorize, socket, net/ssh, etc)?
How do I create a JRuby jar? I saw the following posts on stackoverflow before posting my question but I got confused and kind of not able to figure out from where to start. Please provide some guidance on this.
Below are the steps which worked for me to bundle all the gems into jruby-complete.jar.
Download the jruby-complete-latest_version.jar from http://jruby.org/download.
Verify which gems are included in the downloaded jar, say java -jar jruby-complete-latest_version.jar -S gem list.
To push the gems into jruby-complete-latest_version.jar you need to check for all the required runtime dependecies for that gem. Example: for net-scp you need to download net-ssh gem before.
Download the gems under the same directory where you have jruby-complete-latest_version.jar by using the following command:
java -jar jruby-complete-latest_version.jar -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri
java -jar jruby-completelatest_version.jar -S gem install -i ./net-scp net-scp --no-rdoc --no-ri
Now add the gems inside ruby-complete-latest_version.jar by using update file (uf) option for the jar file. Example:
jar uf jruby-complete-latest_version.jar -C net-ssh .
jar uf jruby-complete-latest_version.jar -C net-scp .
Check the gem list for the jar file to make sure all the gems are added successfully
java -jar jruby-complete-latest_version.jar -S gem list
Last check to make sure gems are loading successfully, run require statements on irb.
java -jar jruby-complete-latest_version.jar -S irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/scp'
=> true
After I have the jruby-complete_latest_version.jar file under lib I used ANT to build the jar for my project.
Again this solution will work for the smaller projects. For big projects Warbler will the best choice as suggested by #joelparkerhenderson.

Jenkins + Ruby with RVM. Unexpected tCONSTANT error

We are downloading the latest Cordova documentation and want to generate it with Jenkins.
We are using RVM to manage the Ruby instances.
Here is the relevant shell execution in the Jenkins job.
#!/bin/bash
source "$HOME/.rvm/scripts/rvm"
echo "====== Setting up ruby ========================================"
rvm use "1.7.8"
set -e
echo "====== Installing cordova docs dependencies ==================="
gem install bundler
gem install nokogiri
cd "${WORKSPACE}/submodule_apache_cordova_docs"
bundle install
cd -
echo "====== Generating documents ==================================="
rvm current
ruby -v
${WORKSPACE}/submodule_apache_cordova_docs/bin/generate
and this is the output for that section
[workspace] $ /bin/bash /tmp/hudson1421417307959072745.sh
====== Setting up ruby =====================================
Using /var/lib/jenkins/.rvm/gems/jruby-1.7.8
====== Installing cordova docs dependencies ================
Successfully installed bundler-1.7.2
1 gem installed
Successfully installed nokogiri-1.6.3.1-java
1 gem installed
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using json 1.8.1
Using nokogiri 1.5.9
Using rspec 1.3.0
Using bundler 1.7.2
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
/var/lib/jenkins/jobs/Build-Documentation/workspace
====== Generating documents ================================
jruby-1.7.8
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on OpenJDK 64-Bit Server VM 1.7.0_65-b32 [linux-amd64]
SyntaxError: /var/lib/jenkins/jobs/Build-Documentation/workspace/submodule_apache_cordova_docs/bin/../lib/cordova/jodoc.rb:28: syntax error, unexpected tCONSTANT
#template_directories = [ File.join TEMPLATE_PATH, 'default' ]
^
require at org/jruby/RubyKernel.java:1084
require at /var/lib/jenkins/.rvm/rubies/jruby-1.7.8/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
require at /var/lib/jenkins/.rvm/rubies/jruby-1.7.8/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:53
(root) at /var/lib/jenkins/jobs/Build-Documentation/workspace/submodule_apache_cordova_docs/bin/../lib/docs_generator.rb:1
require at org/jruby/RubyKernel.java:1084
(root) at /var/lib/jenkins/jobs/Build-Documentation/workspace/submodule_apache_cordova_docs/bin/../lib/docs_generator.rb:26
(root) at /var/lib/jenkins/jobs/Build-Documentation/workspace/submodule_apache_cordova_docs/bin/generate:22
Build step 'Execute shell' marked build as failure
Finished: FAILURE
As far as I can see all the dependency versions are correct, including Ruby.
This is the file that errors: https://github.com/apache/cordova-docs/blob/master/lib/cordova/jodoc.rb
What is causing the error?
Thanks

Resources