I'm trying to install an application on Ubuntu that uses ruby. I installed RVM and Ruby 2.0 and ran rake install, but Rake tried using an older system version of Ruby. So I uninstalled the system version and tried running Rake again. This time it said "No such file". How do I get Rake to use RVM's ruby? Below is the output from different commands.
$ rake install
sudo bundle --without production staging test levelbuilder --quiet
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
rake aborted!
...
/home/ubuntu/../rake_utils.rb:33:in `system'
..
/home/ubuntu/../rake_utils.rb:43:in `bundle_install'
/home/ubuntu/../Rakefile:198:in `block (3 levels) in <top (required)>'
..
/home/ubuntu/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
...
The path and version look right:
$ echo $PATH
/home/ubuntu/.rvm/gems/ruby-2.0.0-p643/bin:/home/ubuntu/.rvm/gems/ruby-2.0.0-p643#global/bin:/home/ubuntu/.rvm/rubies/ruby-2.0.0-p643/bin:/home/ubuntu/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]
$ which ruby
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p643/bin/ruby
Here's my .bash_profile:
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
and here's the bottom of .bashrc:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting.
Execute source ~/.bash_profile
Related
I was running ruby 2.0.0-p247 on my Mac Mini Server (Mavericks 10.9.1). I read that there was a security vulnerability so I decided to upgrade to use the latest Ruby patch 2.0.0-p353. I did the following commands:
gem update --system (RubyGems 2.1.11)
rvm get stable (RVM 1.25.0)
rvm upgrade 2.0.0-p247 2.0.0-p353 (which should have moved my gemsets)
There is nothing in my system that I can find that references 2.0.0-p247 in rvm which is what I expected. When I go to ~/myuser/.rvm/environments there is no file 2.0.0-p247.
I am now attempting to start passenger. I had version 4.0.23 enterprise installed. I attempted to run rvmsudo passenger-install-apache2-module but got an error.
cd /Users/myuser/.rvm/gems/ruby-2.0.0-p353#mygemset/gems/passenger-enterprise-server-4.0.23
/Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
# /Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
ERROR: Missing RVM environment file: '/Users/myuser/.rvm/environments/ruby-2.0.0-p247#LightBeCorp_Rails4Ruby2'
Here are statements in my .bashrc file related to rvm if this will help.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/gems/ruby-1.9.3-p327#mygemset/bin:/.rvm/rubies/ruby-1.9.3-p327/bin/ruby:/.rvm/rubies/ruby-1.9.3-p448/bin/ruby:/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
I did a rvm list rubies command. ruby-2.0.0-p247 is not listed.
Any help would be appreciated. I will continue looking. I plan to post a link to this in the Phusion Passenger group.
UPDATE 12/21/2013 12:20 pm
I updated my .bashrc file to the following since I no longer use the other rubies in my Rails applications. I still get the error when I try to run rvmsudo passenger-install-apache2-module.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
looks like a bug, please open a ticket here: https://github.com/wayneeseguin/rvm/issues
Indeed this was a bug, to fix it run:
rvm get head
rvm gemset reset_env
you can repeat the reset_env operation for every gemset that is broken:
rvm ruby#gemset do rvm gemset reset_env
There might be a cached bin file in your RVM path. In my case, it's "/usr/local/rvm/bin/unicorn"
Also, you may not directly having the gem in your Gemfile. In my case, I do not have "unicorn" in my Gemfile although I had "capistrano-unicorn".
So that the system will try to use the global cached file "/usr/local/rvm/bin/unicorn".
The file's content may using a ruby that you no longer use.
if [[ -s "/usr/local/rvm/environments/ruby-2.0.0-p247" ]]
then
source "/usr/local/rvm/environments/ruby-2.0.0-p247"
exec unicorn "$#"
else
echo "ERROR: Missing RVM environment file: '/usr/local/rvm/environments/ruby-2.0.0-p247'" >&2
exit 1
fi
I've got Ruby, Rails, Rake and friends all working pretty well using RVM on OSX, but when I start a new shell (new tab in Terminal.app) rake tasks seem to "lose" their environment:
$ rake my_module:my_task
Could not find uglifier-1.2.7 in any of the sources
Run `bundle install` to install missing gems.
If I issue "rvm use" (which, I believe merely prints the current ruby, but does not alter anything) then it works fine:
$ rvm use
Using /Users/username/.rvm/gems/ruby-1.9.3-p194
$ rake my_module:my_task # works fine now!
It seems to happen when a new shell is started. I have rvm installed as a single-user installation, with the following at the bottom of my .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
I've verified that my .bash_profile is in fact executing by putting some echo statements after that line; I see the echo on the command line when I open a new tab, so it seems to be working. Any idea why rake doesn't work without "rvm use"?
Try setting rvm ruby to default ruby
$ rvm use ruby-1.9.3-p194 --default
This should use the rvm ruby-1.9.3-p194 every time as default.
I'm trying to get Octopress (http://octopress.org/) working, but I'm having some issues.
I'm using POW (http://pow.cx/) and it seems to not load the correct Ruby version for me (using RVM).
It always uses the RVM default ruby version and not the one specified in .rvmrc. My default Ruby version in RVM is: ruby-1.9.3-p125.
In my .rvmrc file I have this: rvm use 1.9.2
I get this error in the browser when visiting my site:
LoadError: cannot load such file -- bundler/setup
~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
~/Sites/Lejnus/lejnus/config.ru:1:in `block in <main>'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/Sites/Lejnus/lejnus/config.ru:1:in `new'
~/Sites/Lejnus/lejnus/config.ru:1:in `<main>'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:50:in `eval'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:50:in `load_config'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:43:in `initialize'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `new'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/bin/nack_worker:4:in `<main>'
Why is it using 1.9.3-p125 when 1.9.2 is specified in my .rvmrc file? If I set 1.9.2 as default it works of course...
Isn't it supposed to do this magic for me and use the correct ruby versions?
Ok, seems like POW is moving away from RVM.
I needed to run this in my projects root to get it working:
rvm env . -- --env > .powenv
i've sorted the problem by adding a .powrc at the root of the project with the following code
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
source "$rvm_path/scripts/rvm"
source ".rvmrc"
fi
[Edited to add: This is recommended in the Pow documentation]
This is what solved the problem for me:
rvm env -- `rvm current` > .powenv
You can also create a rvm hook (as commented here) for switching the .powenv automatically when you change the current ruby env:
# ~/.rvm/hooks/after_use_update_powrc
for file in `ls ~/.pow/` ; do
POW_LINK_TARGET=`readlink ~/.pow/$file`
if [ `pwd` = $POW_LINK_TARGET ]; then
rvm env -- ``rvm current`` > .powenv
fi
done
Don't forget to make it executable:
chmod +x ~/.rvm/hooks/after_use_update_powrc
I have spent literally days trying to install ruby 1.9.2 and get it working with gems :-/ I eventually gave up on my Mac OSX 10.6 machine and below is the current state on my Ubuntu machine. Any advice would be greatly appreciated!
# ruby test.rb
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- mongo (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from test.rb:1:in `<main>'
# cat test.rb
require 'mongo'
db = Mongo::Connection.new.db("mydb")
# gem which mongo
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/mongo-1.1.2/lib/mongo.rb
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"
According to this page: http://docs.rubygems.org/read/chapter/19
I symlinked which ruby I was using to match that which gem is using:
# which ruby
/usr/local/rvm/bin/ruby
# ls -l `which ruby`
lrwxrwxrwx 1 root root 44 2010-11-17 13:25 /usr/local/rvm/bin/ruby -> /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby
# gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.2-p0/bin/ruby
# which gem
/usr/local/rvm/bin/gem
# gem -v
1.3.7
# ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Try putting the following line at the beginning
require "rubygems"
Why is "rvm" displaying in your /usr/local/rvm/ path? Did you do a system-wide install, as a system administrator using administering Ruby system wide for multiple users?
Did you add [[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm' to your ~/.bashrc, ~/.bash_profile or ~/.profile (whichever you have configured)?
For normal, every day use, I recommend RVM's default setup:
RVM installation, RVM gems management.
Note to self: Buy stock in RVM. It's too cool.
Does it work under Ruby 1.8.7, which is pre-installed by default on OS X?
If so, one difference between 1.9.1 and 1.9.2 is that "." isn't part of $:'s path any more.
I recommend that you do rvm implode and delete the current setup. Then use the railsready script to setup RVM and Ruby properly for you on Ubuntu. It's important to understand that until you know what you are doing you should run the script as a user. Hope that helps.
On linux and OS X, I have always had to put require "rubygems" in the beginning. However it has always worked fine without this line on windows.
I've cloned the ruby 1.8.7 source tree. I can build ruby. But I can't figure out how to run it without installing it in system directories. How can I do it?
Background: I want to use "git bisect" to figure out which build of Ruby introduced a new behavior in my code. I need to build and run ruby against a test program, multiple times, but I don't want to clobber the ruby that the Debian package installed.
Here's what I get if I try to run the ruby I built from source:
$ ./ruby -e 'puts RUBY_VERSION'
ÀÇ ÀÇ : ÀÇ ÀÇ : cannot open shared object file: No such file or directory - ÀÇ ÀÇ (LoadError)
I've also tried installing it, but not to the system directories, and got a stack trace:
$ ./configure --prefix=/home/wayne/tmp/ruby/installed --exec-prefix=/home/wayne/tmp/ruby/installed
$ make
$ make install
$ /home/wayne/tmp/ruby/installed/bin/ruby -e 'puts RUBY_VERSION'
/home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl/ssl.rb:26: uninitialized constant OpenSSL::SSL::VERIFY_PEER (NameError)
from /home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl.rb:23:in `require'
from /home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl.rb:23
I've got the feeling that I'm close, but a miss is as good as a mile.
rvm is a great tool. and should be able to take care of the heavy lifting for switching between different ruby version (or even sets of gems).
Installation is very easy:
$ gem install rvm && rvm-install
$ echo "if [[ ! -z $HOME/.rvm ]] ; then source $HOME/.rvm ; fi" >> ~/.bash_profile
Then to install a specific version & patch level:
rvm install ruby-1.8.7-p160
Then to switch between versions:
$ rvm 1.8.7-p160
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 160) [i686-darwin10.0.0]
$ rvm 1.8.7-p174
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
When I need to do something like that, I use the chroot command. Create a temporary directory, install ruby into a sbin subdirectory, and chroot into the temp folder. Depending on what you are testing, you may also have to copy some system libraries into the temporary directory tree (before you chroot in).
It's probably easier to use rvm to test your app against different rubies.