Warbler does not package Java/JRuby gems? - jruby

I have a Ruby on Rails app that I want to compile/package as a WAR file to host in Tomcat. I've added all of the relevant stuff I can find, but the WAR only appears to include the non-JRuby versions of gems. As a result, I get GemNotFound exceptions such as "could not find activerecord-jdbc-adapter" in Tomcat. If I open the WAR file in 7-zip, it does not show any of the JRuby or Java gems under /WEB-INF/gems/gems.
Warbler does not report any errors or warnings, and the WAR appears to contain everything it needs, except for these gems.
(Because this is a lightweight, internal app, I'm using sqlite for now... which explains the sqlite gems. The DB is stored outside the project and configured in the database.yml file.)
The relevant snippet from my Gemfile:
if defined?(JRUBY_VERSION)
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
else
gem 'sqlite3'
end
I also tried explicitly including/excluding these gems in the warble.rb file:
config.gems -= ["sqlite3"]
config.gems += [
"jdbc-sqlite3",
"activerecord-jdbc-adapter",
"activerecord-jdbcsqlite3-adapter",
"jruby-openssl",
"jruby-rack",
"warbler"
]
As an interesting side note, if I modify my Gemfile to demand the JRuby gems, jruby -S bundle install works fine but warble gives a series of errors stating that the gems are only for use with JRuby. On the other hand, if I try to run it within JRuby (jruby -S warble) I get:
warble aborted!
no such file to load -- jruby_pageant
How can I convince Warbler that I want the JRuby gems?
Edit:
I also tried specifying platforms in the gemfile, as described in this blog post, but this causes warble to stack-overflow.
platforms :jruby do
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter', :require => false
gem 'activerecord-jdbcsqlite3-adapter', :require => false
gem 'jruby-openssl'
gem 'jruby-rack'
end
platforms :ruby do
gem 'sqlite3'
end
Versions:
ruby 1.9.3
jruby 1.7.4
warbler 1.3.8

So it turns out that I was missing the jruby-pageant gem. Once I added this to the bundle, jruby -S warble produced the expected output.

Related

jekyll error building page related to kramdown parser

Whenever I run the bundle exec jekyll serve it returns the error
Dependency Error: Yikes! It looks like you don't have kramdown-parser-gfm 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 -- kramdown-parser-gfm' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
Liquid Exception: kramdown-parser-gfm in /_layouts/default.html
ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
kramdown-parser-gfm
so, I tried gem install kramdown-parser-gfm, but it returns the same error after that.
I also tried to remove and reinstall the jekyll and bundle, but didn't work either.
jekyll version 3.9.0 Bundler version 2.1.4
I added gem "kramdown-parser-gfm" to the Gemfile and then ran bundle install.
Now the serve command completes successfully.
delete the Gemfile.lock file
go to gem file add gem "kramdown-parser-gfm"
open terminal and give command bundler
after install all packages, in terminal give command bundle exec jekyll serve
I hope application will run properly now.
On Windows
If you open your gemfile, you will notice the following.
gem "jekyll", "~> 3.2.1"
If you have the specific jekyll version and after running "bundler", you will receive the following errors.
Bundler could not find compatible versions for gem "kramdown":
In Gemfile:
jekyll (~> 3.2.1) was resolved to 3.2.1, which depends on
kramdown (~> 1.3)
kramdown-parser-gfm was resolved to 1.1.0, which depends on
kramdown (~> 2.0)
Remove the specific version of jekyll, like so:
gem "jekyll"
Do not forget to add webrick gem to gemfile
gem "webrick"
Run bundler again.
bundler
Finally, serve
bundle exec jekyll serve --livereload
What worked for me was to add:
gem "rexml"
to the Gemfile.

Deploying jekyll app on Cloudcannon fails

I am trying to deploy my jekyll app on the Cloudcannon CMS platform for Jekyll, but my build fails with this output:
Syncing raw files... done
Checking existing local bundle state... failed
Loading gem cache...
Checking gem cache (bundle_cache/Jw8rkIm9v3Cmawv2raEpkN96fz3R5X1Q_XMn7xpGB1s.zip)... no cache
$ export JEKYLL_ENV="production"
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]
$ bundle version
Bundler version 2.0.1 (2019-01-04 commit d7ad2192f)
$ bundle config --global jobs 4
Configured concurrent installs!
$ bundle install
Using local cacheable path...
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
jekyll-feed-0.12.0 requires ruby version >= 2.4.0, which is incompatible with
the current version, ruby 2.3.8p459
What am I doing wrong and how can I update the ruby version correctly?
My Gemfile looks like this:
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.8.5"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 2.4.0"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?
I tried to change the jekyll-feed version and bundle it again but it gave me the same results and I don't want to remove that plugin because I need it.
The issue could be from your Gemfile.lock.
The latest version of jekyll-feed is 0.12.1
Correct your Gemfile to point to any version of jekyll-feed greater than or equal to 0.12.0:
gem "jekyll-feed", "~> 0.12"
The run bundle update so that the new version is installed and included in your Gemfile.lock
Then commit and push your updated Gemfile and the Gemfile.lock into your remote repository.
Jordan from CloudCannon here.
ashmaroli is correct, you're referencing an invalid version number for jekyll-feed. Following ashmaroli's steps should resolve the problem.
As a side note, we'll be adding support for multiple Ruby versions within the next month or two. This will resolve any future incompatibilities with plugins that require a later version of Ruby.
If you have any more questions feel free to contact us, we're more than happy to help :)

Rails Setup: mysql2 gem always causing problems

I'm fairly new when it comes to commandline or Rails, but work on a rails project where I'm doing the frontend.
I've installed all gems that are needed for the project, but lately some errors occur when doing a rake:db migrate or today when trying to deploy the current version via cap production deploy
The problem I'm facing seems to have todo with the mysql2 gem. At least that is what the console says.
When running cap production deploy I get this error:
rake stdout: Nothing written
rake stderr: rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.
and further down this …
Gem::LoadError: can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile.
What do I have todo here? When I do gem list I see that mysql2 is installed.
Thank you,
Matt
Rails used to have the mysql2 gem locked down to ~>0.3 in the codebase.
So that is what it looks for but your Gemfile will simply state
gem "mysql2"
Pretty sure they've updated this in the latest release of rails 4 so either:
Update to the latest version of rails 4 or use a specific version of the mysql2 gem
gem "mysql2", "~> 0.3.20"

bundler not recognizing platform? Could not find gem

I'm using jruby 1.7.2 and setting up a new rails app. Bundler appears unable to find the necessary (java/jruby based gems) to use:
> bundle
Could not find gem 'neo4j-core (>= 0) ruby' in the gems available on this machine.
If I specify the path, I get this:
> bundle
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Could not find gem 'neo4j-core (>= 0) ruby' in source at ./vendor/gems/neo4j-core.
Source contains 'neo4j-core' at: 2.0.1
Perhaps bundler is getting confused about its platoform -- why would it be tacking the word ruby on the end there? I ran ruby -e "puts RUBY_PLATFORM", which gave me: java
Solved by deleting Gemfile.lock: https://github.com/carlhuda/bundler/issues/2043

jRuby and Problems with Warbler, RVM, and Tomcat

I've been having a tough time getting jRuby on Rails 3 deployed on Tomcat 6. I got it to work exactly once.
I modified my database.yaml and Gemfile to check for jRuby, something like this:
if defined?(JRUBY_VERSION)
gem 'jdbc-mysql'
#gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
#gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'
else
gem 'mysql'
gem "mongrel"
gem 'ruby-debug'
end
Some environment settings:
$ rvm -v
rvm 1.0.14
$ jruby -v
jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]
When I run jruby -S bundle install everything goes smoothly.
It's when I try to do something like rake db:migrate, jruby -S rake db:migrate or warble that I get 50 DEPRECATION WARNINGs and an eventual stackoverflow.
I solved this issue by deleting the warbler plugin, it did not like the line Warbler::Task.new
Next, I ran warble config to give me a config/warbler.rb file.
And finally, warble to create my .war file. So far so good.
Now I move the .war file to my Tomcat webapps. Everything works fine except for an error:
Oct 10, 2010 1:34:46 AM org.apache.catalina.core.ApplicationContext log
SEVERE: Application Error
org.jruby.rack.RackInitializationException:
http://github.com/plataformatec/devise.git (at master) is not checked out.
Please run 'bundle install'
I solved this problem once and only once by going into my webapps/myapp/WEB-INF and running jruby -S bundle install
It no longer works and I have no idea what is going on.
I believe this can be called a bug in the current version of Warbler. Using git repositories in your Gemfile don't quite get staged properly in the war file and Bundler is still looking for a checked out repository on disk.
A future version of Warbler will probably do something along the lines of bundle --deployment when you create the war file.
For now, to work around, you might have to vendor the devise code.
The current version of warbler (1.3.6) will also exhibit this behavior if you build a war file with warbler war. I've found that building with the following command works:
warbler compiled war
Hopefully future versions will address this more completely.