Problem with MongoDB Ruby Driver - ruby

I'm on Ubuntu, and I've done
install gem mongo
which reported
Successfully installed bson-1.0
Successfully installed mongo-1.0
2 gems installed
I've started mongod
Now I cd to the mongo gem directory and try
> ruby examples/simple.rb
and I get the error
./examples/../lib/mongo.rb:31:in `require': no such file to load -- bson (LoadError)
from ./examples/../lib/mongo.rb:31
from examples/simple.rb:3:in `require'
from examples/simple.rb:3
which I can't make sense of, since the bson gem is installed
> gem list
*** LOCAL GEMS ***
bson (1.0)
bson_ext (1.0)
mongo (1.0)
rack (1.1.0)
sinatra (1.0)
Any suggestions what's up here?

The example script doesn't require rubygems, which means that bson isn't going to be in your load path. If you add
require 'rubygems'
to the start of the script, I believe it will work.

Related

Installing gem error (EADDRNOTAVAIL)

I am trying to install Redmine to a Windows Server 2012, following "How to MANUALLY install Redmine 3.x on Windows Server 2008 R2".
After installing http://rubyinstaller.org/downloads/ the next step is to install Bundler but I got the following error:
C:\inetpub\wwwroot\redmine>ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
C:\inetpub\wwwroot\redmine>gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
C:\inetpub\wwwroot\redmine>gem install bundler
ERROR: While executing gem ... (Errno::EADDRNOTAVAIL)
The requested address is not valid in its context. - connect(2) for "0.0.0.0
" port 53
C:\inetpub\wwwroot\redmine>
Any help would be appreciated.
Check your DNS is right.
If your DNS not set, gem will display below error:
ERROR: While executing gem … (Errno::EADDRNOTAVAIL)
The requested address is not valid in its context. – connect(2) for “0.0.0.0″ port 53
Found it! You need to install a loopback adapter on Windows. There's lots of guides on how to do it. One of the first links on DuckDuckGo is that.
After poking around with ruby I noticed that uninstalling and reinstalling ruby does not remove some configs. I found a command:
gem env
This gave me the location of the configuration files. After completely deleting the directory .gem it started to work! Looks like something messed up my gem config and the defaults are right.
Start Command prompt with Ruby
Use command: gem env
Check GEM PATHS and locate directory .gem
Delete .gem directory
Done
Good luck!

Error installing unicorn

