I am looking for a path of where ruby gets stored on mac?
I installed macruby on my mac and I am trying to see where it got installed. I want to include the path of macruby in my ruby script. When I do rvm list, I get:
=> macruby-0.12 [ i686 ]
* ruby-1.9.3-p545 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
ruby-2.1.2 [ x86_64 ]
ruby-2.1.2-version [ x86_64 ]
I use #!/usr/local/bin/macruby in my ruby script, but looks like macruby is not present in that location. When I execute "whereis ruby" command on I get back "/usr/bin/ruby", but when I execute "whereis ruby-1.9.3-p545" or "whereis macruby-0.12" I get nothing.
How do I find the path of where does all these ruby versions lie?
You can get the path to the local executable with
$ which ruby
the rvm rubies are in your rvm directory, which I believe is ~/.rvm/rubies (I use rbenv so not sure about the details)
The which command should pickup whatever shims/other magic RVM is using to set your shell ruby
You can find your answer by running one of the following commands:
which ruby
whereis ruby
type -P ruby
Related
I recently installed Ruby 2.1.1 with RVM, and I set that to the default. In my root directory it correctly sets current to ruby-2.1.1:
$ rvm list
rvm rubies
ruby-1.9.3-p448 [ x86_64 ]
ruby-1.9.3-p545 [ x86_64 ]
=* ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ which ruby
$ /Users/mynamehere/.rvm/rubies/ruby-2.1.1/bin/ruby
But when I move into my rails project, current is set back to 1.9.3, even though default is 2.1.1:
$ rvm list
rvm rubies
ruby-1.9.3-p448 [ x86_64 ]
=> ruby-1.9.3-p545 [ x86_64 ]
* ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ which ruby
$ /Users/mynamehere/.rvm/rubies/ruby-1.9.3-p545/bin/ruby
Can someone tell me why the current ruby version changes depending on my directory, and how I can set 2.1.1 to be the default? I've tried doing "$ rvm --default use 2.1.1" in my project directory, but that doesn't fix the issue.
Thanks!
You probably have a .ruby-version file in your Rails project folder which establishes the default for that project. Check for that and, if you have it, you can remove it or change it's contents to the version you want to use for that particular Rails project.
It's discussed (rather tersely) in the rvm website under Typical RVM Project Workflow.
You can also define your gemset specific to the project as well. It's a cool feature if you have multiple projects that require different versions.
I am trying to fix my RVM. Last week everything was working fine but today for some reason my rails commands are not working. For example, if I try:
rails new blog
I get this error:
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require': cannot load such file -- rails/version (LoadError)
Is this because my ruby version is outdated? does anyone know how I could fix this? I looked all over and only found the rvm get stable command however that did not fix my issue. Thank you to anyone that knows what is going on here.
Sorry for the bad formatting, here you go.
here is ruby -v:
`
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
here is the error I get with rails -v:
/home/tyrel/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require': cannot load such file -- rails/version (LoadError)
here is rvm list:
rvm rubies ruby-1.9.3-p448 [ x86_64 ] ruby-1.9.3-p484 [ x86_64 ] =* ruby-2.0.0-p247 [ x86_64 ] ruby-2.0.0-p353 [ x86_64 ] # => - current # =* - current && default # * - default
thanks for the help but upon further research I found what I needed to do.
First I ran:
gem pristine --all
Then I found another post on here that recommended trying this:
You need to run the follow
user$ source ~/.rvm/scripts/rvm
then run this
user$ type rvm | head -n 1
and if you get
rvm is a function
the problem is solved.
You also need to run user$ rvm requirements to see dependency requirements for your operating system
Source: https://rvm.io/rvm/install/
I forget mention that you need to put this code into you ~/.bashrc or ~/.zshrc file and you will not need to write this code again. Cheers! -Jorge Garcia
After all that my RVM was fixed, and I can use my rails new projectname command.
Thanks for all the help community!!!<3
I have been using RVM for almost a year now without a problem, but suddenly it started to behave odd a day ago. First of all I wasn't able to enter the Rails console or server - it just told me that it couldn't be found anywhere. After running bundle install it fetched all Gems again as if none of them had been installed previously. This worked until I restarted my machine - after that I had to bundle again.
I am not aware of changing anything in the system that could trigger this kind of behaviour. Did anybody experience something like it before?
I am running the latest stable RVM release on Ubuntu 13.10
Try the following:
rvm list
You should see something like this:
ruby-2.0.0-p0 [ x86_64 ]
=* ruby-2.1.0-preview1 [ x86_64 ]
The =* indicates ruby-2.1.0-preview1 is my current and default ruby version.
Try switching to another ruby version, in my case:
rvm use ruby-2.0.0-p0
the rvm list command should now yield ( => means current, * default):
=> ruby-2.0.0-p0 [ x86_64 ]
* ruby-2.1.0-preview1 [ x86_64 ]
What's happening with you is probably that rvm is switching versions when you reboot. You might want to set the version you want to use as default, in my case:
rvm use ruby-2.0.0-p0 --default
rvm list
=* ruby-2.0.0-p0 [ x86_64 ]
ruby-2.1.0-preview1 [ x86_64 ]
Every time I open a new terminal in Mac OSX Lion, rails isn't loaded. This is after I upgraded to ruby 1.9.3 and rails 3.2 - so I was doing a lot of configuring but not sure what I've screwed up. It used to work fine.
If I load a new terminal on startup, and type:
rvm
that works.
If I type
ruby -v
I get the correct (1.9.3)
but if I type rails -v, I get an error saying:
/Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [rake-0.9.2.2, rake-0.9.2] (Gem::LoadError)
from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1208:in `gem'
from /usr/bin/rails:18:in `<main>'
If I type:
rvm use 1.9.3p0#rails32 --default
That makes rails work as normal, but only in that terminal window -even a new tab in terminal, rails gives errors - how do I get it to accept that gemset/config as the global default whenever I start up? I have:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
in my .bash_profile.
What have I done to my config / missed in my upgrade? It seems like something simple, but I'm not spotting it.
I just switched my own default rvm by using the command rvm 1.9.2-p290#mybranch --default (not that I didn't have 'use' in the command)
Then, if you open a new terminal window or tab and type rvm list you should see a => next to the ruby version it's using. I see this:
ree-1.8.7-2010.02 [ x86_64 ]
ruby-1.8.7-p302 [ x86_64 ]
ruby-1.9.1-p378 [ x86_64 ]
ruby-1.9.2-p0 [ x86_64 ]
ruby-1.9.2-p136 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
=> ruby-1.9.2-p290 [ x86_64 ]
I like to see which rvm version and gemset I'm using next to my command prompt. In your .bash_profile right before the line you listed that loads the RVM function, add this:
PS1="\$(~/.rvm/bin/rvm-prompt i v g s) $PS1"
Which prepends this to my prompt: ruby-1.9.2#myapp
rvm 1.9.3-p0#rails32 --default only set it working for the current terminal window, once I added another or exited and came back it was back to not working.
I fixed this by adding a .rvmrc file to my app directory. It now loads the gemset & ruby version correctly.
As per:
http://seanbehan.com/mac-os-x/installing-and-using-rvm-on-mac-os-x-creating-gemsets-and-reverting-to-original-environment/
I know how to use RVM, but now I have a weird problem, which I do not understand why.
Here is the simple story (I am using Ubuntu):
I have created a Rails project, the direcotry of this project is "bookstore/".
I go to project directory by cd bookstore , and type command rvm list like following:
bookstore/$ rvm list
rvm rubies
ruby-1.9.2-p136 [ i386 ]
ruby-1.8.7-p352 [ i386 ]
ruby-1.8.7-p330 [ i386 ]
ruby-1.8.6-p420 [ i386 ]
ruby-1.9.2-p290 [ i386 ]
Since I did not see the => arrow sign which is supposed to indicate the current ruby version in use, so I specify the ruby version with the following RVM command:
bookstore/$ rvm use ruby-1.9.2-p290
Using /home/usr/.rvm/gems/ruby-1.9.2-p290
Now, if I rvm list I see my project is using ruby v1.9.2 :
bookstore/$ rvm list
rvm rubies
ruby-1.9.2-p136 [ i386 ]
ruby-1.8.7-p352 [ i386 ]
ruby-1.8.7-p330 [ i386 ]
ruby-1.8.6-p420 [ i386 ]
=> ruby-1.9.2-p290 [ i386 ]
Every thing works fine at this point!
But, if now I open a new terminal window on Ubuntu, and cd to the project directory, and run the command rvm list again, I got:
bookstore/$ rvm list
rvm rubies
ruby-1.9.2-p136 [ i386 ]
ruby-1.8.7-p352 [ i386 ]
ruby-1.8.7-p330 [ i386 ]
ruby-1.8.6-p420 [ i386 ]
ruby-1.9.2-p290 [ i386 ]
Where is the => to indicate the ruby version I specified previously? Why it again needs me to specify the ruby version?
It happens always when I open a new terminal window. How to have my project "remember" the ruby version I have specified?
Dave is right, you should set a default. But also, look into defining an .rvmrc file on a per-project or per-machine basis. I use project-specific rvmrc files, so I can use different rubies and gemsets for each project, and changing into the directory automatically switches to that project's ruby/gemset.
For example, my rvmrc for company site project:
brett#bender:~/Sites/bearded/bearded(master)$ cat .rvmrc
rvm 1.9.3#bearded
Edit: For explicitness' sake, to solve your problem using an rvmrc file, do the following (assuming you already installed the ruby version you want and created a gemset for this project's gems):
Create a file in bookstore/ directory named .rvmrc (in your favorite editor)
Add rvm ruby-1.9.2-p290 to the file and save it (you can use rvm ruby-1.9.2-p290#gemset_name if you have a gemset you want to default to)
Change directory out of your bookstore directory, then change back into it.
RVM should ask you if you want to trust this .rvmrc file (yes)
RVM should have automatically switched your active ruby and gemset to the ones specified in your rvmrc file for that project.
Also note that if your RVM is older than version 1.8.0 you will need to turn on rvmrc file support (versions 1.8.0+ have it turned on by default). The link at the top of my question contains instructions if you're so inclined.
You need to set the default.
rvm --default 1.9.2-p290 # Or whichever.
A new shell is a new environment; it will not (normally) inherit from already-opened terminals
For per-project settings, use a .rvmrc file in the root of your project, for example:
rvm --create gemset use 1.9.2-p0#my_project
The --create will create the gemset if it does not already exist, handy if you or others work on the same project across machines.