MongoMapper and bson_ext problem - ruby-on-rails

I can't get MongoMapper to work with my Rails app. I get this error message:
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
You can install the extension as follows:
gem install bson_ext
If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.
I have installed DevKit and installed the gem: gem install bson_ext --no-rdoc --no-ri (result: bson_ext-1.0.1 installed)
I'm running on Windows 7. The Rails version is 2.3.7. I used the RubyInstaller when installing. Can anyone point me in the right direction?

The problem is: the bson_ext gem version and the mongo gem version need to match, also, mongo_mapper isn't ready for mongo-1.0.1 yet, so the versions of the mongo and bson_ext gems you should be using are 1.0 for each, respectively.
so, do the following:
gem install mongo -v=1.0 --no-ri --no-rdoc && \
gem install bson_ext -v=1.0 --no-ri --no-rdoc
then for Rails 2.x in your config/environment.rb do:
config.gem 'mongo', :version => '1.0'
config.gem 'bson_ext', :version => '1.0'
or for Rails 3, in your Gemfile:
gem 'mongo', '1.0'
gem 'bson_ext', '1.0'

This is generally caused by installing a version of bson_ext not equal to the version number required by MongoMapper. Check which version of bson MongoMapper is requiring, and then make sure that you have that version and no other installed.

I needed specify the bson version to get this to work, like so:
gem 'mongo', "1.1"
gem 'bson', "1.1"
gem 'bson_ext', "1.1"
(Using rails 3)

I followed the instructions above but still the "no such file to load 'bson_ext'. I went to the gem and tried moving the folders in the "ext" folder up one level (to the root of the gem) and lo and behold, it worked. FWIW...

Include the following in your environment.rb
config.gem 'bson_ext', :version => "1.0", :lib => "bson_ext/cbson"

Install bson_ext using:
gem install bson_ext
Add the gem to your Gemfile:
gem 'bson_ext'
Run bundle in your project root level directory.

Related

'bundle install' keeps installing gem sqlite3 version 1.4.2 even if not in Gemfile

I need sqlite3 v1.3.9 gem installed for my app, so I add this line to the Gemfile:
gem 'sqlite3', '= 1.3.9'
However, when I run 'bundle install', it installs v1.4.2 of that gem.
I modified the above line to
gem 'sqlite3', '= 1.3.9', '< 1.4'
No joy -- sqlite v1.4.2 is installed (even if I remove any reference to 'sqlite3' from the Gemfile completely).
My Gemfile was created when I used rails new appname, so it is not fancy at all... I only added gem devise to it.
Gemfile.lock doesn't contain any reference to sqlite3. I removed it anyway and it didn't help.
As another option, I installed v1.3.9 via gem install sqlite3 -v 1.3.9 and I removed v1.4.2 with
# bundle exec gem uninstal sqlite3
Select gem to uninstall:
1. sqlite3-1.3.9
2. sqlite3-1.4.2
3. All versions
> 2
Successfully uninstalled sqlite3-1.4.2
...but as soon as I tried to add v1.3.9, I got:
# bundle add sqlite3 -v 1.3.9
[!] There was an error parsing `injected gems`: You cannot specify the same gem twice with different version requirements.
You specified: sqlite3 (~> 1.4) and sqlite3 (= 1.3.9). Bundler cannot continue.
# from injected gems:1
# -------------------------------------------
> gem "sqlite3", "= 1.3.9"
# -------------------------------------------
I'd grateful for any hints on why v1.4.2 keeps being installed and, most importantly, how do get the bundler forget about v1.4.2 and accept v1.3.9?
Thanks a lot!
There might be some gem in your app that requires sqlite3-1.4.2 and that is causing an issue with installing sqlite3-1.3.9. You should check your Gemfile.lock and look for any gem that is adding sqlite3-1.4.2 as a dependency.
There should be a gem in your app that requires sqlite3-1.4.2 and that is causing an issue with installing sqlite3-1.3.9. You should check your Gemfile.lock and look for any gem that is adding sqlite3-1.4.2 as a dependency.

Bundler: how to remove uninstalled gems

I'm trying to install the pg_search gem. In the first attempt I did not pay attention to the necessary version of ruby (we are using 2.3.1 and 2.4 was required), in the error message that appeared I was asked to run bundle update, but it updated pg_search to 2.3.5 which require ruby >= 2.5. Even though I specified an older version of the gem, it still shows the same message:
Gem::InstallError: pg_search requires Ruby version >= 2.5.
An error occurred while installing pg_search (2.3.5), and Bundler cannot continue.
Make sure that `gem install pg_search -v '2.3.5'` succeeds before bundling.
I already installed the gem by running docker-compose run web gem install pg_search -v 2.1.4, and recreated the container. My Gemfile:
source 'https://rubygems.org'
gem 'rails', '~> 5.2.0'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
#gem 'mina-puma', :require => false
gem 'puma', '~> 3.7.1'
gem 'pg', '~> 0.18'
gem 'pg_search', '~> 2.1', '>= 2.1.4'
...
Bundler version: bundler (>= 1.3.0)
I would like to know how to remove pg_search 2.3.5 and install 2.1.4.
Even though I specified an older version of the gem
No, you didn't.
You specified '~> 2.1', '>= 2.1.4', which means anything 2.1.4 <= version < 3.0.0.
By running bundle update, this installed the latest available version that met your requirements, which was apparently 2.3.5, not 2.1.4.
If you need to also specify a constraint to ruby version 2.3.1, you can also put this in the Gemfile:
ruby '2.3.1'
...And then running bundle update will also take that into consideration when finding the latest compatible dependencies.
I would like to know how to remove pg_search 2.3.5 and install 2.1.4
You don't have version 2.3.5 installed against this ruby version, because it's incompatible.
Apparently you've already installed version 2.1.4.
The problem is that your Gemfile.lock is still expecting version 2.3.5. There are a few ways you could resolve this, but one way or another you need to update the Gemfile.lock to have a compatible set of dependencies with your ruby version.
The simplest approach is probably to just re-run bundle update pg_search, but make sure you're actually using the correct ruby version this time. That should downgrade the dependency, as the newer library version isn't compatible with the older ruby version.
If you still encounter issues, you could take my advice of adding the ruby constraint to the Gemfile, and revert whatever other changes you've recently made that created this incompatible mix of dependencies.

