Problems with postgres and Unicorn server - postgresql

When I try running Unicorn after setting up postgres (works perfectly with Trinidad and Thin) I get the following error.
dyld: lazy symbol binding failed:
Symbol not found: _rb_thread_select
Referenced from:/Users/pls/.rvm/gems/ruby-2.2.0#coinino/extensions/x86_64-darwin-13/2.2.0/do_postgres-0.10.14/do_postgres/do_postgres.bundle
Expected in: flat namespace
Datamapper connects to the database normally inside a model.rb which then is required in app.rb.
What is wrong and how do I fix it?
Edit: Looks like this is a bug in Ruby 2.2.0.

A call used by old versions of the pg gem has been removed in Ruby 2.2. More recent versions of the gem no longer use this call; I know the latest version (0.18.1) doesn't, but I don't know when that change was made. You can update the pg gem by running the following command:
bundle update pg
As long as you're doing this, you may want to run just a plain bundle update to update all of your project's gems to the most recent versions—who knows what else might be incompatible with Ruby 2.2?
As always when updating dependencies, test that the update doesn't introduce any new bugs before you deploy the new version to production. I doubt pg will cause any problems, but other gems might.

It looks like this is a bug in Ruby 2.2.0. Going to Ruby 2.1.5 gets things going without trouble.

Related

'if not "giveaway rig" in str(ctx.command): AttributeError: 'CheckFailure' object has no attribute 'command'` Can you tell how to fix this?

This is my code:
#bot.event
async def on_command_error(error, ctx):
if not "giveaway rig" in str(ctx.command):
if isinstance(error, commands.CommandNotFound):
pass
elif isinstance(error, commands.MissingRequiredArgument):
await send_cmd_help(ctx)
elif isinstance(error, commands.BadArgument):
await send_cmd_help(ctx)
else:
await ctx.bot.send_message(ctx.message.channel, defaultGiveawayErrorMessage)
And when it runs, this error shows:
if not "giveaway rig" in str(ctx.command):
AttributeError: 'CheckFailure' object has no attribute 'command'
How can I fix this?
The issue at hand:
You've got your event's parameters the wrong way round.
Swap them around like so:
async def on_command_error(ctx, error):
Discord.py version:
And from the looks of things, you seem to be using some async code:
await ctx.bot.send_message(ctx.message.channel, defaultGiveawayErrorMessage)
which, in rewrite (v1.x), can be written as:
await ctx.send(defaultGiveawayErrorMessage)
The rewrite and async versions of d.py are not compatible, and you will need to update your version of d.py.
You can do this by running:
pip install -U discord.py
and you'll know whether you have the rewrite version judging by if you see this in your output:
Requirement already up-to-date: discord.py in c:\PATH\TO\python\python35\lib\site-packages (1.X.X)
(Note the version number at the end)
Some issues that may arise:
You've got it installed successfully, but running your script errors when using rewrite's documentation.
Cause: This is because you may be trying to run the script on a version of python that discord.py wasn't installed on.
Fixes:
If this was done in a virtual environment, it should be an easy enough fix - just open up the venv's terminal and make sure you run the command there (not in your cmd prompt!).
If you're not using a venv, it'd be your best bet to just make sure you have one version of Python installed.
Whenever you run the command pip install -U discord.py, you're only getting v0.16.x installed.
Cause: You're installing the package on an outdated version of Python.
Fixes:
discord.py, as of this answer, only supports Python versions 3.5.3 and above.
This means that you need to upgrade your version of Python.
If you're still encountering this issue and you're sure you've got a version of 3.5.3 or above, check the current versions of Python that discord.py supports. A nice and simple fix for this is to make sure you only have one version of Python installed again.
And with that being said, I highly recommend using the rewrite docs, and if you want to follow any tutorials, make sure they're up-to-date (include rewrite as a keyword in your searches).
The rewrite version is much, much nicer than async, and at first it may be a bit difficult to get to grips with what's changed, which is what this page is for. It'll help build the foundations for your migration to the newer d.py version.
References:
Major model changes - Moving from async to rewrite, I highly recommend reading through this, as it could fix any issues that you run into when you get started.
OS-specific installations - For if you're still running into issues during installation.
on_command_error()
commands.Context - You will, depending on what your bot does, be using context instances a LOT of the time. Get familiar with what attributes and methods you can access - it'll save you a lot of headaches in the future.

