Server Side Swift with Vapor: Configuring a Database | Ray Wenderlich

Learn how to connect your Vapor app to a database, such as MySQL, MongoDB, or PostgreSQL, through three simple steps.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5024-server-side-swift-with-vapor-configuring-a-database
1 Like

Hi,
I have next message at 2:19 min
How to resolved isuue?

vapor xcode
Fetching Dependencies [Failed]
Check your dependencies’ Package.swift files to see where the conflict is.
Error: warning: refname ‘1.0.0’ is ambiguous.
warning: refname ‘1.0.0’ is ambiguous.
warning: refname ‘1.0.3’ is ambiguous.
warning: refname ‘1.0.3’ is ambiguous.
warning: refname ‘1.1.0’ is ambiguous.
warning: refname ‘1.1.0’ is ambiguous.
warning: refname ‘1.0.0’ is ambiguous.
warning: refname ‘1.0.0’ is ambiguous.
swift-package: error: The dependency graph could not be satisfied. The package (GitHub - vapor/fluent: Vapor ORM (queries, models, and relations) for NoSQL and SQL databases) with version tag in range (1.0.0…<1.0.9223372036854775807) is not found. Found tags ([1.1.0])

Thank you,
Alexej

Hi Ray, the initializedProviders - init is deprecated. Use this:

try drop.addProvider(VaporPostgreSQL.Provider.self)

https://vapor.github.io/documentation/guide/provider.html

Regards

@masterfff I tried to reproduce your issue but was unable to; it builds fine for me without any issues. Could you please try downloading the materials for this screencast, and run “vapor xcode” and see if it works for you? Also please make sure you have the latest Xcode installed.

@mludl Thanks! I actually noticed this as well while working on another Vapor screencast. For everyone else, here’s what I replaced the initialization with:

let drop = Droplet()
try drop.addProvider(VaporPostgreSQL.Provider)
drop.preparations += Acronym.self
1 Like

@rwenderlich I have exactly the same problem as @masterfff. Im running Xcode 8.1

Hi Ray,

I have Xcode Version 8.0 (8A218a). It is not last one. :frowning:
Thank you,
Alexej

@masterfff @david6p2 I checked with @tanner0101 and there looks to have been a slight issue with the package file for the PostgreSQL provider, which Tanner has fixed. Try again in a few hours and you should be set. Thanks for the awesomely quick fix Tanner! :]

I’ve installed homebrew and updated.

brew --version
Homebrew 1.0.9

Ran

brew install postgres
postgres --version
postgres (PostgreSQL) 9.5.4

When I run

postgres -D /usr/local/var/postgres
LOG:  database system was shut down at 2016-11-05 15:39:52 GMT
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

Then I can’t type any commands.
Any suggestions?

I am attempting to start the PostgreSQL server, but when I run postgres -D /usr/local/var/postgres I get this output:

LOG:  could not bind IPv6 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG:  could not bind IPv6 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG:  could not bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING:  could not create listen socket for "localhost"
FATAL:  could not create any TCP/IP sockets

I did install through Homebrew. Here is my postgres version:

postgres (PostgreSQL) 9.5.4

I am running OS X 10.11.6

@alexhedley What happens if you type psql? That’s the command line interface to connect to the PostgreSQL server.

@calebkleveter Looks like PostgreSQL was running on your Mac already. Try connecting with psql and see if you get in OK. If not, uninstall any existing PostgreSQL installations and reinstall w/ homebrew.

I get

Password:
psql: FATAL:  password authentication failed for user "calebklevetertest"

I can do this as many times as I want and no matter how hard I try I always get this message.

@calebkleveter My best guess is you had another version of PostgreSQL installed earlier or some such. This thread may help: mac osx - PostgreSQL under Mac OSX Lion. Wrong userpass? - Server Fault

1 Like

@rwenderlich Thanks, that was my issue. I had to uninstall some other versions of Postgres. Problem solved!

@alexhedley. Close the terminal window you have open, then open a new window. Then run the createdb command. It should work.

Alexanders-MBP:~ AlexHedley$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I get the following:

Alexanders-MBP:~ AlexHedley$ createdb `whoami`
createdb: could not connect to database template1: could not connect to server: No such file or directory
  Is the server running locally and accepting
  connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Thought I’d supply this too:

sudo find / -name pg_hba.conf
find: /dev/fd/AlexHedley: No such file or directory
/Users/AlexHedley/Library/Application Support/Postgres/var-9.4/pg_hba.conf
/usr/local/var/postgres/pg_hba.conf

The following returns a single line, not showing postgres

ps auxw | grep post

Sorry Alex. Not really sure what is going on.

@alexhedley Yeah looks like postgres isn’t running. I just checked and mine is running with this command line:

/usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres

Can you try running it manually with that command line?

I get the same:

Alexanders-MBP:~ AlexHedley$ /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres
LOG:  database system was shut down at 2016-11-13 10:18:29 GMT
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

The cursor then stays as a flashing block not allowing any commands, think I might have to uninstall / reinstall?

@rwenderlich Tried and reinstall and now working, thanks.

"version": "PostgreSQL 9.5.5 on x86_64-apple-darwin16.1.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.42.1), 64-bit"