How to work with Sqlite? - ruby-on-rails

I want to setup different rails versions with RVM. However, working with the SQLite gives problem.
First, doing
gem list -ra sqlite
gives
*** REMOTE GEMS ***
sqlite-foreigner (0.5.0)
sqlite-ruby (2.2.3 ruby mswin32, 2.2.2 ruby mswin32, 2.2.1 ruby mswin32, 2.2.0 ruby mswin32, 2.1.0 ruby mswin32, 2.0.3)
sqlite3 (0.1.1, 0.1.0, 0.0.8, 0.0.7, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1, 0.0.0)
sqlite3-dotnet (3.7.2.1, 3.7.2.0)
sqlite3-ironruby (0.1.1, 0.1.0)
sqlite3-ruby (1.3.1 ruby x86-mingw32 x86-mswin32-60, 1.3.0 ruby x86-mingw32 x86-mswin32-60, 1.2.5 ruby x86-mingw32 x86-mswin32, 1.2.4, 1.2.3 ruby mswin32 x86-mingw32, 1.2.2 ruby mswin32, 1.2.1 ruby mswin32, 1.2.0 ruby mswin32, 1.1.0 ruby mswin32, 1.0.1 ruby mswin32, 1.0.0 ruby mswin32, 0.9.0 ruby mswin32, 0.6.0, 0.5.0)
sqlitecache (0.0.1)
I am working with MacOS X 10.6, Sqlite3 3.7.2
Can I work with multiple versions of Sqlite3?
What gems would I need in my RVM environment?
Currently:
*** LOCAL GEMS ***
actionmailer (2.2.3, 2.2.2)
actionpack (2.2.3, 2.2.2)
activerecord (2.2.3, 2.2.2)
activeresource (2.2.3, 2.2.2)
activesupport (2.2.3, 2.2.2)
ffi (0.6.3)
haml (2.2.0)
rails (2.2.3, 2.2.2)
rake (0.8.7)
ruby-openid (2.0.4)
And RVM list:
rvm rubies
ree-1.8.6-20090610 [ x86_64 ]
=> ruby-1.8.6-p399 [ x86_64 ]
ruby-1.9.2-p0 [ x86_64 ]

you can install multiple sqlite3 packages simultaneously with gem. and you can select the specific gem version with the following lines:
require 'rubygems'
gem 'sqlite3', '=0.1.0'
require 'sqlite3'
To install it type:
gem install sqlite3 -v '0.1.0'
I think you can use any sqlite3 gem with any RVM, but you can check their webpage

Related

Rails installation fails

I fail to install rails properly for some reason. gem install rails says everything is fine but I cannot use it due to some missing gemfile. What am I doing wrong?
I am working on a mac Sierra.
$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
$ gem install rails
Fetching: rails-5.1.4.gem (100%)
Successfully installed rails-5.1.4
1 gem installed
$ rails -v
Could not locate Gemfile or .bundle/ directory
$ gem list rails
*** LOCAL GEMS ***
jquery-rails (4.3.1)
less-rails (3.0.0, 2.8.0)
rails (5.1.4)
rails-dom-testing (2.0.3, 2.0.2, 2.0.1)
rails-html-sanitizer (1.0.3)
rails_12factor (0.0.3)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
rspec-rails (3.7.2)
sprockets-rails (3.2.1, 3.2.0)
twitter-bootstrap-rails (4.0.0, 3.2.2)

Why doesn't "bundle exec" see that I have rake installed?

