I have installed ruby on rails following the 310 railcasts on railcast.com. Now I was able to run and create a new rails and run it using rail s. The issue comes as soon has I close the terminal and restarted it i get the following error
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Here ruby version
ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]
if i do rails -v i get following
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
whereis rails
rails:
gem environment gives me this
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
- INSTALLATION DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286
- RUBY EXECUTABLE: /home/john/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
- EXECUTABLE DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/john/.rvm/gems/ruby-1.9.3-p286
- /home/john/.rvm/gems/ruby-1.9.3-p286#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I also believe the answer his the path and seem to the same has this questions Installed Rails but the rails command says it's not installed. But i do not know how to place the path. Any help would be appreciated
try to type rvm -v, if an error occurs, you have a problem with your rvm installation, if so try to source your shell configuration file ie if you are using bash on a mac : "source ~/.profile"
I am using Mac OSX, and in my .bashrc which is under my home directory.
There is a line :
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
By the way, you should tell the rvm to use 1.9.3 of ruby by the command rvm use 1.9.3
Your problem could be the thing that rvm switches between your ruby versions and when you restart the terminal it is not the old ruby version that you were using before exiting. So one solution can be. You create ".rvmrc" file in your rails application folder and inside you put just one line:
rvm use 1.x.x
where 1.x.x is the ruby version that you will use. Once you have gem rails in this version it will always work for you. This file simply tells which ruby shell be used when you work in your aplication direcotry
#user1022209 your solution will also work if the problem is with the ruby version but the point is that you always have to set ruby when your enter your folder and this can somethimes be anoying. I think that the best way to set default ruby version is using .rvmrc file.
3 lines of writing:
vim .rvmrc #creates new file, after which you have to press "i" for Insert mode
rvm use 1.x.x #contains only this line inside after which you press "ESC" and you type
:wq or :wq!
Finally press Enter and you are
done forever :)
Hope it will solve your problem
gem install rails
Do not sudo or apt-get when installing Rails with an installation of Ruby that was compiled from source. You may need to remove the Rails package first since you have already attempted to install it using the apt-get package manager.
apt-get remove --purge rails
apt-get clean
Related
Using ubuntu 10.04, rvm. At first, I've installed ruby 1.9.2 with rvm, gem rails and generated some new project and started it successfully. Everything was working fine. But after changing to another project, executing bundle install command (output looks OK) and starting rails server - error occurs:
rails s
/home/jacek/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/site_ruby/1.9.1/rubygems.rb:316:in `bin_path': can't find gem rails ([">= 0"]) with executable rails (Gem::GemNotFoundException)
from /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin/rails:19:in `<main>'
gem list rails
*** LOCAL GEMS ***
rails (3.2.2)
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.18
- RUBY VERSION: 1.9.2 (2012-02-14 patchlevel 318) [i686-linux]
- INSTALLATION DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318
- RUBY EXECUTABLE: /home/jacek/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
- EXECUTABLE DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/jacek/.rvm/gems/ruby-1.9.2-p318
- /home/jacek/.rvm/gems/ruby-1.9.2-p318#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
My Path (includes EXECUTABLE DIRECTORY: /home/jacek/.rvm/gems/ruby-1.9.2-p318/bin )
/home/jacek/.rvm/gems/ruby-1.9.2-p318/bin:/home/jacek/.rvm/gems/ruby-1.9.2-p318#global/bin:/home/jacek/.rvm/rubies/ruby-1.9.2-p318/bin:/home/jacek/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
I would be grateful for any help
For me just installed bundler. This makes everything work again.
gem install bundler --no-ri --no-rdoc
If you use the command bundle install to install your gems off of a GEMFILE, it will install the gems into your default system location for gems, as outlined in the bundler docs here. After that, you can use bundlers bundle exec command to execute a command in the context of the bundle, as outlined in the docs here. This will ensure that the version of the gem you installed using bundle install is executed.
If you look at the homepage for bundler, which provides an overview of the docs, it states the following:
In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.
However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
I'm guessing that you run gem which rails in your console, and then run bundle show rails in your console, the default installed rails installation for your system differs from the one installed for your bundle.
You say that you are using rvm for your ruby and gem management. I'm thinking you may not have properly configured it. Trying executing the rvm notes command in your console to ensure that you have addressed all of the required/recommended steps for installation on your OS. You want to ensure that the executables for rvm are the first things included in your path when you run echo $PATH ideally. This will ensure that the gems installed for rvm will be the ones executed when you try executing them without prefixing bundle exec. If rvm notes doesn't give you the hints necessary to accomplish that, then try carefully reviewing the docs for installation on the RVM website.
You can switch version between Ruby with $ rvm use --default 2.4.0 for example
But for your problem try this :
$ gem install bundler
$ gem install rails
Hope it helps !
I think below command will work
gem pristine rails
issue => can't find gem rails - Gem::GemNotFoundException
Solution for Mac M1 Chip
Remove Gemfile.lock
run rm Gemfile.lock
run bundle install
run pod update && pod install
After installing rvm, updating .gmrc file, updating rubygems and running gem install rails -v ">=3.1.0rc", I now seem to have a complete mess:
$ rails -v
/usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [] (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1182:in `gem'
from /var/lib/gems/1.8/bin/rails:18
myhome#myhome-mini:~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/myhome/gems
- RUBY EXECUTABLE: /home/myhome/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/myhome/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/myhome/gems
- /usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gemhome" => "/home/myhome/gems"
- "gempath" => ["/home/myhome/gems", "/usr/lib/ruby/gems/1.8"]
- REMOTE SOURCES:
- http://rubygems.org/
I've had a similiar problem. Not sure if that helps you, but you might try to install gems with rvmsudo gem install [gemname] instead of just doing gem install [gemname] or sudo gem install [gemname].
I try to explain this a bit because of the upvotes:
This basically is a path issue. If you set up gems via gem install, they mostly likely will be in another directory (e.g. /usr/local/) compared to gems set up via bundler (where you can override it with --path). Using sudo may also set them up into another directory since sudo starts a subshell which has a different environment then. This is why you have rvmsudo.
If you want to see the differences, compare $PATH, $GEM_HOME, $GEM_PATH and $BUNDLE_PATH when echoing directly, with sudo and with rvmsudo.
I had to sudo gem install bundler to make it work again.
I got a problem similar to this, there may be a compatible problem of rvm.
I fixed by updating rvm to latest version:
curl -L https://get.rvm.io | bash -s stable --ruby
Then you should reload rvm or just open new terminal window.
Then I reinstalled the bundler 'gem install bundler' and ran 'bundle install' as normal
rvm rubygems current
did the trick for me.
remove ruby first
then
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
to install all needed lib
then you could install ruby and rails
rvm install 1.9.3
rvm --default use 1.9.3
rvm gem install rails
I had pretty much the same message when trying to generate a controller after installing IntelliJ IDEA and the associated Plugin for Rail Dev. From my app directory I just executed bundle install and was then able to generate controllers again.
I know this is a really old question but I just recently decided to move to RVM on a server I had setup a while ago and was having this same problem where gems were being installed in the wrong place and it was just messing everything up.
After a few hours of crawling through SO, I finally figured out that in my .gemrc file in my root folder, I had previously setup the gemhome: and gempath: variables and they were messing with the whole system.
After removing these lines, all my gems were working property.
Just thought I would post my answer in case someone was in the same position.
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. :)
I am having problems with conflicting versions of Ruby that I have installed. I had 1.8.6 and then installed 1.8.7 and it has caused problems. I get the following error when trying to run my ruby on rails app:
/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version (1.8.6) doesn't match executable version (1.8.7) (RuntimeError)
I would like to remove 1.8.7 somehow and just use 1.8.6 but have no idea how to go about doing this.
Ran into this same issue and thought I'ld share my findings. There was a 1.8.7 ruby version installed by an rpm (centos 6.3), and I compiled 1.9.3 from sources and put it in a directory /opt/upnxt/ruby. I changed my environment to:
export PATH=/opt/upnxt/ruby/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
export LD_LIBRARY_PATH=/opt/upnxt/ruby/lib64
export RUBYPATH=/opt/upnxt/ruby/bin
export RUBY_HOME=/opt/upnxt/ruby
export RUBYLIB=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux
export GEM_HOME=/opt/upnxt/ruby/lib64/ruby/1.9.1
export GEM_PATH=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/gems/1.9.1
and then when running:
$ ruby /opt/upnxt/ruby/bin/gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/upnxt/ruby/lib64/ruby/1.9.1
- /opt/upnxt/ruby/lib64/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
When running without the 'ruby' command in front, I would get:
$ /opt/upnxt/ruby/bin/gem environment
/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31:in `require'
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31
from /opt/upnxt/ruby/bin/gem:8:in `require'
from /opt/upnxt/ruby/bin/gem:8
because of the default #!/usr/bin/ruby as stated earlier. I guess that's why one should use "#!/bin/env ruby" as a shebang instead (or "#!/usr/bin/env ruby")
If someone can tell me how to change the "RUBY EXECUTABLE" from the "gem environment" output so I won't need to specify it on the commandline, I would be grateful
cheers,
Gerrit
Yes, setting the path:
export PATH=yourrubypath/bin:$PATH
should do it.
I recommend you install rvm, that way you can run different ruby versions and manage gem sets in a very easy way
The installation instructions are here. However it basically reduces to:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then you can install a newer ruby from source (it will compile it!):
$ rvm install 1.9.1 ; rvm 1.9.1
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
$ which ruby
/home/you/.rvm/ruby-1.9.1-p243/bin/ruby
You can go back to the "system" one doing:
$ rvm system
Just change your $PATH to point to the version you want.
I install ruby from the tarball (and not from the distribuition package). This way I can have several different versions working at the same time, I have just to update the $PATH in the session that I want to use a different version.
Your easiest path and future proof too would be using rvm. Download the version of ruby you want with rvm and make it the default.
Installation: http://rvm.beginrescueend.com/rvm/install/
Making it default:
rvm 1.8.6 --default
The whole process would take not more than 15 minutes. Everything is clearly explained in this. Your environment will be set before you finish watching this podcast:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm
I just set up a fresh Mac OS X 10.5 environment for Rails. I installed Ruby 1.8.7, renamed the packaged version of Ruby in /usr/bin, and updated the packaged version of RubyGems from 1.0.1 to 1.3.4. Here's the flow:
$ rails -v
Rails 2.3.4
$ gem -v
1.3.4
$ which gem
/usr/bin/gem
$ whereis gem
/usr/bin/gem
$ which rails
/usr/bin/rails
$ whereis rails
/usr/bin/rails
$ /usr/bin/gem -v
1.3.4
$ /usr/bin/rails -v
Rails 2.3.4
$ rails testapp
...
...
testapp $ script/console
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
The thing is I've updated RubyGems and didn't install another version of it. gem list rails displays two versions of Rails (2.3.4 and 1.2.6), though.
How can I fix this so I can use Rails?
One suggestion is to not change the system versions, instead install in /usr/local or use MacPorts.
The guys over at HiveLogic cover Rails, as well as MySQL and other development tools.
Using these techniques i've successfully installed rails into /usr/local Then it's a simple matter of adjusting the path settings in your terminal shell via (export PATH=/usr/local/bin:$PATH)
Have you tried:
sudo gem update --system
That should get you the latest version of rubygems, which is something like 1.3.5.
Rails will tell you the version of RubyGems you have if it's loading an incompatible version. The error message you're getting means it can't load RubyGems at all, so I'm thinking it's a path issue.
What do you get from $: in irb? Is there a rubygems.rb in any of those locations?
Make your life easier and use Macports instead of trying updatre and repalce the core system libraries. :-)
I second that emotion and, if I could, would up-vote the answer from prodigitalson -- MacPorts is your friend... Recommend you run specifically:
$ sudo port install rubygem
$ gem install rails
Key is making your which ruby and your rubygems which gem in synch. and in harmony...both should be in /opt/local/bin/
So Ruby on Rails 2.3.8 working on my MacOS 10.5.8 - and the gem environment no longer lies after the MacPorts install and reports the correct version, 1.8.7.
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-9
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/saleram/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Though the question is rather old, and comments stale, current searchers may find that these instructions:
Installing Rails on Mac OS X 10.6 (SL)
work fine for installing Ruby / Rails 3 on new OS X 10.6 installs, GIVEN that you install a recent version of RubyGems:
http://rubyforge.org/frs/?group_id=126
... particularly, do this in place of typing
sudo update_rubygems
in the first of my links
Had the same problem, here's what I did that solved it:
First, update gem
gem update --system
Navigate to the primary path in gem env, in my case /Library/Ruby/Gems/1.8
cd /Library/Ruby/Gems/1.8
Then, navigate to the gem itself:
cd gems/rubygems-update-1.3.5
Run setup.rb
sudo setup.rb
And that's it.
Have you considered BitNami Rubystack as an alternative? It is a free installer that provides a out-of-the-box Rails environment with MySQL (and a bunch of preconfigured, commonly used third-party libraries and apps). Please note I am one of the contributors to RubyStack, so I am biased. It is free and distributed under the Apache 2.0 open source license