Closed lazywei closed 9 years ago
Which variant of the image are you using?
I'm using this one
FROM phusion/passenger-full:0.9.15
Found the same issue with 0.9.15. Looks like ruby-switch is not handling bundler
/home/app# ruby-switch --set ruby2.2
/home/app# head -1 `which bundle`
#!/usr/bin/env jruby
Workaround
RUN rm /usr/local/bin/bundle && ln -s /var/lib/gems/2.2.0/gems/bundler-1.7.12/bin/bundle /usr/local/bin/bundle
Looks like our build script is not correctly fixing up the shebang line.
Got it. @skyminer15 's workaround works for me. Thanks!
Off topic
By the way, it seems I can't use bundle install
for non-root user? Then how can I install gems for the role app
given the passenger will run my rails in that role?
Thanks.
@lazywei You should bundle install
to a path that you have write access to, for example bundle install --path=/home/app/bundle
.
@FooBarWidget Thanks. I'll try that.
I found that after bundle install
(with @skyminer15 's workaround), it will fail with
Could not find rdoc-4.2.0 in any of the sources
Run `bundle install` to install missing gems.
when trying to run bundle exec rake db:create
.
Is this also some bugs with ruby-switch
?
OK, it turns out the rake
also uses jruby, we need to
rm /usr/local/bin/rake && ln -s /var/lib/gems/2.2.0/gems/rake-10.4.2/bin/rake /usr/local/bin/rake
Probably all the shebang lines are wrong in the passenger-full image. I'll have a look at this asap.
Same issue here, but I do not use ruby-switch
(as far as I know). I am trying out an example app and am using this Dockerfile
:
# Use phusion/passenger-full as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/passenger-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/passenger-full:0.9.15
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Add the nginx info
ADD nginx.conf /etc/nginx/sites-enabled/webapp.conf
# Prepare folders
RUN mkdir /home/app/webapp
# Run Bundle in a cache efficient way
WORKDIR /tmp
ADD my-app/Gemfile /tmp/
ADD my-app/Gemfile.lock /tmp/
RUN bundle install
# Add the rails app
ADD . /home/app/webapp
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
It does build with the extra line from @skyminer15, but if I don't add the line, it complains about:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/jruby-1.7/bin/jruby extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS.
(root) at /usr/local/jruby-1.7/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1071
(root) at /usr/local/jruby-1.7/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at extconf.rb:19
This issue has been fixed now in commit 368e7ac0. You can also fix it locally by running:
sed -E -i 's|/usr/bin/env j?ruby.*$|/usr/bin/env ruby|; s|/usr/bin/j?ruby.*$|/usr/bin/env ruby|' \
/usr/local/bin/rake /usr/local/bin/bundle /usr/local/bin/bundler
Hi,
I'm using Ruby 2.2, with
ruby-switch
.However, when I try to bundle install from my Gemfile inside the docker, I got this:
What I don't understand is I didn't switch to JRuby, so why the bundle install try to use JRuby for me?
Thanks.