Thursday, 21 July 2016

Weird JRuby Interpreter Issue(s) in CircleCI Containers.

I'm trying to activate JRuby in a containerized CI environment, the machines are running Ubuntu: Linux-3.13.0-91-generic-x86_64-with-Ubuntu-12.04-precise, specifically I have a script which is creating WAR files:

#!/bin/bash --login

if [ "$1" == "" ]; then
BUILD_ENV="production"
else
BUILD_ENV="$1"
fi

echo "Building for: $BUILD_ENV"


rvm install jruby-9.1.2.0
rvm use jruby-9.1.2.0


rvm get head
function nightly_ci() {
    if [[ "$(python -mplatform)" =~ .*Ubuntu*. ]]; then
            export PATH="$PATH:$HOME/.rvm/scripts/rvm"
            chmod 755 ~/.rvm ~/.bashrc && echo rvm_autoupdate_flag=0     >> ~/.rvmrc
            printf '%s' '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
    fi
}
nightly_ci
# install and package all gems (fixes issues with :gem/:ref gemfile)
echo "bundle install --without development test profile"
bundle install --without development test profile
echo "bundle package --all"
bundle package --all

# build war file, smartroom.war
echo "RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile"
RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile --trace
echo "RAILS_ENV=$BUILD_ENV bundle exec warble war"
RAILS_ENV=$BUILD_ENV bundle exec warble war --trace

This works all well and good on localhost, and will run on the containerized environment but only after the JRuby interpreter is explicitly invoked from the command line.

For example I run my script it runs download JRuby, make sure the paths are setup correctly, bundle installs the necessary gems, then makes the WAR. However, this does not work in the containerized environment because the bundle install uses the gems in the native Ruby version and does not install the correct gems into JRuby. If I type rvm install jruby-9.1.2.0 after the script is executed it will tell me that JRuby is already installed and then if I rerun the script it works completely fine. I was thinking it was possible my bash profile was misconfigured but it does not appear to be so. Here is my bashrc on the container:

source ~/.circlerc &>/dev/null

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

# The next line updates PATH for the Google Cloud SDK.
source '/opt/google-cloud-sdk/path.bash.inc'

# The next line enables shell command completion for gcloud.
source '/opt/google-cloud-sdk/completion.bash.inc'

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

And my .profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

My JRuby version: jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.76-b04 on 1.7.0_76-b13 +jit [linux-x86_64]

Lastly I tried invoking the exact set of commands as I do via the shell programmatically, (this needs to be done because I'm trying to automate the WAR generation during a nightly-build) after the script finished and then reran the script and to no avail, I was hoping you guys might have some insight.



from Recent Questions - Stack Overflow http://ift.tt/29Ot8rL
via https://ifttt.com/ IFTTT

No comments:

Post a Comment