I just did this command to install Rails:
gem install rails
And it seems to have run fine and installed things.
Then as I followed this tutorial: http://guides.rubyonrails.org/getting_started.html it said to do this command:
rails new blog
Which I did and it gave me this error:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Any idea why this might be the case? I thought rails was supposed to begin working automagically :)
I did this command:
rvm gemdir
And it gave me this result:
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
- /home/agenadinik/.rvm/gems/ruby-1.9.2-p180#global
Should there be something like this:
EXECUTABLE DIRECTORY: /usr/bin
RVM and apt-get are not compatible; They attempt to solve the same problem of software installation, but in very different ways.
apt-get always installs the software it manages into the system's directories, and you have to be running as root to do so. RVM is designed to install as a user's sandbox, installing into ~/.rvm, isolating everything it installs from the system, but still making it available for the user's code.
Should there be something like this:
EXECUTABLE DIRECTORY: /usr/bin
No, not for a RVM managed Ruby. All RVM managed Rubies and gems should reside in ~/.rvm somewhere.
Use which ruby to see what the system thinks your path to Ruby should be. If RVM is configured correctly, and you've installed Ruby using RVM, the path returned should be:
/home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
If it isn't there's something wrong with the RVM installation and you should check your configuration using the "Troubleshooting your Install" checks on RVM's installation page.
If the working Ruby is correct, type in which rails and you should see a response showing it is in the ~/.rvm sandbox somewhere. If so, try gem list rails. Rubygems should respond with:
rails (3.0.7)
for a current Rails installation. If not, use gem install rails and it should be installed after a couple minutes of churning. Following that, do the gem list rails command again, and you should see it followed by which rails, showing its visible to the system.
A separate issue is it looks like your RVM is out of date, or you didn't use rvm gemdir for the gems output, because rvm gemdir doesn't return that information in the current revision. To update it, use rvm get head, then either use rvm reload or close and reopen your terminal. A subsequent rvm -v should return version 1.6.3, which is current as of today. RVM updates quickly, so be sure to periodically update it for bug fixes. I check several times a week, but weekly should be fine and monthly should be adequate.
My guess is that 'rails' was installed to somewhere which is not in your user path.
You might try to locate rails, but I do not think sudo apt-get install rails will cause the problems you think it will and instead will solve your problem assuming you're okay with using aptitude to install things. It's pretty smarty. :)
Related
I'm trying to setup RoR on my system. I've used the instructions here http://railsapps.github.io/installrubyonrails-mac.html
I'm getting stuck because I was finally able to get Rails installed, but after I set the Ruby version, it won't detect rails anymore
CJs-MacBook-Air:~ cjwheelock$ rails -v
Rails 4.0.1
CJs-MacBook-Air:~ cjwheelock$ rvm use ruby-2.0.0#learn-rails --create
Warning! PATH is not properly set up, '/Users/cjwheelock/.rvm/gems/ruby-2.0.0-p353/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p353'.
Using /Users/cjwheelock/.rvm/gems/ruby-2.0.0-p353 with gemset learn-rails
CJs-MacBook-Air:~ cjwheelock$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
CJs-MacBook-Air:~ cjwheelock$ gem install rails
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
Any help would be greatly appreciated. Hopefully my formatting is readable, its my first time posting here.
Thank you.
Have you tried rvm get stable --auto-dotfiles ?
First restart terminal.
# rvm list
# rvm use 2.0.0-pXXX --default (XXX is the biggest number)
# gem install rails
If you will have some problems, install requirements(openssl, etc... : type below for more infomation)
# rvm requirements
install deb packages
# sudo apt-get install blaaaaaaaa
reinstall ruby 2.0.0
# rvm reinstall 2.0.0
and try first step.
Good Luck
I'm desperate, please help. I can't figure out how to change Ruby on Rails to run with 2.0.0, even though I think I've done everything to set 2.0.0 as the default, and rvm -list doesn't even show 1.8.7 as an option. I don't know what files I need to move/what pathways I need to change, and my attempts to uninstall rails have been unsuccessful as there's a "missingBundle" error.
$ ruby - v
returns ruby 2.0.0p247
$ rvm--default use 2.0.0
Using /Users/ericafischer-colbrie/.rvm/gems/ruby-2.0.0-p247
Then,
$ rails -s
Rails prefers to run ruby 2.0. You're running ruby 1.8.7 (2012-02-08 patchlevel 358)
[universal-darwin12.0]. Please upgrade to Ruby 1.9.3 or new to continue.
I've spent a lot of time looking at similar questions posted on stackoverflow and those solutions so far have not yielded any results.
Since you're using rvm, make sure you create a gemset and ruby-version file and install the version of rails you want to use.
E.g inside you're working dir tell rvm which ruby to use, which gemset to use, create both a gemset and ruby-version file:
rvm use ruby-2.0.0#my_cool_project --ruby-version --create
Then
gem install rails
To check run which ruby in that directory to make sure it's ruby 2 - - which rails will show you that it's using the gem of rails inside the ruby 2 my cool project gemset. Should be ok
Looks like you may have used something like sudo gem install rails.
When installing gems, you want to be sure to not use the sudo command.
Try sudo gem uninstall rails; rvm use ruby-2.0.0#myapp --create; gem install rails
Install rvm in your Macintosh
Then do rvm install 2.0.0 or rvm install version(whatever version you need)
Where ever you need a particular version of Ruby(say 2.0.0), do rvm use 2.0.0 and whichever version you need you can switch similarly.
If you are not sure how to install rvm or stuck with something else. Please see link for detailed explanation.
Updated, thanks #Momer.
I've been fighting with my Mac OS X 10.8 installed version of Ruby and tried to move to a .rvm install in order to keep everything up to date.
After going through all the documentation on the RVM website, here are some outcomes:
~$ which ruby
/Users/localadmin/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
~$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
~$ which rails
/usr/bin/rails
~$ rails -v
-bash: /usr/bin/rails: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
I'm not exactly sure what's causing this. I'm expecting that Rails is trying to use the system Ruby version, which isn't what I set as default in RVM.
I've read that it could be a .gemrc problem, but I can't seem to find a .gemrc file in my home directory. I can't seem to find any references to rails in my .rvm directory, so I'm thinking maybe when I did "gem install rails", "gem" was actually the one affiliated with my system Ruby.
Sorry to answer my own question, and I'd be happy if it gets deleted, but the solution was fairly annoying.
I had been installing rails with:
sudo gem install rails
I guess this took me out of the userspace in which my RVM installation sat
gem install rails
installed rails properly and now I get "Rails 3.2.9" as the outcome to rails -v
Could anyone shine any light on why this happened?
When using RVM, you pretty much NEVER use sudo for anything. The only common exception to this I've found is when installing the Passenger module.
That means all operations you want to perform on or with gems, rubies, rubygems, or RVM itself should NOT be performed with sudo.
Also make sure to do rvm use [RUBY] --default to make certain you're always using a ruby other than the system ones.
I am on a fresh install of OS X Mountain Lion. I have installed rails via:
sudo gem install rails
Everything seems to install correctly, but when I type the rails command (rails s, rails -v, etc), I get this error:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
The result of 'which rails' is /usr/bin/rails
I thought it was a path issue, and perhaps it is, but I can see that /usr/bin is part of my PATH.
Any help? Thanks!
UPDATE: I noticed everything on my other mac with same exact OS works pretty well... I just can't remember how I got it to work that way. If I run 'which rails' I see it's in a totally different place /Users/username/.rvm/gems/ruby-1.9.3-p194/bin/rails
If you're using rbenv, don't forget to rbenv rehash after installing/updating ruby.
Use RVM http://rvm.io or rbenv to install newer Rails versions than what come pre-installed with OS X.
Follow examples on the site https://rvm.io/rvm/install/ but basically:
Install RVM: $ \curl -L https://get.rvm.io | bash -s stable
You can then $rvm list known to see what Rubies are available to you (lots). And simply $rvm install 1.9.3 to get the most current version of Ruby (which as of this writing is ruby-1.9.3-p327)
Set that ruby as your default $rvm --default use 1.9.3
Create a default gemset to store your gems $rvm use 1.9.3#mygemset --create --default
Then install Rails $ gem install rails will get you current which today is same as typing gem install rails -v 3.2.9
Just had this issue using rbenv, no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty...
So to fix this:
Cleaned empty shims: find ~/.rbenv/shims -empty -delete
Then regenerate: rbenv rehash (was not overwriting empty one...)
I had the same problem.
After typing:
sudo gem install rails
and installing rails correctly, just close the Terminal window and open again. Then type:
~ $ rails -v
Rails 4.0.2
So, reseting the Terminal window fix the problem.
I think install rvm that will help you
rvm get head && rvm reload
rvm install 1.9.3
rvm use 1.9.3#current --create --default
The last line creates a gem set called current.
Now check to make sure you RubyGems was installed correctly by typing which gem in your terminal. Now update your gems.
gem update --system 1.8.24
Finally install rails.
gem install rails -v 3.2.3
I hope this works, let me know if you have any issues.
Yes, OSX comes standard with a lot of great software for Ruby on Rails, as well as PHP, Mysql, etc. However, sometimes it's better for sustainment purposes to use a 3rd party installer to get everything you want without digging through your /usr/ directory.
I recommend checking out http://railsinstaller.org/
With one easy install, you have everything you could want for a Rails project, including common software people use, and the site even has a tutorial. I recommend going this way. It saves you time. Plus, it comes with an easy uninstaller that it will put in your Applications folder to remove if you're not happy with the configuration. Enjoy.
Actually, /usr/bin/rails script is just a
# Stub rails command to load rails from Gems or print an error if not installed.
(Comment quoted from the very script's source)
If Rails is installed, then it is loaded. Else, the script will throw the error you pasted in your question.
Yet, another alternative to RVM is the awesome rbenv tool.
It is very easy to install (just a simple brew install rbenv) and work with. In my opinion, it is the best way to manage your rubies on a Mac.
However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode.
Since setting up a fresh ruby on rails dev environment is a common barrier to most newbies (including myself when i started off with rails) I've put together detailed instructions on how to do exactly that in a blog post, which i will link to below. Hope you will find it useful.
http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/
i got the same error and uninstall rvm then i follow the instructions on this page https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
i think that help was
rvm requirements
on the terminal.
Our company uses a script to setup each new machine with a Rails dev environment:
We've open source it, give it a try: https://github.com/platform45/let-there-be-light
After a new
gem install rails
do
rbenv rehash
It worked for me.
I'm using Ubuntu 8.10 and I installed Ruby and Ruby on Rails following the directions on this site. The exact directions I followed are no longer there as it appears the rubyonrails.org wiki has changed recently. But I installed it the long way. Installed Ruby, then Gems, then installed Rails using "gem install rails".
I haven't really messed with Rails for a while, and I tried to use the Gem command today and...
The program 'gem' can be found in the following packages:
* rubygems1.8
* rubygems1.9
Try: sudo apt-get install <selected package>
bash: gem: command not found
That's just weird to me because I installed rails using the gem command. I have been seaching my computer for the gems binary so I could create a link to it in the bin directory but I can't find it. I know it's installed becaues when I run 'script/server' and go to localhost:3000 in a browser I get the following version information:
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.3.1
Rails version 2.2.2
Active Record version 2.2.2
Action Pack version 2.2.2
Active Resource version 2.2.2
Action Mailer version 2.2.2
Active Support version 2.2.2
Anyone know how I can get my gem command working again? Thanks for any help.
Note: I am new to Rails and fairly new to Ubuntu and Linux in general.
Did you install rubygems from apt-get? If yes, maybe you should try to remove it and install it from source.
Here is another article on installing Rails on Ubuntu:
http://www.rubyinside.com/how-to-install-a-ruby-18-stack-on-ubuntu-810-from-scratch-1566.html
Essentially, you can install Ruby from apt-get or source, but it's recommended to install rubygems from source.
You could look to see if it's in:
/usr/bin/gem1.8
if it is, then symlink /usr/bin/gem to it:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
BTW, here's another tutorial on how to install rails on Ubuntu 8.10:
http://articles.slicehost.com/2009/1/6/ubuntu-intrepid-ruby-on-rails