Open sentience opened 10 years ago
+1 seeing this as well. Here's a test running "printenv" that shows the problem with the execute environment:
Had to work around with:
execute "sudo -i -u #{user} bundle install --gemfile=#{File.join deploy_path, 'Gemfile'}"
Without the login shell (which sources rbenv init) and the user's environment there doesn't seem to be much sense to rbenv_execute.
+1
I tried fixing it by adding export HOME=#{node[app]['home']}
to the script, but then I get errors like:
Gem::Exception: Cannot load gem at [/opt/chef/embedded/lib/ruby/gems/1.9.1/cache/minitest-5.3.3.gem] in /opt/myapp
That implies that it isn't running rbenv's bundle
command, but something out of the chef embedded collection instead. Does chef set GEM_HOME
and GEM_PATH
now and rbenv isn't clearing them out?
another fix that worked for me was to assign ownership of rbenv to the user whose bash profile contains the rbenv init:
chown -R ec2-user ${RBENV_DIR}
For me works with added variable environment $HOME. Example:
bash "setup plugin" do
cwd node[:redmine][:dir]
user node[:redmine][:user]
environment 'RAILS_ENV' => 'production' , 'HOME' => node[:redmine][:home]
code <<-EOH
bundle install --without development test postgresql sqlite
rake redmine:plugins:migrate
EOH
end
I’m running into a problem with what I figure must be a pretty common use case.
First, I am using
rbenv
to install a global Ruby version:Then, I am installing the
bundler
gem into that Ruby:Where I get into trouble is when I then use
rbenv_execute
to runbundle install
in my application’s root directory, using that Ruby.(Note the use of the
--system
flag, which I added in an attempt to forcebundle install
to use the default Ruby gem path.)This
bundle install --system
command fails when it attempts to create/root/.bundler
, which it shouldn’t be creating because I’ve told it to run as mydeploy_user
(vagrant
in this case, which is in therbenv
group and therefore has write access to the gem path).If I shell into the machine as
vagrant
and runbundle install --system
by hand, the gems are installed to the correct path.Any idea why Bundler would be trying to write to that path rather than the Ruby gem path? Is there some more correct way to be running
bundle install
with my rbenv-installed Ruby?