When I enter my rails dir on server RVM switch to
/home/capistrano/.rvm/gems/ruby-1.9.2-p290#global/bin/bundle
although it should use ruby-1.9.2-p290#mygemset/bin/bundle as it works on my local machine. When I type rvm use 1.9.2#mygemset it works. Nginx server is also looking for gems in the #global gemset
my .rvmrc file:
environment_id="ruby-1.9.2-p290#mygemset"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create use "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
I'm not sure if I understood you but you could place an .rvmc file in your rails folder and put something like this in it.
rvm use ruby-1.9.2#mygemset
Whenever you cd into that directory rvm will use settings from the .rvmc file.
RVM is going through rapid develpment so the syntax and functionality of commands sometimes vary. Anyway, I solved it with upgrading to stable RVM:
rvm get stable
which is now rvm 1.14.1 (stable). Afterwards commands like rvm 1.9.3-p194#mygemset --create
works perfectly.
Another thing I was missing is the new syntax for executing commands:
rvm #mygemset do bundle install
This will install all gems for given gemset and ruby specified in .rvmrc file
Related
I set up rvm (and .rvmrc file) not properly, therefore whenever I go the directory of my RoR project and type rails s or any other rails command, I'll get the error of
The program 'rails' can be found in the following packages:
* rails
* ruby-railties-3.2
Try: sudo apt-get install <selected package>
and I have to type rvm use 1.9.3-p392 to fix it.
.rvmrc file contains
environment_id="ruby-1.9.3-p392#project1"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
do
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
then \. "${__hook}" || true
fi
done
unset __hook
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
Try
rvm use ruby-1.9.3-p391 --default
.rvmrc in the newest version of RVM is deprecated. It should work but try new syntax:
put to .ruby-version file just:
1.9.3-p392
Additionaly you can define .ruby-gemset with
yourgemsetname
Post your rvmrc file in order to get some help.
If you want to check a look at other's project rvmrc file you can take a look at octopress here. Also you can take a look at rvmrc docs if you haven't already looked.
The message you've got is from the autocomplete ubuntu/debian projects, meaning that it can't found the rails command, so it suggests the packages you can install to get it.
Probably you havent loaded the rvm environment. You can load it via:
source $HOME/.rvm/scripts/rvm
and then check if it works.
I am using ruby on rails on Ubuntu 11.10. Ruby 1.8.7 works fine but I cannot get rvm to work with 1.9.3 or any other version.
When I run rvm reload, rvm list or rvm info, I get the following message:
bash: /usr/bin/rvm: No such file or directory
I have Ruby 1.9.3 installed via rvm and when I change the default it doesn't give me an error. But then when I check the ruby -v it defaults back to 1.8.7.
Also, when I check which ruby it shows the following:
/usr/local/bin/ruby
My guess is that it has something to do with the bash file. What do you suggest?
I am guessing that it isn't even installing it correctly.
This is what happens:
I type the following into the prompt:
bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
And it outputs:
ERROR: Unable to checkout branch .
Are you following the installation instructions from the rvm site?
http://beginrescueend.com/rvm/install/
If you are then look at section 2 about the shell again.
specifically this command that they tell you to run :-)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
remember to reload or restart your shell after running that command.
run the command
source /usr/local/rvm/scripts/rvm
and then
type rvm | head -1
you should get output -
rvm is a function.
And after that run
rvm use rvm use 2.0.0 --default
I installed RVM, Ruby 1.9.2 and Rails 3.0.9 on Lion which works fine. Only problem is, after I close the terminal I need to execute this:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
for it to pick up RVM.I then need to make RVM use Ruby 1.9.2 first before I can do Rails stuff again.
How can I make this permanent?
After you first execute
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
you shouldn't need to do it again. That line appends the necessary file inclusion information RVM into your .bash_profile. If you are using bash (as opposed to zsh, ksh, csh, tcsh or any other shell), then RVM will be accessible each time you open a new session. If you are using a different shell, that line may need to be in a different startup file. For example, if you are using zsh, then you'll probably want to append it to your ~/.zshrc file.
Having done this, simply running rvm --default use ruby-1.9.2 once should ensure that you have the desired version of Ruby by default. Note, you should not need to add this line to your .bash_profile or similar.
try this
rvm --default use ruby-1.9.2
In order to make Terminal (e.g. bash) enable RVM every time you open it, edit ~/.profile and add the following line to it:
[[ -s "/Users/foo/.rvm/scripts/rvm" ]] && source "/Users/foo/.rvm/scripts/rvm" # This loads RVM into a shell session.
Then to make the RVM's version of ruby default, as fl00r has mentioned, run:
rvm --default use ruby-1.9.2
Alternatively, you can add an .rvmrc file to the root folder of your app that uses Rails 3.0.9 and specify which version of Ruby you want to use with that project there:
rvm ruby-1.9.2
Even better, you should create a gemset by running rvm gemset create rails-3.0.9 and update you .rvmrc file to become like this:
rvm ruby-1.9.2#rails-3.0.9
Then run cd into the project once again (you must cd into it once again), and run bundle install.
This way your project will have its own isolated gemset.
this also work for me
rvm --default use 1.9.2
I am struggling to get Rails to deploy on a server that has:
a factory installed Ruby (1.8.7) in /etc/
an updated Ruby (1.9.2p290) in /usr/local/bin/
the Ruby I want to be using(1.9.2p290) in /usr/local/rvm/rubies.
Is there a way to set a GLOBAL default Ruby in RVM for ALL users?
When I set default with rvm --default 1.9.2#railspre it'll work fine for that session. But, when I log back in the ruby switches back to the one in /usr/local/bin. And, due to RVM's hocus pocus, that I don't fully understand, I can't just edit the $PATH for it in .bashrc.
$PATH at login:
/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/opt/subversion/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#railspre/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
$PATH after rvm --default 1.9.2#railspre:
/usr/local/rvm/gems/ruby-1.9.2-p290#railspre/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
No matter what (before or after changing RVM's default) rvm default list says the same thing:
$ rvm default list
rvm rubies
=> ruby-1.9.2-p290 [ ppc ]
Ideas?
Edit- adding requested info
$ type rvm | head -1
rvm is a function
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
$ whereis ruby
/usr/bin/ruby
Please post the result of the following :
type rvm | head -1
rvm notes
which ruby
whereis ruby
rvm list known
Do =>
rvm use 1.9.2 --default
Being root and normal user do =>
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source .bash_profile
Restart your pc and see if it works.
I have installed ruby via rvm on Mint 11 no problem. Installed gems, ditto. Installed rails via gem install rails, and when I type rails -v it returns the correct version. Until I close that terminal and reopen a terminal. When I do that and type rails -v I get the message
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
If I then type
rvm use 1.9.2-p180 --default
and then type rails -v I again get the correct version...until I close the terminal.
I should add that I have added a path statement to my .bashrc pointing to the 1.9.2-p180 directory in my .rvm directory.
Typing ruby -v always returns the correct version.
Create .bashrc file and add .rvm command
$ sudo touch ~/.bashrc
$ sudo gedit ~/.bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
Logout and Login OR just update user profile from .bashrc with following command
$ . ~/.bashrc
Try adding this command to your .profile and reopening your shell:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Use project rvmrc files. You can see how to set this up here http://beginrescueend.com/rvm/best-practices/
That way you keep all your gems seperate for each project and it's dead simple to set up
Try which rails. Maybe there is a link to a stub that gives you the note.
If that is the case calling the full path might help, e.g. /usr/local/bin/rails