I'm trying to install ROR on my notebook (Debian Wheezy 64 bit).
On first I had this issue (enter link description here ) solved by the first answer.
Now the rails server starts, but surfing on the browser at localhost:3000 I get the following error:
Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.
I've installed ruby 2.0.0 compiling the source code, no errors or mistakes.
Then I've installed some needed libraries (sqlite3, libsqlite3-dev )...
Here is my GemFile:
'https://rubygems.org'
-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
-# Use sqlite3 as the database for Active Record
gem 'sqlite3'
-# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
-# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
-# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
-# See https://github.com/sstephenson/execjs#readme for more supported runtimes
-# gem 'therubyracer', platforms: :ruby
-# Use jquery as the JavaScript library
gem 'jquery-rails'
-# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
-# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
-# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
-# Use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'
-# Use unicorn as the app server
-# gem 'unicorn'
-# Use Capistrano for deployment
-# gem 'capistrano', group: :development
-# Use debugger
-# gem 'debugger', group: [:development, :test]
gem 'execjs'
gem 'therubyracer'
And in my database.yml:
-# SQLite version 3.x
-# gem install sqlite3
-#
-# Ensure the SQLite 3 gem is defined in your Gemfile
-# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
My gem version:
ruby 2.0.0
rails 4.0.0
sqlite 1.3.7
Came across this error playing around in Sinatra today when running rake db:create_migration. My error was erroneously specifying a "sqlite:" database type in app.rb when it should have been "sqlite 3 :". Example:
wrong:
set :database, 'sqlite:name.db'
correct:
set :database, 'sqlite3:name.db'
I've just struggled through this today. My error when trying to run rake db:create or rake db:migrate or running the server was slightly different:
/Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': Could not load 'active_record/connection_adapters/sqlite_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
Note that it's trying to load sqlite_adapter, not sqlite3_adapter, despite the fact that my database.yml file is valid and does have 'sqlite3' in it. I did all kinds of things to my database.yml which caused me to realize that no matter what I tried (e.g. postgresql) rails was still trying to load sqlite. I finally looked around for something that was overriding database.yml and found it:
$ env | grep sqlite
DATABASE_URL=sqlite:////Users/lisa/dev/mango/devdb.sqlite
This was set for playing around with django and was screwing up my rails environment. Ouch.
Related
I am trying to run a Ruby on Rails app on Cloud 9 with the following command:
rails s -p $PORT -b $IP
and I'm getting an error that tells me I don't have sqlite3 in the gem file when I do. This only happened after I pushed my code to Heroku and now it doesn't run in the console any more.
I already tried 'bundle install' and 'bundle update', I also tried to manually install sqlite3 by running 'gem install sqlite3', none of these solved my problem. I also started going through all the steps all over again to see if that issue pops up again, and it does.
source 'https://rubygems.org'
ruby '2.4.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use Haml as the templating library
gem 'haml'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'themoviedb'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'guard-rspec'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg', '~> 0.21' # for Heroku deployment
gem 'rails_12factor'
end
(Posted on behalf of the question author).
I fixed it eventually, what happened was the version in Gemfile.lock was 'sqlite3 (1.4.0)' but the version I needed was 'sqlite3 (1.3.13)'. I changed the version and ran 'rake db:migrate' and 'rake db:seed' again and now it's working.
Your app is probably running the production environment on Heroku, but your Gemfile only includes sqlite3 in the development & test groups. Move sqlite3 out of the groups so that it is available in all environments and redeploy.
Something wrong with sqlite3 versions > 1.4.0 with Rails 5. Mention sqlite3 version explicitly in Gemfile with v1.3.11 or v1.3.13.
(gem 'sqlite3', '~> 1.3.11')
I'm quite new to Ruby (and Rails) and I've been trying to set up a Rails server that accesses a PostgresQL database on Windows. I apologize in advance if I'm missing something obvious. I am using the most recent Windows release of Ruby 2.3.0p0, and the most recent PostgresQL version, 9.6 Beta 2.
I've been following this guide somewhat loosely, as it is written for Ubuntu. I installed Ruby, the Rails gem and dependencies without a hitch. Basically, everything goes fine until I go to run the
rails server
command, and my command prompt complains that the specified module can't be found. I had the pg gem installed, so I tried a variety of fixes I found, such as putting libpq.dll in the ruby/bin folder, creating a 2.3 folder, and so on. Nothing worked until I removed the actual pg gem itself, whereupon my server magically booted up. I suspect that the pg gem was overriding the pg version installed by the
bundle install
command automatically run after the
gem install pg
but I'm not actually sure what was going on. Could someone clue me in on the details?
EDIT, some debugging info:
With the vanilla pg gem, rails s gives:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:14:in `require': cannot load such file -- 2.3/pg_ext
After copying the 2.2 folder to a 2.3 folder, rails s gives:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:14:in `require': 126: The specified module could not be found. - C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/pg-0.18.4-x64-mingw32/lib/2.3/pg_ext.so (LoadError)
gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
database.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: website_development
test:
<<: *default
database: website_test
production:
<<: *default
database: website_production
username: website
password: <%= ENV['WEBSITE_DATABASE_PASSWORD'] %>
I haven't actually linked the database to Rails yet; I wanted to make sure the Rails side was actually working first.
EDIT2:
I realized that MarsAtomic said PATH and not LOADPATH, and I realized that ruby wasn't in my PATH for some reason. However, it still doesn't work after adding ruby/bin to my PATH. I'm beginning to think that Windows is rejecting the .so file or something, because when I put a .rb file in the same location, it finds that without problem. I also ran file on the .dll and .so, and it reports that they are both PE32+, and my ruby is also 64-bit, so I don't think it's an architecture issue either.
It wasn't an architecture thing, but it was close. I believe the reason it couldn't load the module is because the pg_ext.so in question was compiled for Ruby 2.2 and I am using Ruby 2.3. Upgrading to pg 0.19-pre seemed to resolve the issue.
EDIT: I just found out how to build native extensions and I tried it out the pg 0.18.4 package. (extconf.rb -> devkit's make). I took the .so that was generated and placed it in the 2.3 folder. It didn't ask for the .def but I might need it once I actually link to my database.
If not working on gem 'pg' then try to gem 'postgresql' OR gem install postgresql just see working properly or no
Thanks
After creating a Ruby on Rails skeleton (before pushing to master and Heroku) and running: bundle install, I sometimes encounter the following error:
An error occurred while installing pg (0.18.2), and Bundler cannot continue
Make sure that gem install pg -v '0.18.2' succeeds before bundling.
The following command remediates the issue altogether: bundle install --without production.
Why exactly does the aforementioned command remediate the issue? As I understand, the command bypasses production environment gems for deployment; so, is my understanding correct and why must this be the case? Thank you!
Here is my gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
end
gem 'bootstrap-sass'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
The best resource answering the "why" component of this question appears to be explained thusly by Michael Hartl's Ruby on Rails Tutorial:
"Heroku uses the PostgreSQL database...which means that we need to add the pg gem in the production environment to allow Rails to talk to Postgres...Generally speaking, it's a good idea for the development and production environments to match each other as closely as possible, which includes using the same database, however we'll use SQLite locally and PostgreSQL in production."
So, basically it appears that the issue is a matter of maintaining conventions between two different environments- production and development (local)- and more specifically, database types (Postgres vs SQLite), which is why bundle install --without production is required:
"To prepare the system for deployment to production, we run bundle install with a special flag to prevent the local installation of any production gems (which in this case consist of ph and rails_12factor)...Because the only gems added are restricted to a production environment, right now this command doesn't actually install any additional local gems, but it's needed to update Gemfile.lock with the pg and rails_12factor gems."
If the remediation for Heroku deployment bundle install --without production is an acceptable alternative to bundle install, it just seems too bad to be true; if so, is there another setting or file I can revise in order to achieve the same results effected by the regular bundle install? Thanks!
Get an error when running a query within a Rails app or console against a SQL Server with tiny_tds.
Note: gem install tiny_tds was successful.
Undefined symbol: rb_thread_blocking_region
../bin/ruby: symbol lookup error:
/var/www/.../tiny_tds-0.6.2/lib/tiny_tds/tiny_tds.so:
undefined symbol: rb_thread_blocking_region
My system setup:
Centos 7.0
Ruby 2.2.0p0
Rails 4.1.4
freetds and freetds-devel are installed:
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
My MSSQL section of config/database.yml looks like (I'm connecting to a remote host):
devel_sql:
adapter: sqlserver
mode: dblib
dataserver: DBSERVER\DBINSTANCE
encoding: utf8
database: SOMEDATABASENAME
username: xxxx
password: yyyy
reconnect: true
autocommit: true
timeout: 5000
My Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'pg'
# MSSQL gems
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
The query worked on a Centos 6.3. May any version conflicts?
I am using tiny_tds 0.6.2, ruby 2.2.2, capistrino 3.2.1 and unicorn 4.9.0.
tiny_tds 0.6.2 is not compatible with them. So i changed
gem 'tiny_tds', '~> 0.6.3.rc1'
and upgraded the tiny_tds and it worked. Hope it works for you and others too.
Found the solution. I verified that tiny_tds 0.6.2 runs with ruby 2.1.1.
ruby 2.2.0 seems not yet to be supported.
Found the discussion here.
So in my quest to get a ruby dev environment working, I've ran into an issue that seems...confusing to this ruby noob.
When executing rails server, it starts up as expected, but when you put in localhost:3000 to your standard web browser, it replies the following:
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.
Now here's the confusing part. I have sqlite3 installed (the 64 bit version, as that is what I downloaded, and am running a 64 bit OS), as verified by gem query (here's the full list of gems)
Uninstalling and reisntalling didn't do a lick of good for the issue at hand, but it did install without a hitch. Also the gemfile for the project that I'm testing this with is the folliwing
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
As you can see, sqlite3 is specified in the Gemfile quite early on, yet for whatever reason when I try to load the main page, it acts like it's not there.
Particulars for this machine are the following that weren't mentioned earlier in the gems section:
Rails 4
Ruby 2
Windows 7
Anyone ever ran into this before?
I just had this issue too. Go into your Gemfile.lock file and search for the 'sqlite3' entry. You'll note it reads sqlite3 (1.3.8-x86-mingw32).
Change that to sqlite3 (1.3.8-x64-mingw32) and then run the bundle install command and everything should work like normal.
I faced same issue and this seems to be Windows 7 specific Env issue. My problem was resolved with below changes
Go into your Gemfile.lock file and update sqlite3 (1.3.8-x86-mingw32) to sqlite3 (1.3.8-x64-mingw32)
Run bundle install from the project directory. That will update Gemfile.lock. You also have to restart the Rails server.
Also see config/database.yml which specifies which gem to use for the database.
development:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000