I installed rails 4 beta1 to try out. now, I am trying to create a new rails 3.2 app using rails version hack but it doesn't work.
$ gem list rails
*** LOCAL GEMS ***
rails (4.0.0.beta1, 3.2.13, 3.1.0)
$ rails -v
Rails 4.0.0.beta1
$ rails _3.2.13_ demo
/home/gaurish/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems.rb:317:in `bin_path': can't find gem rails (["3.2.13"]) with executable rails (Gem::GemNotFoundException)
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/rails:19:in `<main>'
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /home/gaurish/.rvm/gems/ruby-2.0.0-p0
- RUBY EXECUTABLE: /home/gaurish/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/gaurish/.rvm/gems/ruby-2.0.0-p0
- /home/gaurish/.rvm/gems/ruby-2.0.0-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => 1
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri --verbose"
- REMOTE SOURCES:
- http://rubygems.org/
what is wrong, how do I fix this so I can have both rails 4 & rails 3.2 installed at the same time?
Update your rubygems to 2.0.3
gem update --system
and don't panic! It's just Rails 3
rails _3.2.13_ new demo
Had the same problem earlier today.
Removing rails 4.0.0.beta1 and reinstalling it, then using rails _3.2.13__ as stated in your question solved the issue for me.
Related
I wanted to start a new rails project and decided to upgrade my Rails and Ruby versions.
I started by upgrading Rails to 6.1.4 and later upgraded Ruby to 3.0.2
Before creating my new app I decided to check once more the version of Rails running and I had this error:
$ rails -v
Traceback (most recent call last):
2: from /Users/el/.rbenv/versions/2.6.5/bin/rails:23:in `<main>'
1: from /Users/el/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/Users/el/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)
I tried the create new rails app command and had the same error as below;
$ rails new tracking-app-api --api --database=postgresql
Traceback (most recent call last):
2: from /Users/el/.rbenv/versions/2.6.5/bin/rails:23:in `<main>'
1: from /Users/el/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/Users/el/.rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)
I ran the command $ gem update --system and currently have:
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.3
- RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/el/.rvm/gems/ruby-3.0.2
- USER INSTALLATION DIRECTORY: /Users/el/.gem/ruby/3.0.0
- RUBY EXECUTABLE: /Users/el/.rvm/rubies/ruby-3.0.2/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/el/.rvm/gems/ruby-3.0.2/bin
- SPEC CACHE DIRECTORY: /Users/el/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/el/.rvm/rubies/ruby-3.0.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/el/.rvm/gems/ruby-3.0.2
- /Users/el/.rvm/rubies/ruby-3.0.2/lib/ruby/gems/3.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/el/.rvm/gems/ruby-3.0.2/bin
- /Users/el/.rvm/gems/ruby-3.0.2#global/bin
- /Users/el/.rvm/rubies/ruby-3.0.2/bin
- /Users/el/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/el/.rvm/bin
But I keep having the same error. I am using macOS Mojave version 10.14.5
Thanks for your help.
I ran gem install rails and it fixed the issue. This is because I upgraded Rails before upgrading Ruby and as such my gem file did not have the rails gem. So I think it is advisable to always upgrade Ruby before upgrading Rails.
Try this:
bundle install --path vendor/bundle
I am trying to install the latest version of Globalize gem - the only one compatible with Rails 5. To do that I have to install it from Github. So I added the following line to the Gemfile as suggested by the Readme file:
gem 'globalize', git: 'https://github.com/globalize/globalize'
bundle install command is performed smoothly. But, globalize gem is not shown in gem list (I think all gems installed from Github does not show as well) but is shown in bundle list.
When I run bundle exec irb then require 'globalize' works fine. But it doesn't work in rails console. Why? How can I make the gem available for rails?
> rails c
2.4.0 :001 > require 'globalize'
LoadError: cannot load such file -- globalize
from (irb):1
> gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.12
- RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/wael/.rvm/gems/ruby-2.4.0#rails5
- USER INSTALLATION DIRECTORY: /Users/wael/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/wael/.rvm/rubies/ruby-2.4.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/wael/.rvm/gems/ruby-2.4.0#rails5/bin
- SPEC CACHE DIRECTORY: /Users/wael/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/wael/.rvm/rubies/ruby-2.4.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/wael/.rvm/gems/ruby-2.4.0#rails5
- /Users/wael/.rvm/gems/ruby-2.4.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/wael/.rvm/gems/ruby-2.4.0#rails5/bin
- /Users/wael/.rvm/gems/ruby-2.4.0#global/bin
- /Users/wael/.rvm/rubies/ruby-2.4.0/bin
- /Users/wael/.rvm/bin
....
rvm version is 1.29.2.
I couldn't find globalize gem in /Users/wael/.rvm/gems/ruby-2.4.0#rails5.
Update:
> rvm gemset list
gemsets for ruby-2.4.0 (found in /Users/wael/.rvm/gems/ruby-2.4.0)
(default)
global
=> rails5
I found this to resolve the issue for me:
> bundle exec rails console
I want to install rails 3.2.1 on ubuntu 11.10.
I already installed rbenv, ruby-build.
When I run
gem install rails
it tells me
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
then after rbenv rehash, if I run "rails", it cannot find the binary file. So I guess rails is NOT installed. How can I do?
edit:
~ » gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /home/jafar/.rbenv/versions/1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- /home/jafar/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
edit 2 :
gem list tells me the rails gem is installed. When I search for the rails binary I find this :
~ » find . -name rails
./.oh-my-zsh/plugins/rails
./Downloads/robbyrussell-oh-my-zsh-3629270/plugins/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/guides/code/getting_started/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/bin/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/app/templates/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/plugin_new/templates/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/test/dummy/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/scss_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/sass_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/sass/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/actionmailer-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jquery-rails-2.0.0/lib/jquery/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-3.1.12/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin/rails
The rails binary should be in ~/.rbenv/shims but it's not. ~/.rbenv/shims is in my PATH
You need to add the bin subdirectory of /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1 to your PATH, e.g. edit your ~/.bashrc file and add this line at the end:
export PATH=/home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin:$PATH
And then see what the command rails --version will output.
My rails application is working well under my user:
$ rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on htttp://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-03-30 01:56:29] INFO WEBrick 1.3.1
[2011-03-30 01:56:29] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0]
[2011-03-30 01:56:29] INFO WEBrick::HTTPServer#start: pid=3899 port=3000
But I need to run it under port 80, so running it as sudo gives me this:
$ sudo rails server -p 80
/Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin/rails:18:in `<main>'
More info:
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
$ sudo ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
$ rails -v
Rails 3.0.5
$ sudo rails -v
/Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin/rails:18:in `<main>'
$ gem list --local rails
*** LOCAL GEMS ***
rails (3.0.5)
$ sudo gem list --local rails
*** LOCAL GEMS ***
rails (3.0.5)
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ sudo gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Any idea of what's going on?
How can I make it work with and without sudo?
RVM is preventing sudo from seeing the Rails binary.
To get around this, use rvmsudo:
> rails -v
Rails 2.3.11
> sudo rails -v
/Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /Users/dan/.rvm/gems/ree-1.8.7-2010.02#crm/bin/rails:18
> rvmsudo rails -v
Rails 2.3.11
You are using Rails 3, which uses Bundler, which installs gems on a per-user basis, so before you can run the app as a given user, you must first run bundle install while logged in as that user. I think that will make it work for you.
By the way, I assume you know that running anything as root is risky. You probably want to configure Apache and Passenger (or something like that) to serve up your Rails application over port 80.
So this happens to me regularly, where i have gems that are installed but for some reason my rails app is not finding it...here is my example
my config/environment.rb
config.gem "whenever"
my install
sudo gem install whenever
Password:
Successfully installed whenever-0.6.2
1 gem installed
gem list | grep when
whenever (0.6.2)
script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
Missing these required gems:
whenever
You're running:
ruby 1.8.7.174 at /usr/local/bin/ruby
rubygems 1.3.7 at /Users/matt/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8
- /Users/matt/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- http://gemcutter.org
$ which gem
/usr/local/bin/gem
$ which ruby
/usr/local/bin/ruby
Does anybody see the issue because i clearly cant even start my server and i know the gem is installed. I am on a macbook pro with Snow leopard by the way...
Please check you ruby and gem installation :
May be use these commands
which ruby
which gem
and make sure they have the correct path.
Most times people have these problems is that "gem" command installs gems into a different ruby installation instead of the one used by your rails app.
I had two different 1.9.x ruby versions, and I had installed rvm.
All the gems installed through rvm were not showing up.
Basically my "which gem" was showing /usr/bin/gem while it was supposed to be "/home/gh/.rvm/rubies/ruby-1.9.x/bin/gem"
If such is the case, in your gnome-terminal, under Edit > Profile Preferences > Title and Command, check the option "Run command as a login shell"
This integrates rvm with gnome-terminal :) Hope this helps someone who faced the same issue as I did.
Reference: https://rvm.io/integration/gnome-terminal