I am running Apache on my Raspberry Pi (Raspbian) and struggling to get Passenger working properly with my site. When I go to visit my site (which is set up as a VirtualHost), I get the error: "cannot load such file -- bundler". The first line of the backtrace is
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb
To install Passenger, I followed the instructions here: http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu.
In particular, I ran the command
sudo apt-get install libapache2-mod-passenger
This link says, "The Apache package provides configuration snippets for you, so you don’t need to modify any Apache configuration to get it to load Phusion Passenger". The way the installation went on my machine was that it automatically added and enabled the passenger module through the files "passenger.conf" and "passenger.load":
passenger.conf:
<IfModule mod_passenger.c>
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
</IfModule>
passenger.load:
LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
Running "gem env" gives me the following output:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.7
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [armv6l-linux-eabihf]
- INSTALLATION DIRECTORY: /home/user/.rvm/gems/ruby-2.0.0-p247
- RUBY EXECUTABLE: /home/user/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
- EXECUTABLE DIRECTORY: /home/user/.rvm/gems/ruby-2.0.0-p247/bin
- RUBYGEMS PLATFORMS:
- ruby
- armv6l-linux
- GEM PATHS:
- /home/user/.rvm/gems/ruby-2.0.0-p247
- /home/user/.rvm/gems/ruby-2.0.0-p247#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
I tried looking all over for a mod_passenger.so file elsewhere in the file system with no luck. I am reluctant to simply reinstall rails or passenger because I am unsure what the implications will be for the modules and configuration. Any advice is appreciated, thanks!
Maybe you didn't configure your app to use Ruby 2.0.0? If you don't do that explicitly, it will use the default Ruby, which is /usr/bin/ruby. This section from the manual tells you how to specify a different Ruby: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby
Note that multiple Ruby supports requires Phusion Passenger >= 4.0.0.
The problem ended up being that I needed to set the environment variable for the GEM_PATH within a .htaccess file!
Related
I am having a ruby gem path problem starting passenger on apache.
Environment:
ubuntu-20
passenger-6.0.14
ruby-3.0.4
Ruby was installed system-wide using ruby-install, and is located at
/opt/rubies/ruby-3.0.4
chruby is being used to set the ruby environment.
ruby apps and gems are (hopefully) installed on a per-user and per-app basis. In this case, redmine is the only app.
When I visit the newly-created redmine site, passenger fails to start rails because of a gem path problem:
Raw Bundler exception:
Bundler was unable to find one of the gems defined in the Gemfile
Bundler tried to load the gems from #<struct Bundler::Settings::Path explicit_path=nil, system_path=false>
Could not find rails-6.1.4.7, rouge-3.28.0, ...
The gems are in fact, present:
$ cd ~
$ find . | grep rails-6.1.4
./.gem/ruby/3.0.4/specifications/rails-6.1.4.7.gemspec
./.gem/ruby/3.0.4/cache/rails-6.1.4.7.gem
./.gem/ruby/3.0.4/gems/rails-6.1.4.7
./.gem/ruby/3.0.4/gems/rails-6.1.4.7/README.md
The apache ssl startup for the virtual host looks like:
<IfModule mod_passenger.c>
PassengerRoot /home/test_user/.gem/ruby/3.0.4/gems/passenger-6.0.14
PassengerDefaultRuby /opt/rubies/ruby-3.0.4/bin/ruby
</IfModule>
...
Include rubies/test_user.include
and rubies/test_user.include has:
<Directory /var/www/html/issues-test>
PassengerAppRoot /home/test_user/redmine_test
PassengerAppEnv redmine_test
PassengerAppGroupName redmine_test
RailsBaseURI /issues-test
PassengerUser test_user
PassengerGroup test_user
PassengerFriendlyErrorPages on
</Directory>
The gem environment for the user where redmine is installed:
- RUBYGEMS VERSION: 3.2.33
- RUBY VERSION: 3.0.4 (2022-04-12 patchlevel 208) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/test_user/.gem/ruby/3.0.4
- USER INSTALLATION DIRECTORY: /home/test_user/.gem/ruby/3.0.0
- RUBY EXECUTABLE: /opt/rubies/ruby-3.0.4/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /home/test_user/.gem/ruby/3.0.4/bin
- SPEC CACHE DIRECTORY: /home/test_user/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /opt/rubies/ruby-3.0.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/test_user/.gem/ruby/3.0.4
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0
- SHELL PATH:
- /home/test_user/.gem/ruby/3.0.4/bin
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/bin
- /opt/rubies/ruby-3.0.4/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /snap/bin
Note that the shell PATH does not include the
/home/test_user/.gem/ruby/3.0.4/gems/
path; and the test_user.include shows no path to the gems for passenger.
I'm not clear on how ruby/passenger establishes the path for gems.
The passenger install was done from the user environment.
Note: I'm also unclear as to why the INSTALLATION DIRECTORY shows
/home/test_user/.gem/ruby/3.0.4
but the USER INSTALLATION DIRECTORY shows
/home/test_user/.gem/ruby/3.0.0.
(At some point I may have done ruby-install 3.0 and it installed 3.0.4). There is, however, no directory ~/.gem/ruby/3.0.0
There were a couple of issues here. Thanks #Casper for some hints.
Passenger must be installed system-wide, i.e., as root.
It was installed as the redmine user, so had to be de-installed.
Checking the passenger uninstall page for apache, it says
"Remove the passenger files" and then details how to do that, assuming passenger was installed any way except from source.
Unfortunately, I installed from source, as the regular repositories are way out of date. Uninstalling from source is non-trivial, as the passenger files are mixed in with the other application files and there is no easy way to find them all and differentiate. I ended up deleting the entire ruby / redmine environment for the user and starting over.
To install passenger as root, in a ruby-install/chruby environment:
sudo -i
cd /opt/rubies
source /usr/local/share/chruby/chruby.sh
chruby 3.0.4
gem install passenger
passenger-install-apache2-module
exit
Once passenger was re-installed globally, attempting to set up redmine for a specific user still failed with the same error -- Bundler can't find any gems. I read several places that one should not have to set the GEM_PATH explicitly, as Passenger/Ruby/Bundler are supposed to be able to automatically find the gems they need if they are in a conventional place, but apparently not. My assumption was that since the passenger definition for the redmine app specified the user environment properly, they should be found. (It's not clear to me if this problem is specific to Passenger, an Apache2 installation, or Ruby/Bundler)
The problem may be because I am using ruby-install and not rvm; passenger's docs seem to assume rvm is used as the installer.
In any case, I had to explicitly set GEM_PATH in the apache2 configuration.
The path is the one shown if "gem env GEM_PATH" is given from the user account.
So for this case, in (file rubies/test_user.include above), add the line:
SetEnv GEM_PATH /home/test_user/.gem/ruby/3.0.4/:/opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/
The complete apache2 config fragment looks like:
<Directory /var/www/html/issues-test>
PassengerAppRoot /home/test_user/redmine_test
PassengerAppEnv redmine_test
PassengerAppGroupName redmine_test
RailsBaseURI /issues-test
PassengerUser test_user
PassengerGroup test_user
PassengerFriendlyErrorPages on
SetEnv GEM_PATH /home/test_user/.gem/ruby/3.0.4/:/opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/
</Directory>
Using heroku for deployment while learning Rails with the Ruby On Rails tutorial by Michael Hartl, on Ubuntu 11.04 Natty Narwhal. I installed it using
sudo gem install heroku
and the commands seemed to run fine for that session in the terminal. The next time I went to work, I tried the command "heroku open" and I was told "heroku: command not found". Looking at some of the answers to similar problems here, it seemed the answer was to run
gem enviroment
which returned the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/richard/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I then ran
$ export PATH=$PATH:/var/lib/gems/1.8/bin
which seemed to fix the problem. However, the next time I tried to run heroku in the terminal, I was told "command not found" again! Running the "export PATH=$PATH" command seems to fix the problem every time, but I would rather I didn't have to run this command everytime I want to use heroku. Is there any permanent solution to the problem?
If you're using bash as your shell, then add that export line to .bash_profile in your home directory. The equivalent for zsh is .zshrc, and other shells have their own files to automatically load for every shell session.
I'm currently trying to get Thin webserver running on Windows, to form a basic cluster behind a NGINX proxy, but this is proving to be rather difficult.
I was wondering if anyone actually succeeded in getting this up and running?
To give some examples of the things I have tried:
C:\Users\arne.de.herdt.TENFORCE2\RubymineProjects\ESCO>thin start
C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:926:in `report_activate_error': Rub
yGem version error: thin(1.2.11 not >= 0) (Gem::LoadError)
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:244:in `activate_dep'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:236:in `activate'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:1307:in `gem'
from C:/Ruby/bin/thin:18:in `<main>'
I really don't get this error message. I've included below the environmental output of my system that I'm trying this on (my development system)
RubyGems Environment:
- RUBYGEMS VERSION: 1.7.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby/lib/ruby/gems/1.9.1
- C:/Users/arne.de.herdt.TENFORCE2/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Hoping someone has been experimenting with this.
Also I must say that it's starting to annoy me that the lack for Windows support is such a serious issue with Ruby on Rails. I really enjoy the language and programming in it, but it's a pain getting things to work on Windows machines because of uncompilable dependencies...
Thin ain't supported under Windows.....
Lots of confusion and difficulty related to gem installation. My gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/apple/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
The problem is one where I will add (eg) to environment.rb :
config.gem 'authlogic'
All good, now when I run
gem install authlogic
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /opt/local/lib/ruby/gems/1.8 directory.
running it with sudo is fine :
Dans-iMac-335:authlogic apple$ sudo rake gems:install
Password:
(in /Users/apple/Documents/projects/authlogic)
gem install authlogic
Successfully installed authlogic-2.1.6
1 gem installed
Installing ri documentation for authlogic-2.1.6...
Installing RDoc documentation for authlogic-2.1.6...
but running rake tasks throws an error :
Dans-iMac-335:authlogic apple$ rake db:migrate
(in /Users/apple/Documents/projects/authlogic)
Missing these required gems:
authlogic
You're running:
ruby 1.8.7.174 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
rubygems 1.3.5 at /Users/apple/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
I can't see what the problem is. And I'm going out of my mind. The directory at the 'other' gems location :
Dans-iMac-335:authlogic apple$ ls /Users/apple/.gem/ruby/1.8/gems
actionmailer-2.2.2 activeresource-2.2.2 aws-s3-0.6.2 mysql-2.8.1 rails-2.2.2 xml-simple-1.0.12
actionpack-2.2.2 activeresource-2.3.3 builder-2.1.2 packet-0.1.15 rake-0.8.7
actionwebservice-1.2.3 activesupport-2.2.2 chronic-0.2.3 pg-0.8.0 rest-client-1.3.1
activerecord-2.2.2 activesupport-2.3.3 mime-types-1.16 rack-1.0.0 sqlite3-ruby-1.0.1
activerecord-2.3.5 activesupport-2.3.5 mongrel-1.1.5 rack-1.0.1 taps-0.2.26
This, I assume, is the default OSX rails system? The first location gives the much fuller set that represents my normal environment. Since my projects depend on many of these, and they aren't present in the other directory, this is verifiably the location that gems are being pulled from in my development environment:
Dans-iMac-335:authlogic apple$ ls /opt/local/lib/ruby/gems/1.8/gems
RedCloth-4.2.3 crack-0.1.8 mime-types-1.16 rack-1.1.0 sinatra-0.9.2
actionmailer-2.3.5 daemons-1.0.10 minitest-1.4.2 radiant-0.8.1 sinatra-1.0
actionmailer-2.3.8 faker-0.3.1 mogli-0.0.14 rails-2.2.2 spree-0.10.2
actionpack-2.3.5 fastthread-1.0.7 mongrel-1.1.5 rails-2.3.5 sqlite3-ruby-1.0.1
actionpack-2.3.8 gem_plugin-0.2.3 mutter-0.5.3 rails-2.3.8 sqlite3-ruby-1.2.5
activemerchant-1.5.1 google-geocode-1.2.1 mysql-2.8.1 rc-rest-3.0.0 state_machine-0.8.0
activerecord-2.3.8 hashie-0.4.0 net-scp-1.0.2 rest-client-1.0.3 stringex-1.0.3
activerecord-tableless-0.1.0 heroku-1.10.8 net-sftp-2.0.2 rest-client-1.6.1 taps-0.2.19
activeresource-2.3.5 highline-1.5.1 net-ssh-2.0.15 rmagick-2.13.1 taps-0.3.13
activeresource-2.3.8 hoe-2.3.3 net-ssh-gateway-1.0.1 ruby-hmac-0.4.0 thor-0.9.9
activesupport-2.3.8 hpricot-0.8.1 nokogiri-1.3.3 ruby-openid-2.1.7 treetop-1.4.8
authlogic-2.1.6 httparty-0.6.1 paperclip-2.3.1.1 rubyforge-2.0.2 whenever-0.3.7
authlogic-oid-1.0.4 json-1.1.9 passenger-2.2.5 rubyforge-2.0.4 will_paginate-2.3.11
aws-s3-0.6.2 json_pure-1.1.9 pg-0.8.0 rubygems-update-1.3.5 xml-simple-1.0.12
builder-2.1.2 json_pure-1.2.4 pg-0.9.0 rubygems-update-1.3.7
capistrano-2.5.9 launchy-0.3.3 polyglot-0.3.1 searchlogic-2.3.5
cgi_multipart_eof_fix-2.5.0 less-1.2.20 postgres-0.7.9.2008.01.28 sequel-3.0.0
configuration-1.1.0 libxml-ruby-1.1.3 rack-1.0.1 sequel-3.15.0
So, if the system uses this /opt/local/lib/ruby/gems/1.8/gems directory, why can't it see it when I call rake? And what can I do about it?
I don't see what the problem is, but have you tried running "gem list " to see what gems your system recognizes as having installed?
My solution was to change the #! line of rake.rb to point to the location of the ruby installation that has the gems.
From what I learned, when you're installing gems, rails takes account of the $PATH variable, but when loading the environment when rake is called, it doesn't. So rake doesn't know about those locations. The answer, then, was to direct rake's attention to the right location.
Everytime I start my Rails applications I get LoadError with the following output.
On Rails 2.3.8:
no such file to load -- sqlite3/sqlite3_native
<internal:lib/rubygems/custom_require>:29:in `require'
On Rails 3.0.0:
no such file to load -- bundler
<internal:lib/rubygems/custom_require>:29:in `require'
I run the applications in the production mode on a development machine using Nginx + Passenger.
What is the reason of this issue? How can I solve it?
Thanks.
Debian GNU/Linux 5.0.6;
Ruby 1.9.2;
Rubygems 1.3.7;
Ruby on Rails 2.3.8, 3.0.0;
Nginx 0.8.50;
Passenger 2.2.15;
sqlite3-ruby 1.3.1;
bundler 1.0.0.rc.6.
Updated
All of my gems is installed by the unprivileged user in the local directory /home/<usernam>/.gem. If it helps, here's the gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /home/<username>/.gem
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/<username>/.gem/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/<username>/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :gemhome => "/home/<username>/.gem"
- :gempath => ["/home/<username>/.gem"]
- REMOTE SOURCES:
- http://rubygems.org/
Updated
I tackled with the problem. Its source was that I defined a custom gem path. That is I added to the ~/.gemrc file the following lines:
:gemhome: /home/<username>/.gem
:gempaths:
- /home/<username>/.gem
Thus all of my gems was placed in the specified directory but not the default one. For some reason Rubygems coundn't find it there and rose an exception.
When I removed that lines from the file the default paths was set for Rubygems and after I installed all the required gems and loaded my Rails applications all began to work.
Once again, the bug conditions are:
Nginx + Passenger;
The gempath is set to /home/<unprivileged_user>/.gem in ~/.gemrc;
An init.d script is creaded and added to the boot sequence (update-rc.d nginx defaults);
System is rebooted, server is started atomaticlally;
http://localhost/my_rails_app;
LoadError; no such file to load -- <gem_name>; <internal:lib/rubygems/custom_require>:29:in `require'.
Why can't Rubygems find gems in the custom location but can find them in default? That's the question.
I too had this problem when using RVM - I must have specified a gemset or something and not made it project specific. At any rate, read this rvm guide if you want to know the basics of RVM and try to specify a new gemset for your current folder / project, install a new rails gem to that gemset, and then use that gemset. For example, to create a new gemset for rails version 2.3.8:
$ rvm gemset create rails238
$ rvm ruby-1.8.7#rails238
$ gem install rails -v 2.3.8
Then if all went according to plan type rvm gemset use [gemsetName], or do rvm gemset list to see a list of installed gemsets, and to see if rails is working fine try rails -v and you should see rails 2.3.8
Check your system to locate where your rubies and gems are installed ( you can do this by "which ruby" and "which gem"). Usually, they're installed in the same folder (/usr/bin or /usr/local). If they are in different locations, there might be load error. Just a suggestion.