Ruby Passenger: no such file to load bundler - ruby

I installed Phusion Passenger with Nginx, configured Nginx to point to the right directory, Then I ran webapp directory and this has downloaded the gemfiles, but it can't find the gems.
When I visit the site I get the standard Passenger error page which says:
Error message:
no such file to load -- bundler
Here's the full error: http://tinypic.com/view.php?pic=vpx36r&s=7
I've do a gem install bundler so I know bundler is installed, but I think it's looking in the wrong place for the gems.
It appears as if Passenger has installed ruby-enterprise-1.8.7 and it looks like 1.8 was already installed in this box.
gem env gives me the following:
- RUBYGEMS VERSION: 1.4.2
- RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/ruby-enterprise-1.8.7-2010.01/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/ruby-enterprise-1.8.7-2010.01/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
From what I've read it appears to be a path issue, but I don't know what the best course of action is to fix it.
Here's the output of
which ruby:
/opt/local/ree/bin/ruby
which bundle:
/opt/local/ree/bin/bundle
I've run bundle install in that directory and it's given me:
Your bundle is complete! It was installed into ./vendor/bundle

it looks like you have some path issues (as you already stated). try to check why you have two different paths for your ruby installation.
I mean, according to your gem env output, you have some installation on
/opt/local/ruby-enterprise-1.8.7-2010.01/
but you also have ruby and bunlder under
/opt/local/ree/
so, start from here to check if all the paths are correct and/or you haven't any double installations (well, it's just enough to check if your ENVs are coherent).
Another issue could be related to your nginx.conf, you should have something like this:
[...]
http {
passenger_root /your/path/to/passenger/gem;
passenger_ruby /path/to/ruby;
[...]
}
UPDATE (just saw additional comments with nginx.conf):
as you can see, there's a problem with paths: you have two paths for ruby and gems installs:
/opt/local/ruby-enterprise....
and
/opt/local/ree
you should remove the latter (not phisically, just review ENVs to point to the first one)
EDIT:
to change your env, you can append the following line to your /etc/bash.bashrc (or whaterver file is loaded from your shell by default):
PATH="/opt/local/ruby-enterprise-1.8.7-2010.01/bin:$PATH"
then logout and login, or for a quick test, launche this command from shell:
source /etc/bash.bashrc
now, retry to see what binary is used by default with:
which ruby
which gem
which rake
gem env
...
everything should have the /opt/local/ruby-enterprise-1.8.7-2010.01/ prefix (that's what is used from nginx and passenger configs).
UPDATE2: from the comments, it turned out that you have at least 3 ruby installs:
ruby from your package manager in /usr/lib/ruby/ (are you using ubuntu linux?)
a ruby in /opt/local/ree/
a ruby in /opt/local/ruby-enterprise-....
at this point, the best thing to do is:
uninstall all the rubys under /opt/local/ and all their gems
uninstall (purge) system provided ruby packages (you don't need it)
install and setup RVM: https://rvm.io
re-install passenger using RVM: https://rvm.io/integration/passenger/
fix nginx.conf to use passenger path and ruby

Related

Configure gem installation directory to match user installation directory

I'm familiar with the node/npm way, and trying to get set up using ruby/gem/bundler as well.
The output from gem env includes these lines:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby2.5/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/ssterling3/.gem/ruby/2.5.0
(I don't get why gems for ruby 2.5.1 would be installed in dir named 2.5.0, but that's not what this question is about.)
I don't want gem to ever touch anything outside of $HOME, and I want to do so in a way that I'll never have to edit even when I upgrade ruby or move the content of $HOME to a different computer where I have a different username.
(Sure, I'll have to reinstall all the gems or something, that's also not what this question is about.)
I think the right way to do it is to override the default INSTALLATION DIRECTORY and set it to always match the default USER INSTALLATION DIRECTORY.
How can I do that?
I know I can override the INSTALLATION DIRECTORY by setting $GEM_HOME, but I don't know how to get gem to output the USER INSTALLATION DIRECTORY in a way I won't have to parse before setting $GEM_HOME. I can get the INSTALLATION DIRECTORY from gem env gemdir, but gem env --user-install gemdir says Invalid option.
(Why one value has three dissimilar names and a closely related value only has the least usable analogous name are both also not what this question is about.)
I know I can configure some things in $HOME/.gemrc, but the documentation and examples I found didn't make it clear to me how to manipulate the INSTALLATION DIRECTORY. It sounded like I might be able to do it by adding the line gem: --user-install, but maybe it has to be at least three lines for install, uninstall, and update, but adding the line with gem: doesn't change the output of gem env so maybe none of those will really do what I want.
You can update environment variables. For my output:
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/ivan/.rvm/gems/ruby-2.5.1
- USER INSTALLATION DIRECTORY: /home/ivan/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /home/ivan/.rvm/rubies/ruby-2.5.1/bin/ruby
- EXECUTABLE DIRECTORY: /home/ivan/.rvm/gems/ruby-2.5.1/bin
- SPEC CACHE DIRECTORY: /home/ivan/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/ivan/.rvm/rubies/ruby-2.5.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/ivan/.rvm/gems/ruby-2.5.1
- /home/ivan/.rvm/gems/ruby-2.5.1#global
my file is located here:
home/ivan/.rvm/gems/ruby-2.5.1/environment
Note the environment file is into GEM PATHS first path.
Important: I should reload variables by:
source home/ivan/.rvm/gems/ruby-2.5.1/environment
or faster in most of shells:
. home/ivan/.rvm/gems/ruby-2.5.1/environment
I ended up putting this atrocity in my init scripts:
if [ ! -z "`which gem`" ]; then
GEM_HOME=`prefix=" - USER INSTALLATION DIRECTORY: "; line=\`gem env | grep "^$prefix"\`; suffix=${line#$prefix}; echo $suffix`
fi;

Textmate + RVM + Rake = Rake not using expected gem environment

I am using:
TextMate: version 2.0-alpha.9511
rvm: 1.25.15 (stable)
ruby: version 2.1.0p0
oh-my-zshell: 5.0.2
Mac OS X: 10.9.1 (Mavericks)
I have rvm and textmate set up to use
TM_RUBY=/Users/<myuser>/.rvm/bin/rvm-auto-ruby
The problem:
when I try to run my rake tasks using the rake bundle in textmate, I get some errors about the file not loading: "cannot load such file -- rubocop/rake_task"
The clue:
I changed my rakefile so that it simply reports the "gem env" for the default task.
When I then run the task, I see a completely different gem environment, than I would see if I used rake at the terminal command line.
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-13
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/Johno/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Whereas I see this when running
$ gem env
in my terminal, for my project
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0.rc.1
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- RUBY EXECUTABLE: /Users/Johno/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- SPEC CACHE DIRECTORY: /Users/Johno/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- /Users/Johno/.rvm/gems/ruby-2.1.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- /Users/Johno/.rvm/gems/ruby-2.1.0#global/bin
- /Users/Johno/.rvm/rubies/ruby-2.1.0/bin
- /Users/Johno/.rvm/bin
- /usr/local/bin
- /Users/Johno/Projects/Scripts/Ruby
- /Users/Johno/Projects/Scripts/bash
- /Users/Johno/Projects/Scripts/perl
- /Users/Johno/Projects/Scripts/Geek Tool
- /usr/bin
- /bin
I suspect that textmate is trying to use the "wrong" rake, or failing to set up the environment properly.
I think the problem may lie in the ruby bundle command from text mate:
#!/usr/bin/env bash
export RUBYLIB="$TM_BUNDLE_SUPPORT/RakeMate${RUBYLIB:+:$RUBYLIB}"
export TM_RAKE=$(which "${TM_RAKE:-rake}")
"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby" -- "$TM_BUNDLE_SUPPORT/RakeMate/rake_mate.rb"
It appears to be using a specific ruby (1.8) rather than the rvm project specific ruby
Does anyone have a suggestion as to how to resolve this?
Thank you,
John Schank
Followed the advice to set TM_RAKE and it didn't help.
I tried both the suggested setting, and using the results of which rake
/Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake
When using my TM_RAKE, is get a different error
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 5 total gem(s) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake:22:in `<main>'
This happens to be the same error I get when I try to use the rubocop.tmbundle
It still looks to me like the gem environment is not being passed to the child process.
I solved my own problem.
Here are the details for anyone else who has this problem...
First, the answer in this question TextMate, rvm and TM_RUBY
is almost perfect.
I had to create a textmate_ruby, and a textmate_rake script, and reference them in the variables in text mate: TM_RUBY, and TM_RAKE.
Second, since I'm using zsh, I had to change the shebang line in the textmate_xxx scripts to use zsh.
Finally, the key that helped me arrive at the correct solution is that I modified my project rakefile to :
task :default do
system "gem env"
system "ruby --version"
system "pwd"
system "printenv"
end
Then when I ran the rake task in textmate, it would dump the current values of my environment, ruby version, current directory, and gem environment. This really helped to see what was going on.
It seems that TextMate is still using your system rake instead of rvm's.
Try to set TM_RAKE in addition to TM_RUBY:
TM_RAKE=$HOME/.rvm/bin/rake
This also applies to rbenv, where you would set TM_RAKE to $HOME/.rbenv/shims/rake.

Error installing any gems on IronRuby

I am brand new to Ruby as of today. I installed IronRuby as I am a .NET developer and it seems to have a lighter footprint for Windows 7.
Things have been proceeding well, until I needed to install a Gem to parse HTML. I am issuing the following command:
igem install rokogiri
and receiving the following error:
ERROR: While executing gem ... (NoMethodError)
undefined method `set_params' for #<OpenSSL::SSL::SSLContext:0x00001ba>
Running igem env yields:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i386-mswin32]
- INSTALLATION DIRECTORY: C:/Program Files (x86)/IronRuby 1.1/Lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: "C:/Program Files (x86)/IronRuby 1.1/bin/ir.exe"
- EXECUTABLE DIRECTORY: C:/Program Files (x86)/IronRuby 1.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-dotnet-4.0
- GEM PATHS:
- C:/Program Files (x86)/IronRuby 1.1/Lib/ruby/gems/1.9.1
- P:/.gem/ironruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
My searches on Google have been fruitless. Does anyone have any suggestions?
Thanks!
The error happens in using OpenSSL library.
So this problem can be solved to use ruby standard OpenSSL library, not the library of IronRuby.
I think you can install the library in the following procedure.
Invalidate the function of SSL verifying once.
Add the next line to ~/.gemrc(%HOME%\.gemrc) file.
(if it doesn't exit, create)
:ssl_verify_mode: 0
In this, 'igem' is usabled.
But this state isn't recommend.
Install OpenSSL library, like this :
> igem install rubysl-openssl
And, restore ~/.gemrc file.
'igem' remains to be usabled.
For anyone else that comes across this a solution that worked for me was to use the standard Ruby gem command and set the install directory to the IronRuby gem location.
gem install --install-dir "c:/Program Files (x86)/IronRuby 1.1/lib/ironruby/gems/1.8" -V json_pure
igem does look like it's a very basic Ruby script that wraps up the Ruby gem command. The OpenSSL error seems to be a bit of a red herring and is probably because the default gem repository URL now redirects to a different location and the igem script doesn't deal with that.

having problems installing ruby gem "bluepill" on ubuntu [duplicate]

I recently upgraded to Ubuntu 9.04 and I have issues using gems.
I installed Ruby, Rubygems and Rails using apt-get.
The rails command does work.
I then installed capistrano and other gems, such as heroku.
In order to do that, I used the command:
sudo gem install XXX
When I want to use the cap command it does not work:
bash: cap: command not found
It is the same with the other gem commands.
Do I have something particular to do so that the gem commands work?
Where are my Gems?
You can find where your gems are stored using the gem environment command. For example:
chris#chris-laptop:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.2
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/chris/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
If you look at the "GEM PATHS:" section you can see that gems can be stored in two places on my laptop: /usr/lib/ruby/gems/1.8 or in the .gem directory in my home dir.
You can also see that executables are stored in EXECUTABLE DIRECTORY which in this case is /usr/bin.
Because /usr/bin is in my path this lets me run cap, merb, rails etc.
Updating your PATH
If for some reason your EXECUTABLE DIRECTORY isn't on your path (for example if it is /var/lib/gems/1.8/bin) then you need to update your PATH variable.
Assuming that you are using the bash shell. You can do this quickly for the current session by typing the following at the shell prompt; let's pretend that you want to add /var/lib/gems/1.8/bin to the path:
export PATH=$PATH:/var/lib/gems/1.8/bin
and press return. That appends the new directory to the end of the current path. Note the colon between $PATH and /var/lib/gems/1.8/bin
To set the value for all sessions you will need to edit either your .profile or .bashrc file and add the same line to the end of the file. I usually edit my .bashrc file for no reason other than that's what I've always done. When finished, save the file and then refresh your environment by typing:
bash
at the shell prompt. That will cause the .bashrc to get reread.
At any point you can check the current value of $PATH by typing
echo $PATH
at the shell prompt.
Here's a sample from one of my own servers, where my username is "chris" and the machine name is "chris-laptop":
chris#chris-laptop:~$
chris#chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
chris#chris-laptop:~$
chris#chris-laptop:~$ export PATH=$PATH:/var/lib/gems/1.8/bin
chris#chris-laptop:~$
chris#chris-laptop:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin
chris#chris-laptop:~$
My Gem won't load!
"Ruby gems won't load even though installed" highlights a common problem using multiple different versions of Ruby; Sometimes the Gem environment and Gem path get out of sync:
rb(main):003:0> Gem.path
=> ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
irb(main):004:0> exit
Any Ruby process here is looking only in one place for its Gems.
:~/$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/ruby1.9/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/ruby1.9/bin/ruby1.9
- EXECUTABLE DIRECTORY: /opt/ruby1.9/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
- /home/mark/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Look carefully at the output of gem environment:
- GEM PATHS:
- /opt/ruby1.9/lib/ruby/gems/1.9.1
This isn't the same path as returned by Gem.path:
["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
It's hard to say what exactly caused lib/ruby to change to lib/ruby1.9 but most likely the developer was working with multiple Ruby versions. A quick mv or ln will solve the problem.
If you do need to work with multiple Ruby versions then you really should be using rvm.
As noted by #Chris you need to add the gems environment to your path. You can do this by:
echo 'export PATH=$PATH:/var/lib/gems/1.8/bin' | tee --append ~/.bashrc
The folder in which gems are stored must be on your PATH, for example mine is:
/home/victor/.gem/ruby/1.8/bin
Check your path by typing
echo $PATH
It seens that when installing rubygems, now in ubuntu 9.04, I have this problem. I noticed that in "gem environment" the executable directory is "/var/lib/gems/1.8/bin", instead of "/usr/bin"... This is a problem with rubygems or with ubuntu 9.04??
The solution that I encountered is to add "/var/lib/gems/1.8/bin" to my $PATH doing this:
export PATH=$PATH:/var/lib/gems/1.8/bin
But it don't is saved... how can I save my path?
Thanks...
Resolvi: coloquei o export PATH=$PATH:/var/lib/gems/1.8/bin no ~/.bashrc! =]
mkmf is part of the ruby1.9.1-dev package. This package contains the header files needed for extension libraries for Ruby 1.9.1. You need to install the ruby1.9.1-dev package by doing:
sudo apt-get install ruby1.9.1-dev

How to change the Bundle Installer Executable and Installation directory

I have installed RVM and as noted in the install http://rvm.beginrescueend.com/rvm/install/ I was able to get "rvm is a function."
A lot of what I've read recommends not to use sudo gem install bundler, but it did not work without sudo (the error said I was not able to write to var/lib/gems/1.8 with gem install bundler)
Even after "Successfully Installed bundler" I still get "Bundle command not found" when i try to run either "gem bundle install" or "bundle install" from my App.
I think I need to change the executable but I am lost as to how to do this.
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [x86_64-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_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/james/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
Really appreciate any help. Thank you.
Ah, I cant remember exactly how I did this. It had to do with installing to the wrong directory. Adding the path on the ~/.bashrc file fixed it I am pretty sure. Try adding the lines below to the bottom of your ~/.bashrc file and see if that works. These are the three bottom lines of my file.
export RUBYOPT="-r rubygems"
export PATH=/var/lib/gems/1.8/bin:$PATH
if [[ -s /home/james/.rvm/scripts/rvm ]] ; then source /home/james/.rvm/scripts/rvm ; fi
The instructions that I used to figure this out are here also it looks like this might be a better way to do it, as it is a system wide installation. I would have done this if I did it over.
Also check these other posts regarding the same issue. I am sure you will be able to figure it out from there.
Good Luck!
post 1
post 2

Resources