The program 'gem' can be found in the following packages - ruby-on-rails

I'm installing Ruby on Rails on Virtual Box/Ubuntu 13.10. Below are the steps
ruby -v
=> The program 'ruby' can be found in the following packages ... Try: sudo apt-get install
source /my account/...
==> Ok.
\curl -L https://get.rvm.io | bash
=> I've got a message thanking me for using RVM. In case of problems, I should consult their website or twitter.
rvm requirements
==> Requirments installation successful.
type rvm | head -n 1
==> rvm is a function
rvm list known
==> I get a list of ruby's versions
rvm install 2.0.0 -C --enable-shared, --with-openssl-dir=/usr/local
==> Install of ruby 2.0.0 complete. Please consider upgrading to ruby 2.1.0 ...
rvm list
==> rvm rubies
=* ruby-2.0.0-p353 [i686 ]
# => - current
# =* - current && default
# * - current
rvm use 2.0.0#railstutorial_rails_4_0 --create --default
==> ok.
rvm gemset list
==> gemsets for ruby-2.0.0-p353 ...
(default)
global
=> railstutorial_rails_4_0
gem -v
=> The program 'gem' can be found in the following packages:
ruby1.9.1
rubygems
try: sudo apt-get install
Why do I need to install ruby again? I thought I did so in step 7. I've gone over and over the same steps but I don't understand why it keeps telling me to install ruby again.
Thanks for helping

On your Terminal window go to Edit>Profile Preferences>Title and command, and check the box that says "Run command as a login shell". Restart your Terminal and try ruby -v and gem -v now. The versions should come up. If they don't then try re-installing them.

It sounds like the rvm ruby is not actually being used. If you run ruby -v, what do you get? I suspect it will be the message from the system about ruby being available in a package. Are you sure your $PATH is set correctly?
If you run /bin/bash --login and try again what happens?

check what rvm list returns.
I had multiple ruby versions installed but had not selected the ruby version to use.
I did rvm use <ruby_version> --default then ruby as well as gem command worked.

Related

Failed gem install: gem require ruby-2.6.1 but the currently ruby-2.6.1

Show messages errors:
Required ruby-2.6.1 is not installed.
To install do: 'rvm install "ruby-2.6.1"'
ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
rails -v
Rails 5.2.2
First of all, I doubt that RVM may not be updated to support this version of Ruby. As I know the following version is supported, you can version by following command and response should match.
rvm --version
1.29.7
If you have updated version then I will do the following to check if RVM has also the same version of ruby installed.
I will check the content of my project root folder's following file
cat .ruby-version
If it has mention same, as rvm is also complaining that I will run the following command on rvm to check if this ruby is really installed in RVM
rvm list
It will show a list of rubies installed and it should include 2.6.1 in the end. If you can't see this list then you probably need to install using the following command
rvm install "ruby-2.6.1"
If it is showing than can you try the following command and see what result comes
rvm use 2.6.1
If all good, then try the following command to see which ruby is being used
which ruby
response must include .rvm/rubies/ mean you are using .rvm ruby otherwise, you may using the system built in ruby.
Just wrote may help you to diagnos issue.
Are you using rbenv? If so, I'd recommend running rvm implode as described here.
if you are using rbenv
see if you have it available in your list :
rbenv install --list | grep 2.6.1
if not, fetch it
cd ~/.rbenv/plugins/ruby-build && git pull && cd -
now if you try again
rbenv install -l | grep 2.6.1
so just run the installation command:
rbenv install 2.6.1
Downloading ruby-2.6.1.tar.bz2... 08:36:17
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.1.tar.bz2
Installing ruby-2.6.1...
Installed ruby-2.6.1 to ~/.rbenv/versions/2.6.1
now you can use it for global or local projects. if local :
rbenv local 2.6.1

RVM Gemset: Rails is not currently installed on this system

I have latest RVM installed in OX 10.9.
$ rvm rubies
* ruby-1.9.3-p545 [ x86_64 ]
=> ruby-2.1.1 [ x86_64 ]
$ rvm gemset list
gemsets for ruby-2.1.1 (found in /Users/rajveershekhawat/.rvm/gems/ruby-2.1.1)
(default)
global
rails403
rails404
=> rails410
After this i installed rails.
$ gem install rails -v 4.1.0
It got installed. It is also there in correct location within .rvm folder. But when I try using it, system says rails is not installed.
$ 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.
I have tried it twice and still unable to figure out what am I am missing. Please help.
Thanks.
This question is similar but is not helping.
Edits:
$ gem list | grep rails
rails (4.1.0)
sprockets-rails (2.1.3)
$ echo $PATH
/Users/rajveershekhawat/.rvm/gems/ruby-2.1.1#rails410/bin:/Users/rajveershekhawat/.rvm/gems/ruby-2.1.1#global/bin:/Users/rajveershekhawat/.rvm/rubies/ruby-2.1.1/bin:/Users/rajveershekhawat/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Update:
Seems like the rails was not properly installed before. I recreated the gemset and tried to intall rails again but got some error. Then I again emptied the gemset and reinstalled rails with sudo. This resolved the issue.
Try to run:
rvm use ruby-2.1.1#rails410
gem list
Can you find Rails here?
Why did you call sudo gem install rails, cant be this the problem, you do not need to use sudo.

