I can manually run bundle install and get something sane back, but when I let Puppet provision a Vagrant box, this happens the second time (the first I get successful output).
[default] Running provisioner: Vagrant::Provisioners::Puppet...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/default.pp...
stdin: is not a tty
/opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:900:in `report_activate_error': Could not find RubyGem puppet (>= 0) (Gem::LoadError)
from /opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1276:in `gem'
from /opt/vagrant_ruby/bin/puppet:18
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
I am not requesting the puppet gem anywhere, it's not in my Gemfile and my manifest does not require it either. Why is the puppet gem being looked for, and how do I get rid of this error?
I'm using https://github.com/blt04/puppet-rvm for provisioning my Vagrant box with RVM and I get the same problem. Unsetting "default_use => true" indeed fixes it. Unfortunately then you have to manually select your target Ruby once you ssh'd into the box.
Alternatively, you can add the puppet gem explicitly to the default Ruby in your manifest (not to any gemset, just to the Ruby itself). It still kept bugging me about some config file for hiera (??) missing, but it seemed to work anyway.
I'm wondering if RVM on Vagrant is even worth the hassle. The whole point about creating a Vagrant box is to have an isolated environment for a single project, so why would I need multiple Rubies/Gemsets then?
Puppet is run by you VM on your VM. Make sure the gem is still installed for users vagrant and root.
It could be a switch of your default ruby version too (system vs installed via rvm or rbenv ?).
Hope this helps.
Puppet is expected to be run by vagrant with the system ruby, but RVM may default to your chosen installed ruby. To work around this, I did this (a pretty ugly hack) while still having a default ruby when logging in normally:
In your vagrant file:
# setup working dir only to exploit in below
working_dir = '/home/vagrant/puppet'
config.vm.provision :shell, :inline => "mkdir -p #{working_dir}"
config.vm.provision "puppet" do |puppet|
# [ ... Your config ... ]
# before puppet is run, vagrand `cd`s into the working directory, failing to escape it.
puppet.working_directory = "#{working_dir}; rvm use system || true"
end
Due to an escaping bug/feature in the vagrant puppet provider (https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/puppet/provisioner/puppet.rb#L154) this causes vagrant to
Start out with the rvm loaded and configured with the default
Change into the given directory
Switch to the system ruby, making the gem be found again
Run puppet like on the first run without any RVM-rubies interfering with it.
Related
I am trying to build a RhoStudio application for the iPhone-simulator on Mac OS X 10.9.1.
The build with XCode fails at
/bin/sh -c ~/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.0.1/platform/iphone/build/rhorunner.build/Release-iphonesimulator/rhorunner.build/Script-5C0442920EFBE79D0014E5C6.sh
[31mERROR: Gem rake is not installed, run `gem install rake` first. (B [m
Command /bin/sh failed with exit code 127
Within the script (Script-5C0442920EFBE79D0014E5C6.sh), there is a "source ~/.profile" call which seems to mess up the environment for rake. The error can be reproduced by opening a shell and executing the source command. If i don't source, there is no error for rake.
Also, if i try to gem install rake after the source command, there is a confirmation that it has been installed but the error still occurs.
Anybody help?
This is one of those issues where there are way too many specific factors involved to easily come up with a solution; I'm going through the ropes myself with Rhodes in 10.9. The problem is because Rhodes constantly is changing environments (it's a real mess) so your environment, which tracks the paths to your Ruby installations and Gems, will be very volatile. Here are some tips that might help you diagnose the issue:
Try running gem which rake, which shows you the absolute path of your rake gem as visible to the calling script. You can place this in one of your config files like ~/.profile or ~/.bashrc to test different contexts.
You can also use gem env to see a full printout of the gem's configuration for your environment, and just plain env shows you the system (shell) environment. Look very closely for the variables GEM_PATH AND GEM_ROOT which show you where Rubygems and your gem libs are searched for, respectively.
Keep in mind using sudo before install will affect where your gems are installed; this depends on where you installed Ruby, which ruby manager (for RVM look in ~/.rvm) and whether or not you are using Bundler for instance.
Hope that helps. Also, if you are into Bash scripting I recently posted a tip for managing the environment paths that might help: https://coderwall.com/p/f_dlyg
I'm using zeus ruby gem on a vagrant for development
the problem is that running any of the following commands
zeus start
env ZEUSSOCK=/home/vagrant/zeus.sock zeus start
env ZEUSSOCK=/tmp/zeus.sock zeus start
export ZEUSSOCK=/tmp/zeus.sock
zeus start
produces the following error
Starting Zeus server
Unable to accept socket connection.
It looks like Zeus is already running. If not, remove .zeus.sock and try again.
there is no .zeus.sock file created in the project root directory or in any of the specified directories
how can i fix this problem without using NFS vagrant configuration
reference to wiki
running on
Mac osx 10.9
Vagrant 1.3.5
zeus (0.13.3)
the solution I found was to update the zeus gem any version grater than 0.13.4.pre2
any of the upper commands works fine with me on version 0.14.0.rc1 and also on 0.13.4.pre2
version 0.13.4.pre2 works best with RAILS_ENV, as of version 0.14.0.rc1 they suppressed executing test with RAILS_ENV enabled
On my system (OS X), I have an application running on Rails 3.1.0, ruby 1.8.7.
I installed Vagrant and set it up with Ubuntu virtual. I created a new project ABC from within the virtual machine and installed ruby 1.9.3 and Rails 3.2.6, on the virtual machine.
Now, when I exit Vagrant virtual machine and want to ssh into it again, from the ABC project directory, it struggles with a conflict in the ABC project's Gemfile:
~/.rvm/gems/ruby-1.8.7-p358#global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90:in 'materialize': Could not find actionmailer-3.2.6 in any of the sources (Bundler::GemNotFound)
When I remove the Gemfile from ABC project's directory, I can use Vagrant without any issue.
Why is Vagrant checking out project's Gemfile, instead of just running the virtual machine?
Anyone experienced something like this before?
Vagrant uses Gemfile for plugins.
See the documentation for plugins https://docs.vagrantup.com/v2/plugins/packaging.html.
So vagrant thinks that your rails gems are plugins for vagrant and fails.
My current setup uses Vagrantfile detached from rails directory.
I ended up with this settings after I started using Puppet provision scripts, various bash scripts, project documentation folder outside of rails etc.
It makes more sense to keep rails app as clean as possible and not poisoning it with local development tools files (Vagrantfile).
The question is still valid though. I'm not sure whether this qualifies for an Issue report on github...
I have used the same script to setup ruby and gems via rvm for two users on the same machine. I have confirmed with rvm --version that I'm using the same version and things seem to be installing identically.
However, on one my $GEM_PATH is being set properly, on the other both $GEM_PATH and $GEM_HOME are both blank - I have confirmed this both by echo $GEM_PATH and within a ruby script reading ENV['GEM_PATH']
Is RVM meant to set $GEM_PATH? If so, any ideas why it hasn't for me?
Are you sure both machines are running the same set of ruby and gems?
If the first is running version a of ruby and version b of gems and the second one is running the system versions (very likely on OS X) then the second machine may have different gem paths.
Make sure to do
rvm use _version_you_want_
in both machines!
When I run cap deploy:update I get the error below, indicating that bundle is not found. When I run echo $PATH from cap shell the /var/lib/gems/1.9.1/bin path which contains bundle is missing, however, this path is in both /etc/profile and ~/.bashrc. Anyone know how to solve this problem?
[192.168.10.100] executing command
*** [err :: 192.168.10.100] sh:
*** [err :: 192.168.10.100] bundle: not found
*** [err :: 192.168.10.100]
command finished in 25ms
failed: "sh -c 'bundle install --gemfile /data/www/apps/my_app/releases/201104
04163717/Gemfile --path /data/www/apps/my_apps/shared/bundle --deployment --qui
et --without development test'" on 192.168.10.100
To avoide such problem you should have most recent versions of RVM (currently it is 1.13.5) installed in both places: locally and on remote server.
Next, check if your deploy.rb has
require "rvm/capistrano"
require "bundler/capistrano"
This line is not needed anymore:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
Hope this will help
Ok, I've recently had some experience with this. Looks like there are a couple of ways that this problem can be solved. First, you can determine if in fact the remote execution (via Capistrano) is what's messed up vs. the host itself. Looks like you've done this with the Capistrano remote shell:
$ cap shell
> echo $PATH
Good. I'll bet when you login to the machine and 'echo $PATH' there, the right stuff comes out... same here.
I've found two ways to fix this: One is to enable the environment execution in the remote host's ssh daemon. In theory this would work, but I didn't want to ask the sysadmin if it was ok to open this up. You basically edit the ssh configuration files to set the 'PermitUserEnvironment' to 'yes' and add the required environment settings to the deploy user's ~/.ssh/environment file -- your system-specific man pages are probably better than my trying to generalize.
I opted for what seems rather hackish, and has the drawback that it is global for all hosts you deploy the app to (so if your ruby / gems locations are different on different hosts, this won't work) -- but: I added the default_environment settings to the config/deploy.rb script:
set :default_environment, {
'PATH' => "/usr/local/bin:/bin:/usr/bin:/bin:/<ruby-dir>/bin",
'GEM_HOME' => '<ruby-dir>/lib/ruby/gems/1.8',
'GEM_PATH' => '<ruby-dir>lib/ruby/gems/1.8',
'BUNDLE_PATH' => '<ruby-dir>/lib/ruby/gems/1.8/gems'
}
AMMENDED: It isn't so 'hackish' if you consider the following:
- The environment-specific deploy scripts (deploy/foo.rb) can
override the default in deploy.rb
- PermitUserEnvironment hides the configuration deep in the
.ssh directory of the deploy user; :default_environment at
least exposes it in the checked-in sources.
This also solves the problem of not being able to do remote rake tasks, etc., via Capistrano. Be aware that the Capistrano gem, at least the version I have and with my deploy set up in the "standard" way, will install the gems into the /shared/bundle
directory, which gets picked up by the app. The method I described requires a minimal subset of gems in the system directories referenced by the default environment so that the remote Capistrano commands can execute bundle, rake, etc.
You didn't say if you were using RVM (my solution doesn't); however, this solution is very close to one of the recommended RVM solutions. Alternately, you could just use the 'rvm/capistrano' solution; look for RVM Capistrano integration on the RVM website for more details.
Have you manually installed the bundler gem on the remote box? You can't use the bundle command or install any bundles until you do.
Are you using RVM ?
DaneS some possible solutions:
place
require "bundler/capistrano"
in your script as bundler now has support for capistrano
https://github.com/carlhuda/bundler/blob/1-0-stable/lib/bundler/capistrano.rb
And maybe
before "deploy:cold",
"deploy:install_bundler"
task :install_bundler, :roles => :app do
run "type -P bundle &>/dev/null || { gem install bundler --no-rdoc --no-ri; }"
end
The install_bundler task will only be installed if not found.