bundle install --standalone doesn't install bundler

133 views
Skip to first unread message

Christian Becker

unread,
Aug 10, 2016, 9:20:46 PM8/10/16
to ruby-bundler
Hi Folks,

I know this may sound weird - maybe like search for "google" using google - but I'm fighting with a problem using the standalone feature.

Background:

I'm creating a rpm for "single click" installation of a rails application. What I don't want is to build all the necessary gems on the target server - I want to deliver them within the rpm file.

So I did the "hack" using 

bundle install --standalone default --binstubs bin/

But rails requires bundler. Shure there are ways to remove bundler from rails - but this isn't easy in an grown application. So I don't have a problem with using bundler in my production setup.

But bundler won't install bundler to the standalone folder - and I couldn't figure out how to do this


Is there a way to work arround this issue?

Bests
Chris

Tim Moore

unread,
Aug 10, 2016, 11:57:09 PM8/10/16
to ruby-b...@googlegroups.com
Chris,

Rails adds a dependency on Bundler to Rails apps by default, but doesn't depend directly on Rails at runtime. It's possible to remove all of the runtime Bundler dependencies by taking out the call to Bundler.require in your application.rb and replacing it with explicit require statements. Have a look at these blog posts:


The other option you have would be to set GEM_HOME to a directory inside your app, and then install bundler using that GEM_HOME value so it gets installed there. You'll also need to set GEM_HOME to the same value at runtime of course.

Cheers,
Tim

--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler+unsubscribe@googlegroups.com.
To post to this group, send email to ruby-b...@googlegroups.com.
Visit this group at https://groups.google.com/group/ruby-bundler.
For more options, visit https://groups.google.com/d/optout.

Christian Becker

unread,
Aug 11, 2016, 3:22:38 AM8/11/16
to ruby-bundler
Hi Tim,

thank's for your answer.

I would prefere the GEM_HOME method.

So I created a folder called temptest, export GEM_HOME=$HOME/temptest and ran gem install bundler.
Bundler was installed successfull in the folder. 

But when I start unicorn

ruby -r ./bundle/bundler/setup.rb ./bin/unicorn -c /opt/my-webapp/config/unicorn.rb -E production


It can't find bundler...

E, [2016-08-11T09:18:09.622680 #2161] ERROR -- : uninitialized constant Bundler (NameError)
/opt/my-webapp/config/application.rb:7:in `<top (required)>'
/opt/rh/rh-ruby23/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `
require'
/opt/rh/rh-ruby23/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

/opt/my-webapp/config/environment.rb:2:in `<top (required)>'
/opt/rh/rh-ruby23/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `
require'
/opt/rh/rh-ruby23/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

config
.ru:4:in `block in <main>'
/opt/my-webapp/bundle/ruby/2.3.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `
instance_eval'
/opt/my-webapp/bundle/ruby/2.3.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'

config
.ru:1:in `new'
config.ru:1:in `<main>'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `eval'

/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `block in builder'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:752:in `
build_app!'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:617:in `init_worker_process'

/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:639:in `worker_loop'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:508:in `
spawn_missing_workers'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:519:in `maintain_worker_count'

/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:283:in `join'
/opt/my-webapp/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `
<top (required)>'
./bin/unicorn:12:in `load'

./bin/unicorn:12:in `<main>'



Any idea so far?

Bests
Christian

Jordi Massaguer

unread,
Aug 11, 2016, 3:31:55 AM8/11/16
to ruby-b...@googlegroups.com

Hi Christian,

We did a very similar thing but for passenger. I don't know if you are familiar with the open suse build service for building rpms. See build.opensuse.org and look for the projec


Jordi Massaguer

unread,
Aug 11, 2016, 3:34:20 AM8/11/16
to ruby-b...@googlegroups.com

El 11/8/2016 9:31, "Jordi Massaguer" <jordimas...@gmail.com> escribió:
>
> Hi Christian,
>
> We did a very similar thing but for passenger. I don't know if you are familiar with the open suse build service for building rpms. See build.opensuse.org and look for the projec
>

Sorry i hit send by accident...

Look for the project Virtualization:containers:Portus . The package is called portus.

I hope it helps

>> To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.

Tim Moore

unread,
Aug 11, 2016, 5:14:07 AM8/11/16
to ruby-b...@googlegroups.com
That's what I meant by "You'll also need to set GEM_HOME to the same value at runtime of course." If you pass the same environment variable to your Unicorn script, it should work 
--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler+unsubscribe@googlegroups.com.

Christian Becker

unread,
Aug 11, 2016, 5:36:22 AM8/11/16
to ruby-bundler
I did the test only from terminal and did start unicorn directly from bin/unicorn

Christian Becker

unread,
Aug 11, 2016, 8:51:50 AM8/11/16
to ruby-bundler
Alright, next steps.

I could found out, that bundler needs to be required - so I put "require 'bundler'" to the application.rb and bundler works fine.

But then I found it, that bundle install --standalone doesn't install all dependend gems. So I deleted the bundle folder, ran bundler again - and now another gem is missing.

The answer of Jordi looks great - I will check this for future projects.
Reply all
Reply to author
Forward
0 new messages