I am trying to run GitLab on my server.
But the service won't start up.
It puts out:
==> /var/log/gitlab/sidekiq/current /var/log/gitlab/unicorn/current <==
2016-01-26_16:35:06.79546 failed to start a new unicorn master
2016-01-26_16:35:06.80558 starting new unicorn master
2016-01-26_16:35:07.10485 Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
2016-01-26_16:35:07.11661 bundler: command not found: unicorn
2016-01-26_16:35:07.12170 Install missing gem executables with `bundle install`
My System:
Ubuntu 14.04
Plesk 12.5
Ruby 1.9.3
Gem 1.8.23
Bundler 1.11.2
I tried to run
gem install unicorn
But than I get the Error:
Building native extensions. This could take a while...
ERROR: Error installing unicorn:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/kgio-2.10.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/kgio-2.10.0/ext/kgio/gem_make.out
I have no experience with ruby. So anyone has a suggestion what I'm doing wrong ?
Thanks in advance
Dominic
Are you limited to Ruby 1.9.3? Currently the most stable version of Ruby is 2.3.0. Updating Ruby will probably fix this issue.
https://www.ruby-lang.org/en/downloads/
Alternatively, before updating Ruby, check out this thread. Here is a similar error someone had with Ruby 1.9.1. `require': no such file to load -- mkmf (LoadError)
It looks like people on that thread had success using build-essential:
sudo apt-get install build-essential

Unable to Install Shoes :ruby

I am beginner in ruby and wanted to install and GUI toolkit. So i surfed web and found shoes was one toolkit so i downloaded the ".install" file it didn't work saying some permission error, then i downloaded the older version which was ".run" format and that too didn't work so i found a gem of shoes when i try to download i get the below in ruby. i downloaded this shoes from git and still facing some error.
root#Drona:/home/naren/shoes4# gem install bundler && bundle install
Successfully installed bundler-1.10.5
1 gem installed
Installing ri documentation for bundler-1.10.5...
Installing RDoc documentation for bundler-1.10.5...
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all
non-root users on this machine.
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies....
Using rake 10.4.2
Using addressable 2.3.8
Using after_do 0.3.1
Using ast 2.0.0
Using parser 2.2.2.6
Using astrolabe 1.3.0
Using benchmark-ips 2.2.0
Using bouncy-castle-java 1.5.0147
Using docile 1.1.5
Installing json 1.8.3 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
the above is the terminal output.
Ruby version installed is :
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
someone help we out with this installation
and if i have done anything wrong in installation of shoes then let me know
From your terminal directory it seems like you are trying to install shoes4 on ruby 1.9.3. To install shoes4 you need JRuby and a JDK - please follow the instructions in the readme
Shoes 3 can't be installed through gem install due to the way it was built. For Shoes 3 you need the install script, I recommend the appropriate Shoes 3.2 version from this page. If this fails with some error please let us know the error so we can help :)
You should use the gem program to install shoes. If on your command line you type gem install shoes you should be fine.
to use it in an app, you would need to create a Gemfile and run Bundle install within your folder

ruby and gems are installed but sass gem not working

I know I have ruby and gem installed because I've installed a bunch of gems previously. Additionally when I do the following
~$ ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302 [i486-linux]
~$ gem --version
1.3.7
They, as you can see, return the version--yet when I try to do this--
~$ sass --watch happy.scss:happy.css
bash: sass: command not found
I'm a relative noob to everything, but far more to ruby and gems. For the sake of revealing more or less my level of understanding things generally I've learned enough of Debian to get a an environment where I could get Clojure running and get a web app working (taken me almost a year of spare time to do that--I knew virtually nothing of programming previoiusly). I'm trying to get sass working to ease my mental load in the webpage design side of things and I'm just hitting a brick wall on this.
Would this be a PATH issue? If so what needs to be on the path so that one gem works --
BTW here's what happens when I install sass--
# gem install sass
Successfully installed sass-3.2.5
1 gem installed
Installing ri documentation for sass-3.2.5...
Installing RDoc documentation for sass-3.2.5...
Any help anyone can give will be much appreciated. I've been at this one all day and can't figure it out for the life of me.
justin ⮀ ~ ⮀ gem install sass
Fetching: sass-3.2.5.gem (100%)
Successfully installed sass-3.2.5
1 gem installed
justin ⮀ ~ ⮀ sass -v
Sass 3.2.5 (Media Mark)
seems ok to me. I would check your path.
The proper PATH would depend on where your gems get installed. I use RVM so it will be different. You could try to throw an exception in your ruby code with rubygems loaded this should give you a starting point.
> rails c
Loading development environment (Rails 3.2.11)
1.9.3p362 :001 > throw test
ArgumentError: wrong number of arguments (0 for 2..3)
from (irb):1:in `test'
from (irb):1
from /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:5:in `require'
from script/rails:5:in `<main>'
so from that i see /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/gems/railties-3.2.11/lib/rails/commands/console.rb
so my bin path is at /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/bin
and if i
> ls /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/bin
b2json capify fog html2haml nokogiri rails ri sass-convert therubyracer tilt
bundle coderay geocode httpclient oauth rake2thor ruby_noexec_wrapper scss thin tt
cap erubis haml j2bson rackup rdoc sass sprockets thor
boom sass
so in my case I would want to add /Users/justin/.rvm/gems/ruby-1.9.3-p362#rails3.2/bin
but i use RVM so it does that for me.

Error referencing installed Ruby Gem

Can anyone help with an odd Ruby Gem problem I'm having - note I've installed many gems in the past and never seen this.
I've downloaded the net-ssh and net-sftp gems using the following commands:
sudo gem install net-ssh
sudo gem install net-sftp
both installed successfully. However when I reference the files within my code I get the following error:
./workers/ffmpeg_worker.rb:6:in `require': no such file to load -- net/ssh (LoadError)
from ./workers/ffmpeg_worker.rb:6
from ./workers/tests/test_ffmpeg_worker.rb:3:in `require'
from ./workers/tests/test_ffmpeg_worker.rb:3
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
Note when I do:
gem list --local
The gems are listed as such:
net-scp (1.0.2)
net-sftp (2.0.2, 1.1.0)
net-ssh (2.0.15, 1.1.2)
net-ssh-gateway (1.0.1)
Any clues?
When I see this sort of thing, it usually comes down to having more than one Ruby installed on the machine (which means more than one gem location, etc.), and different apps or environments getting confused about which one to load.
Check for that first. If that isn't the answer, do a gem which net/ssh to see where RubyGems thinks the gem is installed -- make sure it isn't the local user's .gems directory or something.
If neither one solves the mystery, stick some debugging code into your worker script and have it output its load path ($:) so you can see where it's looking.

Resources