LoadError: cannot load such file — bcrypt_ext

I have tried to deploy devise authentication on my rails app.
I am getting this issue
"cannot load such file -- bcrypt_ext"
I see it is a common issue amongst windows based computers but the answers to other questions have not helped me yet.
I am running Windows 8 x64 with x86 ruby and devkit
try
C:\> gem install --no-ri --no-rdoc bcrypt
C:\> cd (path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> ruby extconf.rb
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make install
reference: https://www.alib.jp/entries/bcrypt_ext_load_error_on_ruby21x
bcrypt_ext.so file is missing -if you manually copy it to proper folder - in my case \Ruby23\lib\ruby\gems\2.3.0\gems\bcrypt-3.1.11-x86-mingw32\lib - it helps. :)
This worked for me:
https://github.com/codahale/bcrypt-ruby/issues/142
-Uninstall all bcrypt versions: gem uninstall bcrypt
select option 3 (uninstall all)
-Uninstall all bcrypt-ruby versions: gem uninstall bcrypt-ruby
select option 3 (uninstall all)
replace the line in your gemfile by:
to add this line to the gemfile:
gem 'bcrypt', platforms: :ruby
did not work for me though but to point the gemfile to the git repository did:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
bundle install
and you should be good to go
At this link https://github.com/codahale/bcrypt-ruby/issues/142
Somebody mentioned this solution
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
And it worked for me

Gem is not available after bundle install

I have a Gemfile where I add a new gem
gem 'activerecord-oracle_enhanced-adapter', git: "https://github.com/rsim/oracle-enhanced.git", branch: "rails4"
When I run bundle install I get
> bundle install
Updating https://github.com/rsim/oracle-enhanced.git
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
...
Using activerecord (4.0.0)
Using activerecord-oracle_enhanced-adapter (1.4.2) from https://github.com/rsim/oracle-enhanced.git (at rails4)
Using bundler (1.3.5)
...
But when I call gem list, the gem is missing. If I try to load this gem in the irb, I get
irb
require 'rubygems'
=> false
gem 'activerecord'
=> true
gem 'activerecord-oracle_enhanced-adapter'
Gem::LoadError: Could not find 'activerecord-oracle_enhanced-adapter' (>= 0) among 49 total gem(s)
I do not understand this behavior. I have several gems added to my Gemfile this way and all of them are working.
My system for the test:
RVM
ruby 2.0.0p195
new gemset
new rails 4 project without any modification except this gem in the Gemfile
I tried it with two different users
Ubuntu 12.04
If I call gem install activerecord-oracle_enhanced-adapter, this gem is installed, but not from the 'rails4' branch and I would like to use the Gemfile
Try calling bundle exec irb so you will load irb in specific Gemset scope instead of system one.

bcrypt error: Devise ruby 2.0 and rails 4.0

I keep getting this error when i try to run my app:
C:/ruby-2.0.0-p195-i386-mingw32/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0.rc1
/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- 2
.0/bcrypt_ext (LoadError)
Any takers? - im trying to use the devise gem for basic user authentication..
I've gotten this error when I updated to Ruby 2.0.0+ on Windows. I was able to solve it by uninstalling all versions of bcrypt that were downloaded, and building the gem using DevKit.
gem uninstall bcrypt-ruby
gem install bcrypt-ruby --platform=ruby --no-ri --no-rdoc
Usually doing a bundle update will download a precompiled gem mingw32 extension, which in this case appears not to work. This workaround for reinstalling bcrypt-ruby will hopefully not be needed in the future.
Additionally, I keep updated Windows installation instructions for Ruby on Rails here (mostly for my own reference) for installing Ruby on Rails on Windows.
https://github.com/remomueller/documentation/tree/master/windows
Some other Windows pitfalls you may run into are also listed there:
https://github.com/remomueller/documentation/blob/master/windows/190-miscellaneous.md
Until this problem is fixed, the best workaround is to install bcrypt-ruby from git:
gem 'bcrypt-ruby', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
Update (June 2016.) - as #gneri mentioned, bcrypt-ruby changed it's name to bcrypt, so use:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
On problem with has_secure_password on Window 7 helps this
gem uninstall bcrypt-ruby
gem uninstall bcrypt
gem install bcrypt-ruby --platform=ruby --no-ri --no-rdoc
gem install bcrypt --platform=ruby --no-ri --no-rdoc
Add to Gemfile:
gem 'bcrypt-ruby', '~> 3.0.0', :require => 'bcrypt'
gem 'bcrypt'
bundle install
turns out that it was a problem with the version of ruby that i was using. I was using ruby 2 (32bit).
but if you switch to the 64bit version of ruby 2 the error goes away.
Seems like the downfall of using windows as a development platform for ROR apps. I need to use Ruby 2.0 32 bit in order to get PG gem for a postgresql connection to work or I have to use Ruby 2.0 64 bit to get 'Devise' gem to work.
The new version of bundler just came out. It nows about x64 gems
gem install bundler -v '1.4.0.pre.2'

Resources