Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[disable shared compilation on OSX] rvm ruby 1.8.7 installed passenger loads wrong ruby with apache start OSX 10.7 and 10.8 #1439

Closed
GolgothaX opened this Issue · 23 comments

2 participants

@GolgothaX

This was reproduced on OSX 10.7 and 10.8. Both fresh installs.

This seems to be specific to Ruby 1.8.7. Ruby 1.9.3 and passenger work correctly. Ruby 1.8.7 will work on OSX 10.6 with the same steps ignoring needing make/gcc.

Steps taken:
Install command line tools for xcode (to get make)

curl -L https://get.rvm.io | bash -s stable
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl
rvm install ruby-1.8.7-p357 --without-tk --without-tcl --verify-downloads 1
rvm use ruby-1.8.7-p357@global --default
gem update --system 1.3.7
gem install passenger
passenger-install-apache2-module

Add output to /etc/apache2/httpd.conf

LoadModule passenger_module /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19
PassengerRuby /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby
sudo apachectl -k stop
sudo apachectl -k start

When apache is restarting, it outputs the following and hangs while trying to build for universal-darwin(system ruby!!!).

admins-MacBook-Pro-3:~ admin$ checking for alloca.h... no
checking for ruby/io.h... no
creating Makefile
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/ruby -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -g  -c /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/ruby/passenger_native_support.c
Error: /usr/bin/xcode-select returned unexpected error.
checking for alloca.h... no
checking for ruby/io.h... no
creating Makefile
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/ruby -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -g  -c /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/ruby/passenger_native_support.c
Error: /usr/bin/xcode-select returned unexpected error.

From terminal, console and other ruby tasks work correctly. The $LOAD_PATH is correct

admins-MacBook-Pro-3:~ admin$ /Users/admin/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
puts $LOAD_PATH.inspect
["/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/site_ruby/1.8", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/site_ruby/1.8/i686-darwin11.4.2", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/site_ruby", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/vendor_ruby/1.8", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/vendor_ruby/1.8/i686-darwin11.4.2", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/vendor_ruby", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8", "/Users/admin/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8/i686-darwin11.4.2", "."]

The $LOAD_PATH is incorrect when apache envvars is loaded and then the ruby rvm. It's my understanding that apache loads /usr/sbin/envvars so the below is a valid test. However I can also make the pasenger_spawn output $LOAD_PATH and its the same result.

admins-MacBook-Pro-3:~ admin$ . /usr/sbin/envvars
admins-MacBook-Pro-3:~ admin$ /Users/admin/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
puts $LOAD_PATH.inspect
["/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/powerpc-darwin11.0", "/Library/Ruby/Site/1.8/universal-darwin11.0", "/Library/Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin11.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc-darwin11.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0", "."]
@GolgothaX

gem environment https://gist.github.com/5e3b167236bc8f132cf6
rvm info https://gist.github.com/4514515

I've tried setting the environment SetEnv apache directive.

@mpapis
Owner

could you repeat your steps with the only exception of replacing the step:

gem update --system 1.3.7

with

rvm rubygems 1.3.7

Also have you tried playing with /usr/bin/xcode-select command - it might need some extra configuration for passenger.

@GolgothaX

No difference with.
rvm rubygems 1.3.7

xcode-select seems to be for switching between versions of xcode and I only have the command line tools installed standalone - the only version I have available.

I also tried adding to /usr/sbin/envvars without any change.

[[ -s "/Users/Admin/.rvm/scripts/rvm" ]] && source "/Users/Admin/.rvm/scripts/rvm"

I tried a multi user rvm install and added _www (the apache user) to the group. And then tried changing the apache user to Admin (myself).

@mpapis
Owner

what do you see when you run /usr/bin/xcode-select? the error you get points out that it might be not configured properly.

Also your last test was wrong, it should be:

. /usr/sbin/envvars
/Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -e 'puts $LOAD_PATH.inspect'
@GolgothaX

I had just let it evaluate and ctrl+d to see the output in that test but here is using -e.

admins-MacBook-Pro-3:~ admin$ . /usr/sbin/envvars
admins-MacBook-Pro-3:~ admin$ /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -e 'puts $LOAD_PATH.inspect'
["/Library/Ruby/Site/1.8", "/Library/Ruby/Site/1.8/powerpc-darwin11.0", "/Library/Ruby/Site/1.8/universal-darwin11.0", "/Library/Ruby/Site", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin11.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/vendor_ruby", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc-darwin11.0", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0", "."]

The error no Xcode is selected is expected. I didn't install it and the gcc that does come with Xcode is llvm which doesn't work for ruby 1.8.7.

admins-MacBook-Pro-3:~ admin$ xcode-select
Usage: xcode-select -print-path
   or: xcode-select -switch <xcode_folder_path>
   or: xcode-select -version
Arguments:
   -print-path                     Prints the path of the current Xcode folder
   -switch <xcode_folder_path>     Sets the path for the current Xcode folder
   -version                        Prints xcode-select version information
admins-MacBook-Pro-3:~ admin$ xcode-select -version
xcode-select version 2308.
admins-MacBook-Pro-3:~ admin$ xcode-select -print-path
xcode-select: Error: No Xcode is selected. Use xcode-select -switch /Applications/Xcode.app to select /Applications/Xcode.app, or see the xcode-select manpage (man xcode-select) for further information.

Since the gcc I'm using is from brew, I tried this without success. sudo xcode-select -switch /usr/local/bin/

I don't think this error Error: /usr/bin/xcode-select returned unexpected error. from my first post is about an error in xcode-select. Apache should be using rvm at this point and then passenger-install-apache2-module wouldn't need to be compiled or if it did, it would be using the rvm environment.

@mpapis
Owner

please provide a gist with:

/Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -e 'puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }'
@GolgothaX

/Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -e 'require "rbconfig"; puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }' https://gist.github.com/4539654

@mpapis
Owner

this looks properly, which makes me think something is wrong with apache configuration, could you gist now:

rvm system do ruby -rrbconfig -e 'puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }'
@GolgothaX

system rbconfig https://gist.github.com/4540102

I also tried

. /usr/sbin/envvars
ruby -rrbconfig -e 'puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }'

which ruby reports the rvm ruby path but rbconfig and $LOAD_PATH are from system ruby. https://gist.github.com/4540130

envvars gem environment. Ruby executable is wrong.

admins-MacBook-Pro-3:~ admin$ . /usr/sbin/envvars
admins-MacBook-Pro-3:~ admin$ which ruby
/Users/admin/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
admins-MacBook-Pro-3:~ admin$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
  - INSTALLATION DIRECTORY: /Users/admin/.rvm/gems/ruby-1.8.7-p357@global
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-11
  - GEM PATHS:
     - /Users/admin/.rvm/gems/ruby-1.8.7-p357@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
@mpapis
Owner

this is your apache configuration issue, it does not use the configuration options you have given to it, the script /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby takes care of loading properly ruby - if it would be used then there would be no problem like you have (with using the system ruby).

@mpapis mpapis closed this
@mpapis mpapis was assigned
@GolgothaX

This is apache that ships with OSX. The only customizations are the 3 passenger lines at the top of the file. I didn't add a vhost for any of my apps because the compilation happens at sudo apachectl -k start. I could reimage the machien and perform the same steps and be in the same situation(I've tried that twice already).

