Chruby and bundle_command


#1

Hi,

I’m using the chruby 0.2.1 cookbook to install Ruby on a server.

I’m going to run a Rails application there, but bundle install fails to compile the pg gem. Since I can compile the gem just fine in the shell, my guess is that bundle is running with the system Ruby.

I tried to use the bundle_command attribute like such:

application “rails_app” do

rails do
bundler true
bundle_command ". /etc/profile.d/chruby.sh && bundle install --binstubs"
end
end

but that fails:

---- Begin output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
STDOUT:
STDERR: sh: 1: /etc/profile.d/chruby.sh: source: not found
sh: 2: /etc/profile.d/chruby.sh: source: not found
sh: 3: /etc/profile.d/chruby.sh: Syntax error: word unexpected (expecting “)”)
---- End output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
Ran . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging returned 2

I’ve also tried to source /usr/local/chruby/share/chruby/chruby.sh directly, but that also fails with similar errors.

What’s the best approach to correcting this problem?

Thanks!

  • cassiano

#2

On Wednesday, July 10, 2013 at 6:32 AM, Cassiano Leal wrote:

Hi,

I’m using the chruby 0.2.1 cookbook to install Ruby on a server.

I’m going to run a Rails application there, but bundle install fails to compile the pg gem. Since I can compile the gem just fine in the shell, my guess is that bundle is running with the system Ruby.

I tried to use the bundle_command attribute like such:

application “rails_app” do

rails do
bundler true
bundle_command ". /etc/profile.d/chruby.sh && bundle install --binstubs"
end
end

but that fails:

---- Begin output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
STDOUT:
STDERR: sh: 1: /etc/profile.d/chruby.sh: source: not found
sh: 2: /etc/profile.d/chruby.sh: source: not found
sh: 3: /etc/profile.d/chruby.sh: Syntax error: word unexpected (expecting “)”)
---- End output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
Ran . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging returned 2

I’ve also tried to source /usr/local/chruby/share/chruby/chruby.sh (http://chruby.sh) directly, but that also fails with similar errors.

What’s the best approach to correcting this problem?

Thanks!

  • cassiano

Ugly hack that should work is to wrap your bundle command in bash -c. According to the README chruby supports bash or zsh, I’m guessing the basic bourne shell (/bin/sh) doesn’t work.

I’m not familiar with the application cookbook, so I don’t know what’s involved in making it support running bundle_command in bash.


Daniel DeLeo


#3

Hi,

Thanks for your answer. That’s on an Ubuntu machine where the default shell is dash.

I went ahead and changed the /bin/sh symlink to point to bash and it works now.

Thanks,
Cassiano Leal

On Friday, July 12, 2013 at 12:20, Daniel DeLeo wrote:

On Wednesday, July 10, 2013 at 6:32 AM, Cassiano Leal wrote:

Hi,

I’m using the chruby 0.2.1 cookbook to install Ruby on a server.

I’m going to run a Rails application there, but bundle install fails to compile the pg gem. Since I can compile the gem just fine in the shell, my guess is that bundle is running with the system Ruby.

I tried to use the bundle_command attribute like such:

application “rails_app” do

rails do
bundler true
bundle_command ". /etc/profile.d/chruby.sh && bundle install --binstubs"
end
end

but that fails:

---- Begin output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
STDOUT:
STDERR: sh: 1: /etc/profile.d/chruby.sh: source: not found
sh: 2: /etc/profile.d/chruby.sh: source: not found
sh: 3: /etc/profile.d/chruby.sh: Syntax error: word unexpected (expecting “)”)
---- End output of . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging ----
Ran . /etc/profile.d/chruby.sh && bundle install --binstubs install --path=vendor/bundle --deployment --without development test cucumber staging returned 2

I’ve also tried to source /usr/local/chruby/share/chruby/chruby.sh (http://chruby.sh) directly, but that also fails with similar errors.

What’s the best approach to correcting this problem?

Thanks!

  • cassiano

Ugly hack that should work is to wrap your bundle command in bash -c. According to the README chruby supports bash or zsh, I’m guessing the basic bourne shell (/bin/sh) doesn’t work.

I’m not familiar with the application cookbook, so I don’t know what’s involved in making it support running bundle_command in bash.


Daniel DeLeo