Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails commands in home directory result in "i18n gem is not available" error

I was in my Ubuntu home directory, trying to create a new rails app with rails new, but I got this error:

The i18n gem is not available. Please add it to your Gemfile and run bundle install

Any rails command I run gives that error. I'm really confused, because I'm not inside an application. I'm just in my home directory. There is no gemfile. I tried installing 'i18n' into my home directory with gem install 'i18n', and it worked, but I'm still getting that error.

I've never had any problems with rails commands in my home directory before. Everything rails-related works normally when I cd into my individual apps. What's going on?

Also, I'm now getting the same error in all my existing rails apps. Did rails suddenly become reliant on that gem? Or could deleting the gem in my home directory somehow have made it unavailable in my apps?


UPDATE

I tried gem cleanup rails and reinstalling, but nothing changed. Here was the result:

$ gem cleanup rails
  Cleaning up installed gems...
  Attempting to uninstall rails-4.0.10
  Successfully uninstalled rails-4.0.10
  Attempting to uninstall rails-4.2.1
  Successfully uninstalled rails-4.2.1
  Attempting to uninstall rails-4.2.4
  Successfully uninstalled rails-4.2.4
  Attempting to uninstall rails-5.0.1
  Successfully uninstalled rails-5.0.1
  Attempting to uninstall rails-5.0.2
  Successfully uninstalled rails-5.0.2
  Attempting to uninstall rails-5.0.3
  Successfully uninstalled rails-5.0.3
  Attempting to uninstall rails-5.0.4
  Successfully uninstalled rails-5.0.4
  Clean Up Complete
$ gem install rails -v 5.0.1
  Fetching: rails-5.0.1.gem (100%)
  Successfully installed rails-5.0.1
  Parsing documentation for rails-5.0.1
  Installing ri documentation for rails-5.0.1
  Done installing documentation for rails after 1 seconds
  1 gem installed
$ rails -v
  The i18n gem is not available. Please add it to your Gemfile and run bundle install

UPDATE 2

I had previously manually installed i18n and I thought that might be the problem so I uninstalled both rails and i18n and reinstalled rails. But I'm still getting the error:

  $ gem uninstall rails --all

You have requested to uninstall the gem:
    rails-5.0.1

browser-2.3.0 depends on rails (>= 0, development)
browser-1.1.0 depends on rails (>= 0, development)
browser-0.9.1 depends on rails (>= 0, development)
carrierwave-1.2.1 depends on rails (>= 4.0.0, development)
carrierwave-1.0.0 depends on rails (>= 4.0.0, development)
rails_serve_static_assets-0.0.5 depends on rails (>= 3.1, development)
rails_serve_static_assets-0.0.4 depends on rails (>= 3.1, development)
sass-rails-4.0.5 depends on rails (>= 0, development)
sunspot_rails-2.2.7 depends on rails (>= 3)
twitter-typeahead-rails-0.10.5 depends on rails (>= 3.1, development)
yaml_db_improved-1.0.1 depends on rails (>= 0)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled rails-5.0.1

  $ gem uninstall i18n --all

You have requested to uninstall the gem:
    i18n-0.9.1

activesupport-5.1.4 depends on i18n (~> 0.7)
activesupport-5.0.5 depends on i18n (~> 0.7)
activesupport-5.0.4 depends on i18n (~> 0.7)
activesupport-5.0.3 depends on i18n (~> 0.7)
activesupport-5.0.2 depends on i18n (~> 0.7)
activesupport-5.0.1 depends on i18n (~> 0.7)
activesupport-4.2.4 depends on i18n (~> 0.7)
activesupport-4.2.1 depends on i18n (~> 0.7)
activesupport-4.0.10 depends on i18n (>= 0.6.9, ~> 0.6)
capistrano-3.8.0 depends on i18n (>= 0)
capistrano-3.7.2 depends on i18n (>= 0)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled i18n-0.9.1

  $ gem install rails --version 5.0.1

Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: rails-5.0.1.gem (100%)
Successfully installed rails-5.0.1
Parsing documentation for i18n-0.9.1
Installing ri documentation for i18n-0.9.1
Parsing documentation for rails-5.0.1
Installing ri documentation for rails-5.0.1
Done installing documentation for i18n, rails after 4 seconds
2 gems installed

  $ rails -v

The i18n gem is not available. Please add it to your Gemfile and run bundle install
/home/user/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:2278:in `check_version_conflict': can't activate activesupport-5.1.4, alrea
...
like image 400
Joe Morano Avatar asked Jan 14 '18 23:01

Joe Morano


Video Answer


2 Answers

Try gem install rails again. Or gem install rails -v 5.0 to install a specific version.

It appears you somehow don't have rails and it's dependencies fully installed. Perhaps because you reinstalled ruby or installed a different ruby version. If i'm right that's what's going on, just reinstall the latest version of rails or the version you want, and everything needed will be there again.

like image 186
jrochkind Avatar answered Oct 03 '22 22:10

jrochkind


Are you using any version manager, rvm or rbenv? You should use this to prevent any mismatch in installing libraries and ensuring your packages are ordered.

I will suggest you to remove anything Ruby related and install Rbenv first. A quick search with that error, I found it mostly relates to RVM. I could be wrong though but try with Rbenv. Use Rbenv to setup Ruby in your Ubuntu. Here is a link for Rbenv in Ubuntu 16.04

Also, why not try to create a Gemfile and actually add gem 'i18n', '~> 0.7.0'.

Then run bundle install. If it says it is gem locked, use bundle update i18n

What does it say?

And also, what do you get with which -a ruby

like image 27
arjun Avatar answered Oct 03 '22 23:10

arjun