Reputation: 121
Does anybody else spend more time wrestling with rails than actually coding with it??
Very new to rails and programming in general, so I apologize if this is a stupidly easy question. I don't know enough to understand what's wrong here.
I upgraded to ruby 2.2.2 and somehow lost rails in the process. I don't know why. Now every time I try to load it again, I get the following:
Could not find a valid gem 'rails' (>= 0) in any repository
I've tried sudo gem install rails
and gem install rails
to the same effect. I've already checked similar postings here, here, here, here, and here to no effect.
How can I fix this and move on?
Macbook pro 10.10.3 Ruby 2.2.2
Chases-MacBook-Pro:pinteresting Chase$ sudo gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ bundle install
-bash: bundle: command not found
Chases-MacBook-Pro:pinteresting Chase$
edit
I'm behind a VPN, but that shouldn't make a difference because I've checked this several times and it has never been a problem for coding in the past. Since I live in China I have to use VPN a lot, but most of the coding sites are open.
Right now I'm systematically going through each solution and copying down the error messages.
Here's what happened when I did everything at this link
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
1) railsinstaller.org = the packages are out of date. Nothing over 10.6. Does that matter?
2)where ruby?
= -bash where: command not found
3)rvm gem install rails
= Please note that
rvm gem ...was removed, try
gem install railsor
rvm all do gem install railsinstead. ( see: 'rvm usage' )
4) gem install rails = could not find a valid gem 'rails' (>= 0) in any repository.
5) rvm all do gem install rails
= nothing. It just sat there and didn't seem to do anything.
6) curl -L https://get.rvm.io | bash -s stable --autolibs=enabled [--ruby] [--rails] [--trace] = A bunch of information but no action. I opened to new terminal window 10 minutes ago and it still hasn't done anything.
7) curl -L https://get.rvm.io | bash -s stable --rails
= installs rvm and then ends with the same error could not find a valid gem for rails
8) gem sources -a https://rubygems.org
= added the site to the sources... idk if that will change anything...
no change after following all the previous steps
Since I know rails is not on my computer and something might have changed since I did the steps above, I just set my VPN to a new setting and used sudo gem install rails
. This appears to have installed rails and many gems, however...
I then ran rails -v
and got the following error:
[!] There was an error parsing
Gemfile: no .<digit> floating literal anymore; put 0 before dot - gem 'rails', 3.2.11
^
/Users/Chase/Desktop/pinteresting/Gemfile:4: syntax error, unexpected tINTEGER, expecting '('. Bundler cannot continue.
# from /Users/Chase/Desktop/pinteresting/Gemfile:4
# -------------------------------------------
#
gem 'rails', 3.2.11 # gem 'sass-rails', '~> 5.0' # -------------------------------------------`
Upvotes: 4
Views: 8799
Reputation: 1637
I could fix this after trying all the solutions on the Internet for hours by just connecting through my phone.
Upvotes: 0
Reputation: 71
I solved the same problem as follows:
gem source -a http://rubygems.org/
I think the reason is about https.
Upvotes: 5
Reputation: 121
After trying all the steps I listed earlier, I connected to VPN through a new setting. The one I was using only routed the VPN through my browser, but the new one affects the entire internet connection. I think this is what finally allowed me to download rails again.
After downloading rails, it was just a matter of messing with the Gemfile to get everything downloaded, and voila!
Upvotes: 1