Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jruby with -e does not work in Alpine linux container? #4044

Open
cyxou opened this issue Jul 30, 2016 · 8 comments
Open

jruby with -e does not work in Alpine linux container? #4044

cyxou opened this issue Jul 30, 2016 · 8 comments

Comments

@cyxou
Copy link

cyxou commented Jul 30, 2016

Environment

JRuby version 9.1.2.0
Having this container, described in the following Dockerfile:

FROM java:8-jre-alpine

# Install JRuby
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && apk --no-cache add bash libc6-compat jruby

ENV GEM_HOME="/usr/local/bundle"
ENV PATH="$GEM_HOME/bin:$PATH"
ENV PATH="/usr/share/jruby/bin:$PATH"
RUN echo 'gem: --no-document --no-ri' > /etc/gemrc

CMD /bin/bash

After starting container run in it's shell:

jruby -e 'puts "Aloha!"'

Expected Behavior

The shell should write "Aloha".

Actual Behavior

Shell shows empty line.

@cyxou
Copy link
Author

cyxou commented Jul 30, 2016

When installing jruby manually, everything works just fine. Consider this Dockerfile:

FROM java:8-jre-alpine

# Install JRuby
CMD /bin/bash

RUN apk add --no-cache \
    bash \
    libc6-compat

ENV JRUBY_VERSION="9.1.2.0" \
    JRUBY_SHA256="60598a465883ab4c933f805de4a7f280052bddc793b95735465619c03ca43f35"

RUN apk add --no-cache --virtual .build-deps \
    curl \
    tar \
    && mkdir -p /opt/jruby \
    && curl -fSL https://s3.amazonaws.com/jruby.org/downloads/${JRUBY_VERSION}/jruby-bin-${JRUBY_VERSION}.tar.gz -o /tmp/jruby.tar.gz \
    && echo "$JRUBY_SHA256 */tmp/jruby.tar.gz" | sha256sum -c - \
    && tar -zx --strip-components=1 -f /tmp/jruby.tar.gz -C /opt/jruby \
    && rm /tmp/jruby.tar.gz \
    && ln -s /opt/jruby/bin/jruby /usr/local/bin/ruby \
    && apk del .build-deps

ENV PATH="/opt/jruby/bin:$PATH"

RUN mkdir -p /opt/jruby/etc \
    && { \
        echo 'install: --no-document'; \
        echo 'update: --no-document'; \
    } >> /opt/jruby/etc/gemrc

RUN gem install bundler

ENV GEM_HOME="/usr/local/bundle" \
    BUNDLE_PATH="$GEM_HOME" \
    BUNDLE_BIN="$GEM_HOME/bin" \
    BUNDLE_SILENCE_ROOT_WARNING="1" \
    BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH="$BUNDLE_BIN:$PATH"
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
    && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"

CMD /bin/bash

Executing jruby -e 'puts "Aloha!"' in this container shows Aloha!.

@headius
Copy link
Member

headius commented Aug 24, 2016

I see nothing in your report that indicates why Alpine fails to build a working JRuby. I also have no idea to help :-)

@jirutka
Copy link

jirutka commented Aug 24, 2016

The problem is in launch script, not JRuby itself, it doesn’t handle arguments with spaces; see #1860 (comment). I missed that there’s this -e argument, so it’s not just a minor issue with crazy file paths containing spaces.

What is the state of mruby-based launcher, can we use it?

EDIT: I have an idea how to handle arguments with spaces even in POSIX-shell script… :)

@jirutka
Copy link

jirutka commented Aug 25, 2016

I’ve fixed Alpine’s jruby launch script to handle whitespaces in arguments passed into JRuby, i.a. -e argument. 😸

@cyxou Update to jruby-9.1.2.0-r1, it’ll be in the repository in few minutes. BTW jruby has been moved from testing into the community repository, so replace http://dl-cdn.alpinelinux.org/alpine/edge/testing with http://dl-cdn.alpinelinux.org/alpine/edge/community.

@mkristian
Copy link
Member

@jirutka which shell is Alpine using ?

@jirutka
Copy link

jirutka commented Aug 25, 2016

@mkristian Busybox’s ash (POSIX compliant shell with some common extensions)

@jirutka
Copy link

jirutka commented Aug 25, 2016

@mkristian Please read #1860 (comment) for more information, it explains why I rewrote the launch script.

@mkristian
Copy link
Member

@jirutka thanks did not see that big discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants