cannot load sqlite3/sqlite3_native after a rake db:migrate why? - ruby-on-rails

I am following a ruby on rails tutorial. I have not been able to find an answer that works for this problem yet. I am on Windows 8 running Ruby 2.0 what could be causing this?
$ rake db:create
rake aborted!
cannot load such file -- sqlite3/sqlite3_native
Any possible fixes?

I was able to fix this by simply installing the latest versions on the SQLite3 and Eventmachine gems:
https://rubygems.org/gems/eventmachine
http://rubygems.org/gems/sqlite3-ruby

If you have extracted "exe"s and "dll"s from Sqlite download link to Ruby's bin folder and still have this problem. Try this:
bundle update
gem uninstall sqlite3
Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here
Select gem to uninstall:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. All versions
>3
.
.
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]
>
y
gem install sqlite3 --platform=ruby
rails db:create
This should work.
Read through this link for more explanation if above works for you.

Related

Ruby on Rails Trouble - rake-12.3.1

Anytime I try running the following basic rails commands, e.g. rails g model or rails console, I encounter the following error;
Could not find rake-12.3.1 in any of the sources
Run bundle install to install missing gems.
I've already looked through the forums for solutions and haven't found anything that solves my problem.
My gem file includes the necessary gem and I already ran bundle install.
Thanks in advance for your help.
This is because you have two versions of rake instaled.
Sometimes you have two rails projects with different rake versions and you did bundle install in one and after in another. (now you have two rake versions)
try gem uninstall rake
This command above will show you two these rake versions. You have to type the number that you want to unistall.

Sketchfab api data with Ruby

I am new to ruby. I am trying to upload a .STL file to Sketchfab using the code that they have provided on Sketchfab website.
https://gist.github.com/sbouafif/3736968#file-sketchfab-api-rb
I have installed the required gems including - gem install ruby-multipart-post
When I run:
bundle install
rake db:migrate
I get an error saying:
rake aborted!
cannot load such a file -- ruby-multipart-post
I have never had this issue when installing gems.
Any help would be great.
I am using Ruby 1.9.3.
Thanks
You don't install ruby-multipart-post gem as recommended in this line of script. Open terminal and install it use command:
gem install ruby-multipart-post

Freezing Rails gem versions

I am trying to freeze my Rails gem version as, day by day, some or the other gem version gets updated and sometimes I need to update the code.
I tried rake rails:freeze:gems but this gave me error:
rake aborted!
Don't know how to build task 'rails:freeze:gems'
This locks and then caches the gems into ./vendor/cache.
$ bundle package
Refer this link
rake rails:freeze:gems is an old Rails 2 way of doing it. I think you want to use Bundler's bundle install vendor/gems
"How do I freeze gems into a Rails 3 application?" seem to answer it better.

How to run a specific version of rake

Background:
I get errors whenever I run rake in an older project. (uninitialized constant Rake::DSL).
The rails project in question is an old project that was started with Rails 2.1 (I think), and since then I've updated the OS on my laptop a couple of times, and made updates along the way to make it run.
Right now, the rails app works fine, provided I have RAILS_GEM_VERSION set to 2.3.5. I'm not sure if the app was completely updated to Rails 2.3.5.
There is no Gemfile in my older project.
If I create a brand-new rails project (and unset RAILS_GEM_VERSION), rake runs fine.
My question: To troubleshoot, I'd like to try newer versions of rake. I'd like to know how to force one specific version to be used, since it appears I have multiple versions installed.
Info on my environment:
$ gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.9.2, 0.8.7, 0.8.3)
$ rake --version
rake, version 0.8.7
So it looks like it's picking up the 0.8.7 version.
All the help files online seem to tell me to specify the rake version in the Gemfile, but there isn't one in this project. (Maybe it predates gemfiles?)
If I unset the RAILS_GEM_ENVIRONMENT variable altogether, and try to run rake, I get:
rake aborted!
can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.2.8 for []
None of the environment config files in my older project set that variable either.
This may be of help. Have you tried the underscore solution?
Example:
rake _0.9.2_
you can run rake specific version by using this
bundle exec rake ...
more detail see this - bundle exec, rake
You can uninstall the current version of rake and install another desired version using commands similar to the following:
gem uninstall rake 12.3.1
gem install rake 10.5.0
(Note: you might need to run as sudo for permissions)
I had a problem where I received the following error while trying to install rake 10.5.0:
Could not find a valid gem '0.8.7' (>= 0) in any repository
I resolved this problem by adding the following line to my Gemfile:
gem 'rake', ' <11.0'
After editing Gemfile I was able to successfully downgrade rake by updating my gems:
bundle update

setting up rails/sqlite3 on OSX 10.5.8

I'm trying to get get going on a rails tutorial and get get past the installation. I'm a newbie.
1 . ran "rails new app1." - The app is created but bundler fails (looks like it is run as part of the rails new command
An error occured while installing sqlite3 (1.3.5),
changed the gemfile to explicitly call for "gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' (this is the most recent version that works on osx 10.5)"
ran "bundle install" - success
try to view the default app and see the error
ActiveRecord::ConnectionNotEstablished
looked in config/database.yml. It says "database: db/development.sqlite3"
looked in db/ - no database here. - - Is a db supposed to be created during rails new?
Tried running rake db:migrate - get
"rake aborted!
: Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter (sqlite3 is not part of the bundle. Add it to Gemfile.)"
Tried running that command, got
ERROR: Could not find a valid gem 'activerecord-sqlite3-adapter' (>= 0) in any repository
ERROR: Possible alternatives: activerecord-jdbcsqlite3-adapter, activerecord-sqlserver-adapter, activerecord-spatialite-adapter, activerecord-n
ulldb-adapter, activerecord-dbslayer-adapter
Anyone know what I'm missing?
Anybody have an idea what I need to do?
OSX 10.5.8 (leopard)
rails 3.2.0
ruby 1.9.2
Well that last part is a bit hairy sounding, but to get your database sorted you want:
rake db:setup
...not migration, to create the database.
rake -T | grep db
...shows you the options, for future reference. Let's see what happens after that :)

Resources