Vapor migrate command not found - swift

I installed a swift vapor web-server and I have to run some migrations. Reading from the docs(https://docs.vapor.codes/fluent/migration/?h=migrate#migrate) it says that I just have to run vapor run migrate but all I get is an error that says .unknownCommand("migrate", available: ["boot", "serve", "routes"]). It seems the vapor toolbox doesn't have the migrate command. I installed the vapor toolbox following the docs(https://docs.vapor.codes/install/linux/#install-toolbox):
git clone https://github.com/vapor/toolbox.git
cd toolbox
git checkout <desired version>
make install
To be fair i had some problems with the make install comand. It said that swiftc wasn't a valid comand but I just changed swiftc to swift inside the Makefile and it did compile at the end. As a matter of fact the vapor --version command works.
I use swift 5.5 and vapor 4. Does anybody now how to fix this or find some workaround like running the migration file by itself without the command?

I don't really use the vapor toolbox anymore. I put the second line in main.swift in the Sources/App/Run folder:
// earlier lines omitted
try configure(app)
try app.autoMigrate().wait() // <-- this one needs to be in this position
try app.run()
It needs to be after everything has been configured but before you start the app running.

Related

How to run swift and libDispatch on ARM (Raspberry Pi)

The aim is to run swift and libDispatch on a Raspberry Pi 3. I’m using Ubuntu Core 16.04
Where I’m at: I’ve tried to get SR-397 (https://bugs.swift.org/browse/SR-397) to compile - it is a minimal Swift libDispatch example.
The projects for this SR are here: https://github.com/sheffler/gcd4 and here: https://github.com/sheffler/CDispatch
When I try to compile the gcd4 project, I get this error: “error: Empty manifest file is not supported anymore. Use swift package init to autogenerate.”
I assumed the error message was due to the empty Package.swift file, so then I copied the Sheffler CDispatch project to https://github.com/tree700/CDispatch and added a Package.swift file. I still get the same error and haven't been able to get past it.
By way of background, I’m using a precompiled download of Swift 3.1.1 from https://github.com/uraimo/buildSwiftOnARM, and have installed Ubuntu libdispatch0 and libdispatch-dev packages and dependencies on my system. The swift compiler and Swift Package Manager are working fine,
I’d love to get this going, I use Dispatch on OS X, and it makes concurrency a breeze. Thanks
The answer was simple... the extra information required is in the associated blog. To obtain and install Swift 3.1.1 go to https://www.uraimo.com/2017/09/06/A-small-update-on-Swift-for-raspberry-pi-zero-1-2-3/
Which says to do this...
sudo apt-get install git cmake ninja-build clang-3.8 python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 100
After that, there is the the usual process of decompressing the compressed project file and adding the usr/bin directory into one's path (or run swift, swift etc from inside usr/bin)
Note: I also had to install the package libpthread-workqueue-dev. If running on Raspbian, requires an upgrade to Stretch .
———
By the way, I posted the SO question when using a Raspberry 3. In fact, I was on an early Pi model B when I got this working. The Pi 3 will soon have Swift also. Here is a simple Swift program to test libdispatch:-
import Foundation
import Dispatch
let queue = DispatchQueue(label: "queueName")
let workItem = DispatchWorkItem(qos: .userInitiated, flags: .assignCurrentContext) {
print("Hello")
}
queue.async(execute: workItem)
DispatchQueue.main.async {
print("Hello2")
}
dispatchMain()

Can't execute commands in Swift on Ubuntu 14.04

I have just installed Swift 3.0.1 on Ubuntu 14.04 via Vapor tutorial.
curl -sL swift.vapor.sh/ubuntu | bash
Here I received information about that clang version >=3.4 is required.
So I manualy have installed clang 3.5 and linked this to clang.
Next I run swift command and try to run any swift command like:
print("Hello")
let w = "hello"
But swift ends with segmentation fault.
Welcome to Swift version 3.0.1 (swift-3.0.1-RELEASE). Type :help for assistance.
1> print("Hello")
Segmentation fault
Things I have tried
different swift versions
different clang versions
chmod -R o+r on swift folder
Anyone can help?
Okay. This server was made on OpenVZ virtualization.
Now I have a new one on the KVM and I have made all the same steps and it works...
So solution for my problem was to change virtualization to KVM. Maybe it was a problem of host or OpenVZ itself. No clue.

Error in matcaffe installation

The above error showed up when I tried to install matcaffe in ubuntu. I switched to caffe root directory, and ran the following commands:
$ cd /home/naved/Desktop/caffe-master
$ make all matcaffe
$ make mattest
My matlab version is 2011a.
After running make mattest, the error above showed up.
What should I do to solve this problem?
I believe that the functionality for custom unit test caffe(and specifically the package matlab.unittest.TestCase) was introduced in version R2015a of MATLAB, and that if you're on an older version it won't be available

Swift Build no such command

python-swiftclient 3.0.0
Ubuntu 16.04.1 LTS
I type in swift build and it returns the list of swift commands and says at the end no such command. Could not find anyone describing this specific command line response.
That's because you use either python-swiftclient either your PATH is wrong.
If swift --version returns:
python-swiftclient 3.0.0
Then you aren't currently calling swift build system. Check this link and update your swift release here.
Else check that you call the right swift executable by doing:
which swift
The output is the executable you are actually calling.
Environmental variable failure
just
source ~/.bashrc
Seems that the entire swift environment is needed, so visit the swift download page, and choose your system (mine is ubuntu 18.04):
$ wget https://download.swift.org/swift-5.5.2-release/ubuntu1804/swift-5.5.2-RELEASE/swift-5.5.2-RELEASE-ubuntu18.04.tar.gz
$ tar -xf swift-5.5.2-RELEASE-ubuntu18.04.tar.gz
$ PATH=~/swift-5.5.2-RELEASE-ubuntu18.04/usr/bin:$PATH
This solution worked perfect for me.

Lpsolve matlab installation error

The error is:
Error using mxlpsolve
Failed to initialise lpsolve library.
I run the
Makefile.m
in the folder and the compiliation, it says everything compiled fine. Where do i need to put mslpsolve and where do i find it?
I used the following guide to solve the same problem:
http://lp-solve.2324885.n4.nabble.com/Fwd-Re-lpsolve-in-MATLAB-on-Mac-OS-X-10-8-2-td1770.html
the only thing that was missed within the guide and I added it up is as follows:
$ cd $HOME/Documents/MATLAB/lp_solve_5.5/extra/MATLAB/lpsolve
$ sudo ln -s /opt/local/lib/liblpsolve55.dylib liblpsolve55.so
make sure that you have installed lp_solve package already.