I've been reading StackOverflow and trying to deal with this error for 2 hours now:
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
I followed the advice here, to no avail:
rails s: Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
also:
Could not find rake with bundle exec
So I did:
gem uninstall rake
gem install rake
And, following the other StackOverflow articles I read, I tried:
rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
Installed ruby-2.3.1 to /Users/lkrubner/.rbenv/versions/2.3.1
rbenv global 2.3.1
ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
rbenv rehash
rbenv uninstall rake
rbenv: version `rake' not installed
At the command line, if I look for versions, I see:
rake -V
rake, version 11.2.2
rails -v
Rails 4.2.0
ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
but I still get this error:
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
What would fix this?
Update 1
This is even more confusing:
bundle update rake
Fetching gem metadata from https://rubygems.org/.............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 11.2.2 (was 10.4.2)
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.0
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.4
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.0
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.0
Using globalid 0.3.6
Using activejob 4.2.0
Using mime-types 2.99
Using mail 2.6.3
Using actionmailer 4.2.0
Using activemodel 4.2.0
Using arel 6.0.3
Using activerecord 4.2.0
Using addressable 2.3.8
Using multi_xml 0.5.5
Using httparty 0.13.7
Using uuidtools 2.1.5
Using aws-sdk 1.3.9
Using bcrypt 3.1.10
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bson 3.2.6
Using bson_ext 1.5.1
Using bundler 1.8.5
Using byebug 8.2.1
Using xpath 2.0.0
Using capybara 2.5.0
Using ffi 1.9.10
Using childprocess 0.5.8
Using climate_control 0.0.3
Using cocaine 0.5.8
Using coderay 1.1.0
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.0
Using coffee-rails 4.1.0
Using database_cleaner 1.5.1
Using orm_adapter 0.5.0
Using responders 2.1.0
Using warden 1.2.3
Using devise 3.5.2
Using diff-lcs 1.2.5
Using dotenv 2.1.0
Using dotenv-rails 2.1.0
Using factory_girl 4.5.0
Using factory_girl_rails 4.5.0
Using faker 1.4.3
Using multipart-post 2.0.0
Using faraday 0.9.2
Using sass 3.4.19
Using foundation-rails 5.5.3.2
Using geocoder 1.2.9
Using httpclient 2.6.0.1
Using icalendar 2.3.0
Using multi_json 1.11.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using jwt 1.5.2
Using kgio 2.9.3
Using method_source 0.8.2
Using mimemagic 0.3.0
Using mongo 2.1.2
Using origin 2.1.1
Using mongoid 5.0.1
Using paperclip 4.3.2
Using mongoid-paperclip 0.0.10
Using oauth2 1.0.0
Using slop 3.6.0
Using pry 0.10.1
Using pry-rails 0.3.4
Using quiet_assets 1.1.0
Using sprockets 3.4.1
Using sprockets-rails 2.3.3
Using rails 4.2.0
Using rails_serve_static_assets 0.0.4
Using rails_stdout_logging 0.0.3
Using rails_12factor 0.0.3
Using raindrops 0.15.0
Using rdoc 4.2.0
Using rspec-support 3.3.0
Using rspec-core 3.3.1
Using rspec-expectations 3.3.0
Using rspec-mocks 3.3.1
Using rspec-rails 3.3.2
Using rspec_junit_formatter 0.2.2
Using rubyzip 1.1.7
Using tilt 2.0.1
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using websocket 1.2.2
Using selenium-webdriver 2.48.1
Using shoulda-matchers 2.8.0
Using signet 0.7.2
Using simple_form 3.2.0
Using spring 1.4.4
Using timezone 0.5.0
Using turbolinks 2.5.3
Using uglifier 2.7.2
Using unicorn 4.9.0
Using web-console 2.2.1
Updating files in vendor/cache
* rake-11.2.2.gem
Removing outdated .gem files from vendor/cache
* rake-10.4.2.gem
Bundle updated!
bundle exec rake db:setup
Could not find rake-11.2.2 in any of the sources
Run `bundle install` to install missing gems.
bundle update rake
So one line says that rake is installed, and the next line says that it is not installed, and both lines are nominally being managed by Bundler, so in theory this can not be a cache problem.
Update 2
I added this to the Gem file:
gem 'rake', '10.5.0'
And then ran
bundle install
which gives me:
Updating files in vendor/cache
Bundle complete! 40 Gemfile dependencies, 116 gems now installed.
Bundled gems are installed into ./vendor/cache.
So then I try:
bundle exec rake db:setup
and I get:
Could not find rake-10.5.0 in any of the sources
Run `bundle install` to install missing gems.
You could try to run install command as sudo and specify rake's version like this:
sudo gem install rake -v '11.2.2'

Using rails 4.1.4 - stuck on 3.2.9

I'm trying to install ruby version 4.1.4. I'm keeping it in specific gem sets
rvm use ruby-2.1.2#rails4.1.4 --create
gem install rails --version=4.1.4
bundle install
rails -v
And I always get back 3.2.9. If I run rails -v before bundle install, I get
Could not find proper version of railties (3.2.9) in any of the
sources Run bundle install to install missing gems.
When I run bundle install, I notice the version of rails is 3.2.9. Is there a simple fix for this.
Fetching gem metadata from https://rubygems.org/.........
Using rake 10.3.2
Using i18n 0.6.11
Using multi_json 1.10.1
Installing activesupport 3.2.9
Installing builder 3.0.4
Installing activemodel 3.2.9
Using erubis 2.7.0
Installing journey 1.0.4
Installing rack 1.4.5
Installing rack-cache 1.2
Using rack-test 0.6.2
Using hike 1.2.3
Using tilt 1.4.1
Installing sprockets 2.2.2
Installing actionpack 3.2.9
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Installing mail 2.4.4
Installing actionmailer 3.2.9
Installing arel 3.0.3
Installing tzinfo 0.3.40
Installing activerecord 3.2.9
Installing activeresource 3.2.9
Installing coffee-script-source 1.7.1
Installing execjs 2.2.1
Installing coffee-script 2.3.0
Installing rack-ssl 1.3.4
Using json 1.8.1
Installing rdoc 3.12.2
Using thor 0.19.1
Installing railties 3.2.9
Installing coffee-rails 3.2.2
Installing jquery-rails 3.1.1
Using bundler 1.6.5
Installing rails 3.2.9
Installing sass 3.3.11
Installing sass-rails 3.2.6
Installing sqlite3 1.3.9
Installing strong_parameters 0.2.3
Installing uglifier 2.5.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Any ideas how to get 4.1.4?
Thanks
Firstly, prefix commands with bundle exec where appropriate.
Secondly, have you tried bundle update rails? It could be your Gemfile.lock that's the problem...

Why "bundle install" try to install outdated version of gems?

I have different gemsets
> rvm gemset list
gemsets for ruby-2.0.0-p247 (found in /Users/kai/.rvm/gems/ruby-2.0.0-p247)
=> (default)
global
rails4
> rvm gemset use rails4
Using ruby-2.0.0-p247 with gemset rails4
> rails -v
/Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (>= 0) among 43 total gem(s) (Gem::LoadError)
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247#rails4/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247#rails4/bin/ruby_noexec_wrapper:14:in `<main>'
and when I'm doing:
> bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Installing i18n (0.6.4)
Installing multi_json (1.7.9)
Installing activesupport (3.2.7)
Installing builder (3.0.4)
Installing activemodel (3.2.7)
Installing erubis (2.7.0)
Installing journey (1.0.4)
Installing rack (1.4.5)
Installing rack-cache (1.2)
Installing rack-test (0.6.2)
Installing hike (1.2.3)
Installing tilt (1.4.1)
Installing sprockets (2.1.3)
Installing actionpack (3.2.7)
Installing mime-types (1.23)
Installing polyglot (0.3.3)
Installing treetop (1.4.14)
Installing mail (2.4.4)
Installing actionmailer (3.2.7)
Installing arel (3.0.2)
Installing tzinfo (0.3.37)
Installing activerecord (3.2.7)
Installing activeresource (3.2.7)
Installing coffee-script-source (1.6.3)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Installing rack-ssl (1.3.3)
Installing json (1.8.0)
Installing rdoc (3.12.2)
Installing thor (0.18.1)
Installing railties (3.2.7)
Installing coffee-rails (3.2.2)
Installing jquery-rails (3.0.4)
Using bundler (1.3.5)
Installing rails (3.2.7)
Installing sass (3.2.10)
Installing sass-rails (3.2.6)
Installing sqlite3 (1.3.7)
Installing uglifier (2.1.2)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
But I have ruby 2.0! Why it doesn't install rails 4.0 and activesupport 4.0?
bundler installs gems basing on two files:
Gemfile.lock strict versions saved during previous installation,
Gemfile loose version declaration from user.
when you generate rails project first Gemfile is generated with something like this:
gem 'rails', '~> 3.2'
after the file is generated bundle install is ran which generates Gemfile.lock in which strict versions of gems are recorded, from now on any succeeding call to bundle install will install only the versions saved in Gemfile.lock.
To update gems to newer versions:
check Gemfile for any version restrictions - that might prevent installing the versions you would like to get
run bundle update <gem_name> to update only this single gem and what is require for it - but minimalizing scope of the changes to the smallest possible set of changes.
run bundle update to update all gems to latest versions allowed in Gemfile
bundle install or in short bundle does not install the latest gem unless you have left out the version in your Gemfile. e.g.
gem 'rails'
But usually this is not the case, we specify versions to prevent application from "crashing" when some gems are updated and we unknowingly run bundle update, or for that matter move application to say test or production servers. Usually when adding a gem to Gemfile, we do:
gem 'rails', '~> 3.2.7'
Note the leading ~> in the version number. This says: use rails gem between versions 3.2.7 and less than 3.3.0.
In order for your bundle command to grab rails 4.0, you need to change that line to read either one of the following:
gem 'rails', '>= 3.2.7'
or
gem 'rails', '4.0.0'
If you use gem 'rails', '>= 3.2.7' then your rails application will use the latest gem available in your system. Note that 3.2.7 is just an example I'm using here. If you use gem 'rails', '4.0.0' then your rails application will use rails version 4.0.0.
Please note that this change might break your existing rails 3.2 application.

