Rails - Command "bundle install" can't fetch gems - ruby-on-rails

I always get an error when trying to install all gems of a given app.
$ bundle install --verbose --retry 4
Fetching from: https://bundler.rubygems.org/api/v1/dependencies
Fetching source index from https://rubygems.org/
Resolving dependencies...Fetching from: https://rubygems.org/quick/Marshal.4.8/sass-rails-4.0.3.gemspec.rz
Network error while fetching https://rubygems.org/quick/Marshal.4.8/sass-rails-4.0.3.gemspec.rz
I can fetch the file manually via wget or a web browser, so the network is not an issue !
Installing via the gem command works too but that's a pain.
Can someone help me on this one ? I'm clueless to what could be happening here

I am newbie, learning RoR, Running Mavericks, Trying it using RVM, Ruby version 2.1.2, Rails 4.1.4
When I tried running $ rails server, I was getting the below errors
and I have tried this being in my rails app folder
Network error while fetching
https://rubygems.org/quick/Marshal.4.8/sass-rails-4.0.3.gemspec.rz
$ gem install spring
Could not find gem 'jquery-rails (>= 0) ruby' in the gems available on this machine.
$ gem install jquery-rails
Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.
$ gem install sqlite3
Could not find gem 'sass-rails (~> 4.0.3) ruby' in the gems available on this machine.
$ gem install sass-rails
And for other errors like above I did install them one by one
I couldn't find any solution over the internet, even my system gems are updated. Then as a last resort I did this, installing them one by one.
And it started working

Related

An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue - in rails project

I'm trying to create a project with mysql as a database, ran command
rails new project_name -d mysql
got the following errors
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. rails importmap:install
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. Run bundle install to install missing gems.
rails turbo:install stimulus:install Could not find gem 'mysql2 (~> 0.5)' in locally installed gems.
Run bundle install to install missing gems. "
so i ran
bundle install
but it fails and at the end it tells me
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue
full error https://pastebin.com/jiX7V0Z0
I'm running windows (all answers I found were for linux or mac), any help is appreciated
Edit : as Christos-Angelos Vasilopoulos mentioned, answer in this issue worked https://github.com/brianmario/mysql2/issues/1210#issuecomment-965862944
what I did was the first two steps
1 - Start a cmd terminal and run ridk explicitely by running:
c:\your path to Ruby31-x64\ridk_use\ridk.cmd enable.
This gives you the right environment to do the rest.
2 - From that cmd, run
gem install mysql2 --platform=ruby -- --with-mysql-dir=c:/your path to Ruby31-x64/msys64/mingw64
(no particular quote was neeeded and I used forward slashes).
It is an open issue with mysql2 though there is a workaround. Check this thread from GitHub the last comment is the thing you need.

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
...
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.
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
You might have multiple versions of rails installed. Maybe try running gem cleanup rails
For more information on the command see gem cleanup --help
Edit: and then of course you'd have to install rails again. Either latest stable version or whichever you prefer.
UPDATE
Looking at your output of gem install it doesn't seem to install any of the dependencies, so it assumes you have i18n installed already.
Here is what you can do:
Check out which versions you have installed. Run gem list | grep i18n and grep rails respectively.
Remove all versions of these gems via gem uninstall i18n --all and gem uninstall rails --all respectively
Install rails gem install rails --version 5.0.1 and it should output Successfully installed i18n-0.9.1 during the install process.
Here's my output:
# blank slate
$ rails -v
Rails is not currently installed on this system.
# successful rails install
$ gem install rails -v 5.0.1
...
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
...
35 gems installed
# verify installed gems
$ gem list | grep rails
rails (5.0.1)
...
$ gem list | grep i18n
i18n (0.9.1)
# break i18n
$ gem uninstall i18n --all
You have requested to uninstall the gem:
i18n-0.9.1
activesupport-5.0.1 depends on i18n (~> 0.7)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled i18n-0.9.1
$ rails -v
/Users/me/.rvm/rubies/ruby-2.3.6/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'i18n' (~> 0.7) among 51 total gem(s) (Gem::MissingSpecError)
# fix i18n and rails
$ gem uninstall rails --all
Successfully uninstalled rails-5.0.1
$ gem uninstall i18n --all
$ 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
2 gems installed
# working again
$ rails -v
Rails 5.0.1
So I still don't understand exactly what was happening, but I uninstalled rails using gem uninstall rails and then reinstalled it with just gem install rails, and rails commands now work. Apparently the problem wasn't even really related to i18n. I'm at a total loss. At least it works now!
The problem is with i8ln in the the place where ruby is installed.
For example
Ruby2.3.3\lib\ruby\gems\2.3.0\gems
Try to reinstall ruby and try.
Make sure you clear all ruby files before you do a fresh install.
I was getting the same error after a messy merge on a rails 6.1.4.7 project.
I ran gem uninstall rails , switched the rails version to 7.0.4 in the Gemfile and ran bundle update. After that, all rails commands seem to be working fine.

How Do You Install Missing sass-rails gem?

Hi new to stackoverflow and Ruby on Rails in general. I'm following the Kevin Skoglund Ruby on Rails 3 Essential Training online tutorial and I'm having trouble starting out. I'm trying to boot WEBrick but each time I try I get this error:
C:\Users\Matt\Documents\Sites\simple_cms>rails server
Could not find gem 'sass-rails (~> 5.0) x86-mingw32' in any of the gem sources l
isted in your Gemfile or installed on this machine.
Run bundle install to install missing gems.
What do I do to install this missing sass-rails gem, so I can boot WEBrick?
You can certainly run bundle install in your terminal, or command line, as the output suggests.
$ bundle install
If that fails, run:
$ gem install bundler
$ bundle install

Rails server is not starting

I installed Ruby on Rails in my Windows 8 machine and created a project. When I tried to run the application, it gives this error:
Could not find gem 'sass-rails (~> 4.0.2) x64-mingw32' in the gems available on
this machine.
Run bundle install to install missing gems.
I reinstalled the gem files and ran bundle install but received the same result.
How can I fix this?

Installing Ruby on Rails for OSX - Issues

I am having trouble installing Ruby on Rails on OSX. I have gotten as far as too install the Rails, and have it create the application skeleton but when I go to run the server to test it's all working I get this:
Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in your Gemfile.
sqlite is in the gem folder/list:
* LOCAL GEMS *
sqlite3-ruby (1.2.4)
Any idea?
Found out solution was here:
http://www.ruby-forum.com/topic/1074909

Resources