PostgreSQL 10.6_1 Extensions Missing

I'm looking for a way around a bug I found with the OSX PostgreSQL 10.6_1 Extensions mapping. Upon update, it misses the new directory for the binaries and the PG gem can't find them:
2019-02-09 17:48:06 - PG::UndefinedFile - ERROR: could not access file "$libdir/uuid-ossp": No such file or directory
I've filed the bug with PostgreSQL but I need a workaround until they fix it. Anybody have any ideas how I can get this to work? My app relies on this and a slight version change has halted my work. Installed with Homebrew, contacted the package manager and PostgreSQL.

Error running Python on OpsWorks with Chef + Berkshelf

I'm trying to get Python 2.7 working on my OpsWorks instance but I keep running into errors starting up.
My OpsWork stack is set up with Chef version 11.10 and Berkshelf version 3.2.0.
My metadata.rb has the following in it:
depends "poise-python"
depends "apt", ">= 1.8.2"
My Berksfile is set up with:
source "https://supermarket.chef.io"
cookbook 'poise-python'
cookbook 'apt'
Every time I launch I keep getting the following error and I'm not sure how to resolve it:
Halite is not compatible with no_lazy_load false, please set
no_lazy_load true in your Chef configuration file.
I tried adding a chef/configuration.rb file to set no_lazy_load to true but it doesn't seem to be working. Frankly I'm new to OpsWorks and Chef so I may be missing something very basic.
More Info
The stack I'm taking over originally referenced python instead of poise-python but I had switched from that to resolve a different error (but, I guess, related) when I tried to run with that:
This resource is written with Chef 12.5 custom resources, and requires
at least Chef 12.0 used with the compat_resource cookbook, it will not
work with Chef 11.x clients, and those users must pin their cookbooks
to older versions or upgrade.
I tried pinning to an older version of python but still couldn't get it to work. Basically, I know this instance can run (previous maintainer had it going) but I'm not sure what I'm missing.
After some Googling, I figured out how to make this work without upgrading Chef version. I added the following line to my Berksfile:
cookbook 'build-essential', '= 3.2.0'
My cookbooks aren't compatible with Chef 11, you'll have to upgrade your stack to Chef 12.

Installing mongo_fdw

I am trying to install mongo_fdw on Ubuntu but I am getting some compilation errors. I have installed mongodb, postgresql 9.1, postgresql-server-dev and libpq-dev using apt-get.
I have updated the $PATH as instructed, cd to the directory with the mongo_fdw sources and typed make.
The code starts compiling but then I get errors (some objects and methods aren't found). What am I missing?
It's possible that the extension you're using expects the 9.2 version of the foreign data wrapper API, which has read/write support. Without details like exact errors it's impossible to say for sure.

Undefined method 'group' for #<Sunspot::Search::StandardSearch

Here's the error I'm hitting
NoMethodError: undefined method `group' for Sunspot::Search::StandardSearch:
I have sunspot version 1.2.1 and solr version 3.6. I also tested the grouping functionality with the solr version installed on my server by modifying the url and it works like a breeze.
However it breaks with the current sunspot version I have. I updated the sunspot gem to version 1.3.3 but it still breaks.
I'm pretty sure the syntax is correct because I followed the examples in the documentation:
https://github.com/sunspot/sunspot
I've looked around and this is the relevant answer i've found but doesn't help. Maybe i'm missing something?
Group using Sunspot/Solr?
These are the gems i've got installed:
gem 'sunspot_rails', '1.3.1'
gem 'sunspot_solr'
EDIT
Here's the code that is breaking. It is same as the documentation. ':question' is a single value text field I want to group on.
search.group(:question).groups.each do |group|
puts group.value
end
Problem Solved
Grouping is supported in Sunspot version 2.0.0
Hence the simple fix was just including the sunspot 2.0.0 gem and a bundle install.