Can't install rails - "File exists # dir_s_mkdir" error

I have had rails installed and almost working. Was working on a solution to another problem with I accidentally closed the bash window. So I reopened it, and now I am unable to use rails at all and it's telling me that rails isn't installed. So I ran gem install rails --no-ri --no-rdocand now I get the following:
ERROR: While executing gem ... (Errno::EEXIST)
File exists # dir_s_mkdir - /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems`
How do I correct this error?
I just removed the broken gems, site_ruby and vendor_ruby symlinks from the /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/ folder and now everything seems to work fine.
I just added a gems/ directory here /usr/local/lib/ruby/ and that solved the issue.
for a temporary solution, you can mkdir -p /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems/2.1.0 to solve.
When you open your bash window (called the "terminal window" or "console"), what folder ("directory") are you in? Find out with:
$ pwd
Navigate to the folder where you created your Rails project using the Unix cd command, for example:
$ cd workspace/learn-rails
If you are using RVM, make sure you have selected the correct gemset:
$ rvm gemset list
gemsets for ruby-2.1.1 (found in ...)
(default)
global
=> learn-rails
Then see if Ruby and Rails are installed:
$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ rails -v
Rails 4.1.0
Refer to the article Install Ruby on Rails for help. If you haven't followed all the steps in the article, you may have problems, especially if you followed some of the inaccurate instructions found elsewhere on the web.
I was recently in this wormhole. It seems like Homebrew's ruby installation has an issue with soft links and uses version 2.1.1. I couldn't "gem install" anything without getting the annoying "File exists # dir_s_mkdir" error. Even tried MacPort and that was a nightmare.
First uninstall ruby via
brew uninstall ruby
or
port uninstall ruby
And follow the instruction on https://rvm.io/rvm/install to install ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
It might then complain about ruby-2.0.0-p353 not installed
To install do:
rvm install ruby-2.0.0-p353
Then run the rvm install script. Your "gem install << whatever >>" should now work
This fixed the issue for me (Homebrew on a Mac, Ruby 2.1.3):
$ brew reinstall ruby
$ brew unlink ruby && brew link ruby
the same issue. I just remove dir_s_mkdir, then pod install. it works for me!

executable ruby1.8 missing

So I was trying to install redmine on an apache2 server on Ubuntu.
Between multiple atemps to install a plugin, I "accidentaly" deleted /usr/bin/ruby1.8.
Now I get this error when I try to launch redmine with ruby2.0 (even after a rvm install 1.8) :
*** ERROR ***: Cannot execute /usr/bin/ruby1.8: No such file or directory (2)
What should I do to have this executable back ?
Thanks for your help
I suspect ruby1.8 was the already installed system ruby; can check with dpkg --get-selections | grep ruby . If this is the case, I would uninstall ruby 1.8 from rvm and then reinstall the system ruby through apt.
Once that's been cleared up, and you have a /usr/bin/ruby1.8 again, check/manage your available rubies through rvm:
rvm list
rvm use <ruby version>
etc.

Ubuntu Installation Error

I had used below mentioned commands to install rails in ubuntu 12.10
sudo apt-get update
sudo apt-get install curl
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install 1.9.3
rvm use 1.9.3 --default
rvm rubygems current
gem install rails
Every steps are doing good, but it works for terminal which we are installing rails. If we exit from the terminal and work on a new terminal then the following error occurs.
The program 'rails' can be found in the following packages: * rails * ruby-railties-3.2 Try: sudo apt-get install
I came through a solution that whenever I open an terminal I would run these cmd
source ~/.rvm/scripts/rvm rvm --default use 1.9.3-p374
Can any one explain why these things happen??
Did you include the init script into your bash_profile/bashrc?
RVM installed by Ruby not working?
I've installed Rails 3.2.9 on my machine with RVM. You can follow this steps:
Install RVM : \curl -L https://get.rvm.io | bash -s stable
Reload shell configuration & test: source ~/.rvm/scripts/rvm
Install Ruby via RVM: rvm install 1.9.2 or rvm install 1.9.3
Choose version Ruby after install: rvm use 1.9.2 or rvm use 1.9.3
Ruby 1.9.2 and 1.9.3 support gem 1.8.25, so you'll install rails: gem install rails -v 3.2.9.
Done.
Note
Reload shell: source ~/.rvm/scripts/rvm and choose version Ruby rvm use 1.9.2 before work with projects.

Resources