blt04 / puppet-rvm

A puppet module for installing and using RVM (Ruby Version Manager)
Other
242 stars 280 forks source link

rvm::passenger::apache fails for ubuntu 12.04 / ruby-2.0.0-p195 / passenger 4.0.2 #77

Open flipkick opened 11 years ago

flipkick commented 11 years ago

Using this as node config for a ubuntu 12.04 system;

rvm_system_ruby {
  'ruby-2.0.0-p195':
  ensure => 'present',
  default_use => true;
}

class {
  'rvm::passenger::apache':
    version => "4.0.2",
    ruby_version => "ruby-2.0.0-p195",
    mininstances => 3,
    maxinstancesperapp => 0,
    maxpoolsize => 30,
    spawnmethod => "smart-lv2";
}

fails with this exception on the node:

Notice: /Stage[main]/Rvm::Passenger::Apache::Ubuntu::Post/Exec[passenger-install-apache2-module]/returns:  * Checking for Zlib development headers...
Notice: /Stage[main]/Rvm::Passenger::Apache::Ubuntu::Post/Exec[passenger-install-apache2-module]/returns:       Found: yes
Notice: /Stage[main]/Rvm::Passenger::Apache::Ubuntu::Post/Exec[passenger-install-apache2-module]/returns:       Location: /usr/include/zlib.h
Notice: /Stage[main]/Rvm::Passenger::Apache::Ubuntu::Post/Exec[passenger-install-apache2-module]/returns: /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.2/lib/phusion_passenger/platform_info/ruby.rb:195:in `expand_path': non-absolute home (ArgumentError)
nlsrchtr commented 11 years ago

Same here. But logging into the machine and running the passenger install command manually fixes it.

I'm running debian 6, ruby-1.9.3-p429, passenger-3.0.21 inside vagrant.

adamcohen commented 11 years ago

I had this same issue on CentOS 6.4. Turns out it's caused by having an empty HOME environment variable. I fixed it using the following:

Exec { 
    environment => "HOME=/home/vagrant/" 
}
nlsrchtr commented 11 years ago

Running the command manually works without any problems:

/usr/local/rvm/bin/rvm ruby-1.9.3-p429 exec passenger-install-apache2-module -a

Would be great if there would be a fix without managing the environment variables.

adamcohen commented 11 years ago

I'm guessing it works when you run the command manually because you've logged in with an interactive shell that has $HOME set correctly.

I believe the issue is caused by this pull request: (#5224) Unset USER-related env vars during execs

The fix would be for phusion passenger to be careful about using File.expand_path with "~/.rvm" if the HOME environment variable hasn't been set. I don't think there's much we can do in this puppet rvm module to rectify this, other than my suggestion of setting the HOME environment variable in an Exec command as above.

evilensky commented 11 years ago

We can hack around it via su -c

  exec {
    'passenger-install-apache2-module':
      command     => "/bin/su - root -c \'${rvm::passenger::apache::binpath}rvm ${rvm::passenger::apache::ruby_version} exec passenger-install-apache2-module -a\'",
      creates     => "${rvm::passenger::apache::gempath}/passenger-${rvm::passenger::apache::version}/ext/apache2/mod_passenger.so",
      logoutput   => 'on_failure',
      require     => [Rvm_gem['passenger'], Package['httpd','httpd-devel','mod_ssl']];
  }