I tried using rbenv and it works with this same setup of 1.8.7, passenger, and apache. I realize they're different solutions to the multiple rubies problem but thought that bit of information might be of help.

What apache configurations are needed to support rvm? If I use rvm ruby-1.9.3, the environment variables and apache+passenger work correctly.

@mpapis
Owner

what configuration in rbenv did you use for /etc/apache2/httpd.conf?

@GolgothaX

Installed by brew.

LoadModule passenger_module /Users/admin/.rbenv/versions/1.8.7-p357/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/admin/.rbenv/versions/1.8.7-p357/lib/ruby/gems/1.8/gems/passenger-3.0.19
PassengerRuby /Users/admin/.rbenv/versions/1.8.7-p357/bin/ruby
@mpapis
Owner

Are you sure that the passenger gem was correctly installed? the settings look properly in both cases ... maybe except one very bad sign - the .so extension on OSX.

Please run the following commands and show me the outputs:

otool -L  /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
otool -L  /Users/admin/.rbenv/versions/1.8.7-p357/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so

I have checked with your ruby configuration and it should by bundle or dylib instead of so.

@GolgothaX

I'll get the otool results later. I rvm imploded to do the rbenv test.

As for .so, I agree it seems wrong on OSX, however that's what the passenger apache builder is outputting. https://github.com/FooBarWidget/passenger/blob/master/build/apache2.rb#L32

I just did a quick test on another computer with system ruby (no rvm, no rbenv) and it also outputs .so.

@GolgothaX
admins-MacBook-Pro-3:~ admin$ otool -L /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
/Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so:
    /usr/lib/libapr-1.0.dylib (compatibility version 5.0.0, current version 5.2.0)
    /usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.10.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
admins-MacBook-Pro-3:~ admin$ otool -L  /Users/admin/.rbenv/versions/1.8.7-p357/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
/Users/admin/.rbenv/versions/1.8.7-p357/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so:
    /usr/lib/libapr-1.0.dylib (compatibility version 5.0.0, current version 5.2.0)
    /usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.10.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
@mpapis
Owner

ok this looks exactly the same.

can you gist:

  • /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby
  • /Users/admin/.rvm/environments/ruby-1.8.7-p357@global

maybe one of this files is broken

@mpapis mpapis reopened this
@mpapis
Owner

sorry for returning to this again, could you run this:

/Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CC"]'
. /usr/sbin/envvars
/Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CC"]'

Are you sure the line in /etc/apache2/httpd.conf is:

PassengerRuby /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby

and not:

PassengerRuby /Users/admin/.rvm/rubies/ruby-1.8.7-p357/bin/ruby

as this two paths were confused few times in the discussion.

@GolgothaX
admins-MacBook-Pro-3:~ admin$ /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CC"]'
/usr/local/bin/gcc-4.2
admins-MacBook-Pro-3:~ admin$ . /usr/sbin/envvars
admins-MacBook-Pro-3:~ admin$ /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CC"]'
xcrun cc

from /etc/apache2/httpd.conf

LoadModule passenger_module /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/admin/.rvm/gems/ruby-1.8.7-p357@global/gems/passenger-3.0.19
PassengerRuby /Users/admin/.rvm/wrappers/ruby-1.8.7-p357@global/ruby
@mpapis
Owner

ok found it! it's because of using shared ruby and changing DYLD_LIBRARY_PATH makes ruby load from wrong directory - the compilation path is not respected.

The problem does not appear in ruby-build because it uses default ruby compilation to static libraries. You can recompile your RVM ruby to be also static with:

rvm reinstall ruby-1.8.7-p357 --disable-shared
@mpapis mpapis closed this
@GolgothaX

Wow!@!!% This worked. Thanks for all your help!

Is that worth adding to rvm requirements. Maybe under the section about needing to brew install apple-gcc, make sure to install with --disable-shared

@mpapis
Owner

rvm requirements will be reworked, it's worth rethinking if shared is giving anything on OSX, especially that there is no default package manager which would give any gains to shared, extra hint - binary ruby for OSX is already static via. https://github.com/tokaido/tokaido-build)

@mpapis mpapis reopened this
@mpapis mpapis closed this in 015a686
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.