Mongo::ReplSetConnection authenticate fail - ruby

This is the simple script.
require 'mongo'
database=Mongo::ReplSetConnection.new(["database1:9900", "database2:9900","database3:9900"]).db("project")
database.authenticate("user","passwd")
I got the following error:
undefined local variable or method `pools' for # <Mongo::ReplSetConnection:0x0000000441e610>
from /home/tommy/.rvm/gems/ruby-1.9.3-p194#myrails3/gems/mongo-1.7.0/lib/mongo/repl_set_connection.rb:309:in `authenticate_pools'
Has anyone encountered such problem before? Is there any suggestions?

The following method works for me. But I don't know why.
con=Mongo::ReplSetConnection.new(["host1:14000", "host2:14000", "host3:14000"])
con.add_auth("databasename","user","passwd")
con.apply_saved_authentication()

This seems to be related to the following bugfix:
https://github.com/mongodb/mongo-ruby-driver/pull/112
If you change that code on your driver it will work.

Related

Launching OplRun has encountered a problem. A reference to undefined variable C is shown while trying to use oplrun. Why?

I tried like this but it is not working. The picture is attached below.
You can run oplrun from command line:

What is the proper way to get FQDN of current host?

For some time I was using code:
hostname = Socket.gethostbyname(Socket.gethostname).first
taken from here.
But, as the comment said - it's deprecated, and now both rubocop and ruby itself are complaining:
=$ ./z.rb
./z.rb:5: warning: Socket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead.
=$ rubocop z.rb
...
z.rb:5:13: W: Lint/DeprecatedClassMethods: Socket.gethostbyname is deprecated in favor of Addrinfo#getaddrinfo.
puts Socket.gethostbyname(Socket.gethostname).first
^^^^^^^^^^^^^
The problem is that I don't know how to use getaddrinfo to get the same information. Anyone could show an example?
For now, I figured I'll just use:
`hostname --fqdn`
which works, as I only run it on Linux, but it's not really nice approach.
Got help in some other way, but figured others might benefit too.
Current way to do it is:
require 'socket'
Addrinfo.getaddrinfo(Socket.gethostname, nil).first.getnameinfo.first

sass --interactive returns FormatException: Could not find an option named "interactive"

I've get a FormatException error every time i try to invoke the sass interactive shell. Please does anyone know the reason for this and how it can be resolved. i've tried googling but all i get is syntax errors and nothing about this. please find below the error message returned.
thanks in advance for your help.
my_username$ sass --interactive
/usr/local/lib/node_modules/sass/sass.dart.js:1436
if(this===init.globalState.e)throw u}}finally{this.cy=x
^
FormatException: Could not find an option named "interactive".
at b (/usr/local/lib/node_modules/sass/sass.dart.js:1916:3)
at q (/usr/local/lib/node_modules/sass/sass.dart.js:1922:23)
at iu.fo (/usr/local/lib/node_modules/sass/sass.dart.js:6358:14)
at iu.aC (/usr/local/lib/node_modules/sass/sass.dart.js:6256:9)
at /usr/local/lib/node_modules/sass/sass.dart.js:8058:42
at uM.a (/usr/local/lib/node_modules/sass/sass.dart.js:3050:72)
at uM.dart.uM.$2 (/usr/local/lib/node_modules/sass/sass.dart.js:3146:24)
at tU.dart.tU.$1 (/usr/local/lib/node_modules/sass/sass.dart.js:3142:31)
at tn.fv (/usr/local/lib/node_modules/sass/sass.dart.js:3380:41)
at qv.$0 (/usr/local/lib/node_modules/sass/sass.dart.js:3329:16)
It looks like you're using Dart Sass, which doesn't (currently) support the --interactive flag. Feel free to file a feature request, though!

Can't push to beanstalk

I'm trying to use php git deploy for AWS Beanstalk
I got python, ruby etc installed. I setup the repository, did a git aws.config which went well. Then whenever I try to run git aws.push I get this error.
./.git/AWSDevTools/aws/dev_tools.rb:53:in `host': private method `split' called for nil:NilClass (NoMethodError)
from ./.git/AWSDevTools/aws/dev_tools.rb:112:in `signed_uri'
from .git/AWSDevTools/aws.elasticbeanstalk.push:86
Don't know much about ruby, but from what I gather it looks like it's missing a dependency maybe? I guess I'm not sure what's wrong, any help would really be appreciated.
I had this same problem, and I tracked it to a missing appRoot/.elasticbeanstalk/config file.
I added the file with the following content. Note: substitute your actual app/environment where appropriate.
.elasticbeanstalk/config >>
[global]
ApplicationName=your-application-name-east
DevToolsEndpoint=git.elasticbeanstalk.us-east-1.amazonaws.com
EnvironmentName=your-environment-name
Region=us-east-1
Ok so I did some digging through the source files. Turns out there was a permissions issue in a config file so it was creating a null class, and thus you can't string split a null.

Ruby, Sinatra and Passenger config on Apache

This is potentially a simple question but I wanted to ask to avoid running around in circles.
I have installed ruby 1.9.2 on Ubuntu and have set up passenger to run with Apache 2.2 on the machine. I am getting the following error when I view the site:
Permission denied - log/sinatra.log
I have changed the permissions for the log directory, but still no luck. The full trace from passenger can be seen on the site page: http://monkeh.me/
Does anyone know if/what I've done wrong or what's happening?
Many thanks
EDIT
I have discovered that the site runs well using WEBrick on port 4567 on the production server, but the same code errors using Passenger. I have added to show exceptions for errors, so am now getting the following:
NoMethodError at /
undefined method `include?' for nil:NilClass
file: resource.rb location: block in attributes= line: 332
You can see this here: http://www.monkeh.me/?url=http://www.google.co.uk
Any ideas? Please help :)
The new issue with the nil class was due to not finalizing the classes properly. I needed to add the following after the models were loaded:
DataMapper.finalize
Thanks to #Frost for his continued help within the comments.

Resources