@alexhedley Awesome, Iām glad you got it working!
What did you reinstall, exactly? I have the same issues that you had, and reinstalling postgres didnāt fix it.
I ran
brew uninstall <same package name>
finally have a chance to sit down and go through all the screencasts with time and some detail. I wanted to do something a bit differently because I already have mySQL installed.
as just a note I suspect my paths are different since I installed mySQL from a DMG versus brew. so I had to edit the compiler and linker settings to have the correct path settings.
compiler addition
-I/usr/local/mysql/include
linker addition
-L/usr/local/mysql/lib
hope this helps that might run into problems that I had.
alos trying to clear the version but still not updating the commands
i found the fix for Alex problem ( ie. stuck after postgres -D /usr/local/var/postgres`)
Dont try to quit or anything, just open a new terminal window and execute the commands in the new window (ie create db)
One thing to note.
If you configure your Droplet the way it is one it in the screen cast it will break your CSS. Use the code below to fix this problem:
try drop.addProvider(VaporPostgreSQL.Provider.self)
Thereās been a few updates since this screencast was created. Here are a few extra steps that I had to take to get the project running:
- No
secrets
folder underConfig
.
Solution: Make your ownsecrets
folder by using command + n while youāre in theConfig
folder. - As @calebkleveter pointed out, you need to use
try drop.addProvider(VaporPostgreSQL.Provider.self)
. Compiler now warns if you try to use the initializer that takes in providers.
Thanks @kelvin_lau! :]
@dniswhite hi,
I think that I have the same problem (which is installing mysql from DMG and not from homebrew). I get errors with the package when I compile. my question is how did you edit the compiler and linker? I mean what exact steps should I take.
I had to change the project settings like I listed in my post.
unfortunately I found that really wasnāt the best option best every time you generate with vapor xcode you lose those settings and have to do it all over again. the best option is to remove mySQL and install via homebrew.
I just scrapped mySQL and left things the way they were and moved on with postgreSQL.
hi ray im having an issue when saving cant figure out the issue
thats the error im getting
{
ācodeā: 500,
āerrorā: true,
āmessageā: āThe operation couldnāt be completed. (PostgreSQL.DatabaseError error 1.)ā,
āmetadataā: null
}
@rotemd1 Have you tried setting the user name and database name in the json file to your macOS user name, which is displayed in the Terminal ?
by the way, @rwenderlich. recently the entire screencast videos are not played in Safari 10.0.2. so I am using Chrome for the moment. is this happening only to me?
I just had a similar issue and resolved it.
First, what I initially did wrong is that I had added the wrong link into the Package.swift file. I put the driver in (GitHub - vapor-community/postgresql-driver: PostgreSQL driver for Fluent), and ran āvapor Xcodeā. Then I corrected it but got āwarning: refname ā1.0.3ā is ambiguous.ā errors.
Fetching Dependencies [Failed]
Error: warning: refname ā1.0.0ā is ambiguous.
warning: refname ā1.0.0ā is ambiguous.
warning: refname ā1.0.5ā is ambiguous.
warning: refname ā1.0.5ā is ambiguous.
swift-package: error: rename error: Directory not empty (66): /Users/ronanocsono/Documents/Code/PersonalProjects/vapor/HelloPersistance/Packages/postgresql-driver.git ā /Users/ronanocsono/Documents/Code/PersonalProjects/vapor/HelloPersistance/Packages/FluentPostgreSQL-1.0.5
To fix it, cd into the Packages and ārm -rfā all those related to PostgreSQL:
rm -rf FluentPostgreSQL-1.0.5
rm -rf postgresql-provider
rm -rf postgresql-driver.git
rm -rf PostgreSQL-1.1.0
rm -rf CPostgreSQL-1.0.0
Then cd ā¦/ and run āvapor xcodeā again and it works.
Hi I installed postgresql using Homebrew. Command āpostgres -D /usr/local/var/postgresā results in an error I couldnāt solve for the past 3 days:
FATAL: postmaster became multithreaded during startup
HINT: Set the LC_ALL environment variable to a valid locale.
LOG: database system is shut down
After researching, I set the local variables in .bash_profile by adding these lines:
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
This was the only suggestion I could find on the Internet but it didnāt help, the error stayed the same (I tried restarting the computer after setting the variables, uninstalling and installing postgresql). I ran out of options, every kind of advice is really appreciated. The version is 9.6.3.
Hi Ray,
Nice Tutorial. An update to get things working:
Package.swift
.Package(url: āGitHub - vapor/vapor: š§ A server-side Swift HTTP web framework.ā, majorVersion: 2),
.Package(url: āGitHub - vapor-community/postgresql-provider: PostgreSQL Provider for the Vapor web framework.ā, majorVersion: 2),
.Package(url: āGitHub - vapor-community/fluent-provider: A provider for including Fluent in Vapor applicationsā, majorVersion: 1)
Config+Setup.swift
import PostgreSQLProvider
private func setupProviders() throws {
try addProvider(FluentProvider.Provider.self)
try addProvider(PostgreSQLProvider.Provider.self)
}
Routes.swift:
import PostgreSQLProvider
get(āversionā) {req in
let version = try self.postgresql().raw(āSELECT version()ā);
return try JSON(node: version)
}
Config/postgresql.json. (not secret)
{
āhostnameā: ā127.0.0.1ā,
āuserā: āwhoamiā, (current user)
āpasswordā: āā,
ādatabaseā: āwhoamiā, (current database)
āportā: 5432
}
fluent.json
ādriverā: āpostgresqlā,
And it works. Keep up the good work Ray!
Thanks for sharing the updates! :]
Hi there guysā¦ @rwenderlich this is my error when call localHost:8080/version:
[SQLite.StatusError: error(āno such function: versionā)]
Conform āSQLite.StatusErrorā to Debugging.Debuggable to provide more debug information.
And in the brower is error 500
Thanks