gem 1.8.23 install rails 3.2.8 failed, Unable to resolve dependencies

I'm trying to install Rails 3.2.8 to a linux box without internet connection. I've manually downloaded all the related gem packages and copied them to the linux box. When I try to install some of those packages, I got error. e.g., :
[jw#web gems]$ sudo /usr/local/bin/gem install --local ./activemodel-3.2.8.gem
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: activemodel requires builder (~> 3.0.0)
The strange thing is that some packages can be installed this way. e.g., the builder has already been installed. Please note that all the dependencies required are there.
How come the dependencies is unable to resolve ?
My environment:
Ruby: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Rubygem: 1.8.23
My installed gems:
[jw07#web gems]$ gem list
*** LOCAL GEMS ***
activesupport (3.2.8)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.1.3)
bundler (1.2.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
io-console (0.3)
journey (1.0.4)
json (1.7.5)
mail (2.4.4)
mime-types (1.19)
minitest (2.5.1)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rake (0.9.2.2)
rdoc (3.9.4)
sprockets (2.5.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
It does not look like Rubygems version is a problem.
You see rails requires gem builder ~> 3.0.0, but you have 3.1.3 which does not match (~> means it will match 3.0.x, but not 3.1.x). You have to install builder 3.0.3.
Another possibility could be there is another gem in your Gemfile that requires builder 3.1.x, causing a conflict. It would be helpful if you provided your Gemfile.
Try to upgrade to the latest RubyGems:
gem update --system
And install rails with dependencies:
gem install rails --include-dependencies

Resources