I installed RoR on ubuntu 10, using all kinds so method i could find on internet, either "sudo apt-get" or "sudo gem install", by running 'gem list', i can see they are all the latest version:
*** LOCAL GEMS ***
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
fastthread (1.0.7)
mysql (2.8.1)
passenger (2.2.15)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
rubygems-update (1.3.7)
but when i created a ror application by running 'rails samplecode', then run 'script/about', it always showed:
About your application's environment
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.5
Rails version 2.2.3
Active Record version 2.2.3
Action Pack version 2.2.3
Active Resource version 2.2.3
Action Mailer version 2.2.3
Active Support version 2.2.3
Edge Rails revision unknown
Application root /home/kc/Projects/samplecode
Environment development
Database adapter mysql
why these 2 settings are different? how can i force the application to use the local gems (latest version)? Thanks.
Ubuntu (aptitude/apt-get) installs gems in /var/lib/gems/1.8. When you run gem install manually, you're likely installing them in /usr/lib/ruby/gems/1.8.
Run "gem env" and look at what the gem path(s) is/are.
If you set the GEM_HOME environment variable (GEM_HOME=/usr/lib/ruby/gems/1.8), you can have you application look there.
Alternately, you can install the gems you want (including rails) in your application's vendor directory by putting config.gem lines in environment.rb and running rake gems:unpack:dependencies.
Uninstall the apt-get version of Rails:
sudo apt-get remove rails
And then install Rails again using gem:
sudo gem install rails
Related
Yesterday I updated my Ruby version to 2.6.5 with rbenv, but today I had a problem when I wanted to update Rails to 6.0.2.1.
It didn't work well.
This is what I have:
echo $PATH
/usr/local/opt/ruby/bin:./bin:./node_modules/.bin:/Users/paulinedussart/.rbenv/shims:/Users/paulinedussart/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Users/paulinedussart/.rvm/bin
ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
which ruby
/usr/local/opt/ruby/bin/ruby
I did:
gem install rails
I got:
Successfully installed rails-6.0.2.1
Parsing documentation for rails-6.0.2.1
Done installing documentation for rails after 0 seconds
1 gem installed
then rbenv rehash.
When I ran which rails or which -a rails I got:
/usr/bin/rails
To check if everything was ok I ran rails --version but the result was:
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.
but I did not do that.
Somewhere I saw this instruction
ls `rbenv prefix`/bin
to check if Rails was there but it doesn't appear:
bundle bundler erb gem irb rake rdoc ri ruby
Finally, when I run gem list rails I get:
*** LOCAL GEMS ***
rails (6.0.2.1)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.3.0)
sprockets-rails (3.2.1)
I obviously closed the terminal at a different step of the config but without success.
I'm sure there is a problem with folders but I don't know how to fix this to put the gem rails in the correct one.
Does somebody have an idea?
Try this:
Switch to Ruby 2.6.5:
rbenv global 2.6.5
Install the Bundler gem:
gem install bundler
Install Rails:
gem install rails
Try using: rbenv rehash.
Also you can check "Rails is not currently installed on this system - High Sierra #1106".
I had the same issue and I refered to this issue and found we don't need:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
You just need:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
if you install it via Homebrew.
When I run rails console in my production server with this command
rails c
I get this message:
You must use Bundler 2 or greater with this lockfile.
I checked bundler version:
gem list bundler
And I got this
bundler (2.0.2, default: 1.17.3, 1.16.3)
bundler-unload (1.0.2)
rubygems-bundler (1.4.4)
I read I could set bundler version with this command
bundle _2.0.2_ -v
And I got this message
Bundler version 2.0.2
But I keep getting the same error when running rails console.
Finally, some more information. My Gemfile.lock says I bundled with v2.0.1 (development bundler version). I'm using rvm in production and rbenv in development (not on purpose; I always used rbenv but I inherited an application using rvm in production).
What should I do to run rails console in production server in this situation? Can I uninstall older bundler versions and keep only v2.0.2? Should I updgrade to v2.0.2 in development to have the same versions?
Thanks!
Here are my local gems :
$ gem list
*** LOCAL GEMS ***
actionmailer (4.0.0, 3.2.14)
actionpack (4.0.0, 3.2.14)
activemodel (4.0.0, 3.2.14)
activerecord (4.0.0, 3.2.14)
activerecord-deprecated_finders (1.0.3)
activeresource (3.2.14)
activesupport (4.0.0, 3.2.14)
arel (4.0.0, 3.0.2)
atomic (1.1.13)
builder (3.1.4, 3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.5)
journey (1.0.4)
json (1.8.0)
mail (2.5.4)
mime-types (1.24)
minitest (4.7.5)
multi_json (1.7.9)
polyglot (0.3.3)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.14)
railties (4.0.0, 3.2.14)
rake (10.1.0)
rdoc (3.12.2)
rubygems-bundler (1.2.2)
rubygems-update (2.0.7)
rvm (1.11.3.8)
sprockets (2.10.0, 2.2.2)
sprockets-rails (2.0.0)
thor (0.18.1)
thread_safe (0.1.2)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (0.3.37)
But when I type rails -v I get this :
$ rails -v
Rails 4.0.0
$ which rails
/Users/polonium/.rvm/rubies/ruby-2.0.0-p247/bin/rails
How can I specify rvm to use rails version 3.2.14 ?
Thanks in advance
You can create a new rails app with a particular rails version, like this:
rails _3.2.14_ new myApp
How can I specify rvm to use rails version 3.2.14 ?
rvm has nothing to do with rails. rvm is used to manage multiple ruby installations. And each of your ruby installations can be associated with multiple gemsets. For instance, say you have ruby 1.9.3 installed and you created two gemsets for ruby 1.9.3: gemsetA and gemsetB. If you tell rvm to use ruby 1.9.3 with gemsetA, that means:
Your ruby programs will be executed by ruby 1.9.3.
Your ruby programs can require any gem in gemsetA (which then allows your program to use the methods (or classes) defined in gemsetA), but any gems in gemsetB cannot be seen by your ruby program.
Here's a concrete example:
~$ rvm list
rvm rubies
ruby-1.8.7-p370 [ i686 ]
* ruby-1.9.3-p194 [ x86_64 ]
=> ruby-2.0.0-p0 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
~$ rvm use 1.9.3-p194
Using /Users/7stud/.rvm/gems/ruby-1.9.3-p194
.
~$ rvm gemset list (This lists only the gemsets for the current ruby version)
gemsets for ruby-1.9.3-p194 (found in /Users/7stud/.rvm/gems/ruby-1.9.3-p194)
=> (default)
global
programming
rails3tutorial
rails4
~$ rvm gemset use programming
Using ruby-1.9.3-p194 with gemset programming
After I do that, my ruby programs will be executed by ruby 1.9.3 and any gems in the programming gemset can be required into my ruby program. You can use a shortcut to perform both those commands in one step:
rvm use ruby 1.9.3-p194#programming
You just combine the ruby version and the gemset with an '#' between them.
But when I type rails -v I get this :
$ rails -v
Rails 4.0.0
That's because the current gemset contains the gem for rails 4.0.0. If you want to see $ rails -v output Rails 3.2.14, then you need to tell rvm to switch to a gemset that contains the rails 3.2.14 gem.
However, you can make rvm automatically switch to the proper rails version and gemset for your rails project. In your Gemfile, add a comment after the ruby version:
ruby '2.0.0'
#ruby-gemset=railstutorial4_gems
Then whenever you switch to the directory containing your rails project, rvm will automatically switch the current ruby to ruby 2.0.0 and the current gemset to railstutorial4_gems. If you change directories out of your rails app, rvm will change the current ruby and the current gemset back to what they were.
I'm just a rails beginner, but here are the steps I use to create a new project, which are straight out of the railstutorial book (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book)
1)
.../rails_projects$ rvm use <ruby version here>#<new gemset name here> --create
e.g.
.../rails_projects$ rvm use ruby-1.9.3-p194#myapp_gemset --create
2)
.../rails_projects$ gem install rails --version 3.2.14
Because the current gemset is the myapp gemset, that command installs the rails 3.2.14 gem into the myapp gemset.
3)
.../rails_projects$ rails new myapp
.../rails_projects$ cd myapp
The current gemset is still myapp_gemset.
4)
.../rails_projects/myapp$ rails -v
Rails 3.2.14
In case anyone was wondering what the heck the following two gemsets are all about:
gemsets for ruby-1.9.3-p194 (found in /Users/7stud/.rvm/gems/ruby-1.9.3-p194)
=> (default)
global
rvm creates those two gemsets for every ruby version you install. After you install a ruby version, if you don't create a gemset yourself for that ruby version, and you install a gem, then the gem goes into the (default) gemset. And, if you want all your gemsets to contain a certain gem, you can switch to the global gemset and install the gem there.
Update: -------
To maintain compatibility with other ruby version managers, you can specify the ruby version and gemset name for your project in a different file rather than in the Gemfile:
$ cd ~/rails_projects/myapp
~/rails_projects/myapp$ echo 2.0.0 > .ruby-version
~/rails_projects/myapp$ echo myapp_gemset > .ruby-gemset
You'll still get the same automatic ruby version and gemset switching when you cd into your project's directory. See the rvm docs here.
the path you found /Users/polonium/.rvm/rubies/ruby-2.0.0-p247/bin/rails is not proper path you would found in standard rvm installation while doing proper use of rvm, what you would see should be: /Users/polonium/.rvm/gems/ruby-2.0.0-p247/bin/rails
to get it working properly try this flow:
rvm use 2.0.0
rvm gemset empty
rvm use #rails3 --create
gem install rails -v "~>3.2"
rvm use #rails4 --create
gem install rails -v "~>4"
this way now you can switch between this two rails installations with:
rvm use 2.0.0#rails3
rails -v # rails 3.2...
rvm use 2.0.0#rails4
rails -v # rails 4.0...
you should do: gem install 'rails' -v '3.2.13'
You should use a clean gemset, if you are using rvm, you can try:
rvm gemset create
rvm gemset use
Now you have a clean gemset, it's time to install rails,
gem install rails -v '3.2.13'
and then create a rails app,
rails new app_name
"railties (4.0.0," is the problem you have. I guess it was installed by mistake?
Uninstall that version using, gem uninstall railties, and then picking the option with 4.0.0.
Now the command "rails -v" will return your expected version which is "3.2.14"
Make sure to check the global gemset by first making sure you are in the ruby version you intend to use
$ruby -v
Then switch to the global gemset (the global gemset applys to all of the gemsets so be sure to keep it clean and universal...or global, hence the name)
$rvm gemset use global
After that check the gem list for gems that can affect it like the "railties" gem that Harsha mentioned by typing
$gem list
Sometimes the global gemset can be populated by an accidental gem that will affect all other gemsets. If you find a misplaced gem you can uninstall it simply with
$gem uninstall examplegem
or for a specific version of that gem pass in the -v with the version in quotes
$gem uninstall examplegem -v"3.2.1"
And read 7stud's comment on creating and using RVM for changing between different gemsets.
You could add the version of Rails you want, with:
$ gem install rails --version 3.2.14
And then create an app with that version:
$ rails _3.2.14_ new myapp
Finally, you can check it out the content of the "Gemfile" to corroborate:
...
gem 'rails', '3.2.14'
...
I just installed RoR 3 with sudo gem install rails. I tried this multiple times, but every time I run $ rails I get an error and I hate it:
imac:~ rsonic$ rails
/Users/rsonic/.gem/ruby/1.8/bin/rails:19:in `load': no such file to load -- rails (LoadError)
from /Users/rsonic/.gem/ruby/1.8/bin/rails:19
How can I fix this? I want to use Rails again!
1.Install rvm(Ruby version manager)
sudo gem install rvm
2.Go to install path of rvm and do
rvm-install
3.Check if the install was successful by running
rvm
4.Check for current version of ruby
ruby -v
5.Install ruby 1.9.2 using rvm
rvm install 1.9.2
6.User ruby 1.9.2 with the help of rvm do
rvm 1.9.2
(you can switch back to system's default ruby version by running command >rvm system)
7.Install gems using rvm do
rvm gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
This will install gems locally for ruby1.9.2 without touchin the sytem ruby
8.Install RAILS3 beta release
rvm gem install rails --pre
9.Install railties which are required for RAILS3
rvm gem install railties --pre
10.For generating a new app with RAILS3 skeleton now do
rails myapp
Note all ruby script/ commands have changed to rails *
e.g: RAILS<3
ruby script/server -p 3004
RAILS3
rails server -p 3004
Hope it helps...
$: /Users/dev/.rvm/gems/ruby-1.9.2-head#rails3/gems/sqlite3-ruby-1.3.1/lib/sqlite3/sqlite3_native.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Abort trap
It's seem that ruby is not the correct version (1.8.7) but :
$: ruby - v
$: ruby 1.9.2dev (2010-07-15 revision 28653) [x86_64-darwin10.4.0]
$: gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0.beta4, 3.0.0.beta3)
actionpack (3.0.0.beta4, 3.0.0.beta3)
activemodel (3.0.0.beta4, 3.0.0.beta3)
activerecord (3.0.0.beta4, 3.0.0.beta3)
activeresource (3.0.0.beta4, 3.0.0.beta3)
activesupport (3.0.0.beta4, 3.0.0.beta3)
arel (0.4.0, 0.3.3)
builder (2.1.2)
bundler (0.9.26)
erubis (2.6.6)
i18n (0.4.1, 0.3.7)
mail (2.2.5)
memcache-client (1.8.5)
mime-types (1.16)
polyglot (0.3.1)
rack (1.1.0)
rack-mount (0.6.9)
rack-test (0.5.4)
rails (3.0.0.beta4, 3.0.0.beta3)
railties (3.0.0.beta4, 3.0.0.beta3)
rake (0.8.7)
rdoc (2.5.9)
sqlite3-ruby (1.3.1)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.8)
treetop (1.4.8)
tzinfo (0.3.22)
will_paginate (3.0.pre)
more info :
$: ~ dev$ ruby -v
ruby 1.9.2dev (2010-07-15 revision 28653) [x86_64-darwin10.4.0]
$ :~ dev$ rails -v
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
from /usr/bin/rails:18
Any ideas ?
Thanks very much :)
Had the same issue after moving to 1.9.2p0, but restarting the console on Snow Leopard did the trick. Seems rvm might have gotten confused.
Same problem for me on Snow Leopard; even though under rvm 1.9.2#rails3, I can see correct rails version number.
I have to use following command to use rails command:
ruby which rails g scaffold User name:string bio:text
Any solution?
I've finally found the reason. Looks like gem install rails is not managed to install the proper binary for rails in rvm. And rails is still references /usr/bin/rails, which have a #! line point to System ruby.
You can see it with:
head -1 `which rails`
which returns:
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Change that to:
#!/usr/bin/env ruby
will fix the problem. I don't know if this problem affect other executable scripts gem installs, but why gem not install rails to rvm's own bin path is a mystery to me. Anyway, this workaround do the dirty for me.
I Had the same problem when using ree-1.8.7-2011.03. (Ruby enterprise Edition)
I uninstalled the sqlite3 gems then I ran:
gem install sqlite3
and it worked. Note that the sqlite3-ruby gem now recommends to use 'sqlite3' now.
I don't know how this has happened in your case but it looks to me that Rails has tried to run with your system installed Ruby but is loading gems from a 1.9.2 load path. Very odd.
You see the correct Ruby version in your shell (RVM has precedence in the local path) but that's not apparently what Rails is being started with.
Check to see you how you are starting Rails and that you don't have paths or links or aliases messed up between Ruby versions
You might need to run
rvm reload
Same problem after a bunch of updates (rvm to 1.5.2 and ruby to 1.9.2-p180)
Console restart did not work for me, updating to rails 3.0.6 changed the error to a seg error of mysql2 instead of sqlite3, re-installing mysql2 did the trick for me finally.
Regards
Michael
I encountered this exact error in zsh and MacVim, and eventually tracked it back to this RVM issue. The solution was to move the RVM sourcing I had in .zshrc to .zshenv. Worked immediately. Just posting on the off chance someone stumbles across this the way I did.
There is a known issue with zsh, rvm and vim.
The latest solution is to set the shell to sh in your .vimrc
set shell=sh
This blog has all the solutions listed