Tuesday, 23 August 2011

Ruby gems error: "Could not find a valid gem 'sqlite3' Possible alternatives: sqlite3" WTH?? Gems could be having network issues.

Installed rails and trying to get a test project running:

Created a new project and tried to get it running:

D:\Development\testrails>rails server

Error was:

D:\Development\testrails>rails server
←[31mCould not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you
r Gemfile.←[0m
←[33mRun `bundle install` to install missing gems.←[0m

Now trying to install sqlite3, based on advise here:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/

But I got:

D:\Development\testrails>gem install sqlite3
ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3


And trying 'sqlite3-ruby' doesn't work either:

D:\Development\testrails>gem install sqlite3-ruby
ERROR: Could not find a valid gem 'sqlite3-ruby' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3-ruby

I came across this:

http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/

which advised to download sqlite3 for Windows and copy the file
sqlite3.dll into the directory [RUBY_INSTALL]\bin

No dice, still getting the same error

I also copied the file sqlite3.def to the same location - still
failing! Could it be because my version of sqlite is too new (current
one I downloaded is 3.7.7.1)

Then I realised that I forgot to use the proxy settings. At work, we
go through a Windows proxy, and to get Ruby gems to work, I had to
install CTNLM - which requires username and password - and then
access the proxy like this:

gem install --http-proxy http://localhost:3128 rails

Now it works!!


D:\Development\testrails>gem install --http-proxy http://localhost:3128 sqlite3-
ruby
Fetching: sqlite3-1.3.4-x86-mingw32.gem (100%)
Fetching: sqlite3-ruby-1.3.3.gem (100%)

#######################################################

Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.

Thanks from the Ruby sqlite3 team!

<3 <3 <3 <3

#######################################################

Successfully installed sqlite3-1.3.4-x86-mingw32
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.4-x86-mingw32...
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.4-x86-mingw32...
Installing RDoc documentation for sqlite3-ruby-1.3.3...

And Rails works now:

D:\Development\testrails>rails server
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-08-23 16:27:11] INFO WEBrick 1.3.1
[2011-08-23 16:27:11] INFO ruby 1.9.2 (2011-02-18) [i386-mingw32]
[2011-08-23 16:27:11] INFO WEBrick::HTTPServer#start: pid=4908 port=3000


D:\Development\testrails>


So the lesson here is:

When you see a nonsensical error like this

ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3

It could mean that Ruby gems is having network problems, and can't
access *any* repository.


REFS:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/
http://stackoverflow.com/questions/4418/how-do-i-update-ruby-gems-from-behind-a-proxy-isa-ntlm
http://cntlm.sourceforge.net/
http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/

1 comment:

Mario Ruiz Sánchez said...

In my case I don't have any proxy but the same problem, do you have any idea how can I solve it?
http://www.ruby-forum.com/topic/2983318#1031826