SeaORM: The connection string 'sqlite://test.db' has no supporting driver - rust

Using sea-orm-cli to generate a database using sea-orm-cli migrate but this gives the error
thread 'main' panicked at 'called Result::unwrap() on an Err
value: Conn("The connection string 'sqlite://test.db' has no
supporting driver.")',
.../.cargo/registry/src/github.com-1ecc6299db9ec823/sea-orm-migration-0.8.3/src/cli.rs:17:45
Anything missing here? The cargo.toml contains the sqlite features so I'd assume this should work.
sea-orm = { version = "0.8.0", features = [ "sqlx-mysql", "sqlx-sqlite", "runtime-tokio-rustls", "macros", "debug-print", "mock" ] }

You need to make sure that the DATABASE_DRIVER and ASYNC_RUNTIME is also included in ./migration/cargo.toml.

Related

How to get Bevy to run longer than 5 seconds on Windows 11 with Geforce RTX 2060

I'm trying to go through the Bevy docs and have noticed that I absoilutely cannot run a single example or basic app for longer than about 5 seconds without getting errors breaking execution. Is there something special outside of the doc's setup needed to get things to run or is Bevy just broken for an up-to-date Windows 11 + Geforce RTX 2060 machine?
Doesn't matter which example I run or try to follow along with the docs, this always happens:
PS C:\Development\GameDev\my_bevy_game> cargo run
warning: unused manifest key: target.aarch64-apple-darwin.rustflags
warning: unused manifest key: target.x86_64-apple-darwin.rustflags
warning: unused manifest key: target.x86_64-pc-windows-msvc.linker
warning: unused manifest key: target.x86_64-pc-windows-msvc.rustflags
warning: unused manifest key: target.x86_64-unknown-linux-gnu.linker
warning: unused manifest key: target.x86_64-unknown-linux-gnu.rustflags
Compiling my_bevy_game v0.1.0 (C:\Development\GameDev\my_bevy_game)
Finished dev [unoptimized + debuginfo] target(s) in 4.01s
Running `target\debug\my_bevy_game.exe`
2022-04-18T15:56:45.590239Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
setupLoaderTrampPhysDevs: Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
2022-04-18T15:56:45.591644Z ERROR wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x207c17a7b00, name: ?)
2022-04-18T15:56:45.592432Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
setupLoaderTrampPhysDevs: Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
2022-04-18T15:56:45.592561Z ERROR wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x207c17a7b00, name: ?)
2022-04-18T15:56:45.901926Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2060", vendor: 4318, device: 7957, device_type: DiscreteGpu, backend: Dx12 }
hello Elaina Proctor!
hello Renzo Hume!
hello Zayna Nieves!
2022-04-18T15:56:48.506223Z ERROR present_frames: wgpu_hal::dx12::instance: ID3D12CommandQueue::Present: Resource state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) (promoted from COMMON state) of resource (0x00000207DD7D0A70:'Unnamed ID3D12Resource Object') (subresource: 0) must be in COMMON state when transitioning to use in a different Command List type, because resource state on previous Command List type : D3D12_COMMAND_LIST_TYPE_COPY, is actually incompatible and different from that on the next Command List type : D3D12_COMMAND_LIST_TYPE_DIRECT. [ RESOURCE_MANIPULATION ERROR #990: RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE]
error: process didn't exit successfully: `target\debug\my_bevy_game.exe` (exit code: 1)
PS C:\Development\GameDev\my_bevy_game>
The Rust code I made from the book (please note this happens with the bevy repo's untouched example code as well):
use bevy::prelude::*;
pub struct HelloPlugin;
struct GreetTimer(Timer);
#[derive(Component)]
struct Person;
#[derive(Component)]
struct Name(String);
impl Plugin for HelloPlugin {
fn build(&self, app: &mut App) {
// the reason we call from_seconds with the true flag is to make the timer repeat itself
app.insert_resource(GreetTimer(Timer::from_seconds(2.0, true)))
.add_startup_system(add_people)
.add_system(greet_people);
}
}
fn greet_people(time: Res<Time>, mut timer: ResMut<GreetTimer>, query: Query<&Name, With<Person>>) {
// update our timer with the time elapsed since the last update
// if that caused the timer to finish, we say hello to everyone
if timer.0.tick(time.delta()).just_finished() {
for name in query.iter() {
println!("hello {}!", name.0);
}
}
}
fn add_people(mut commands: Commands) {
commands
.spawn()
.insert(Person)
.insert(Name("Elaina Proctor".to_string()));
commands
.spawn()
.insert(Person)
.insert(Name("Renzo Hume".to_string()));
commands
.spawn()
.insert(Person)
.insert(Name("Zayna Nieves".to_string()));
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(HelloPlugin)
.run();
}
You can see from the output that I'm trying to run the my_bevy_game example from the book, but this exact same issue with wgpu occurs on all the examples I've run thus far. What does one need to do to run anything with Bevy?
-- edit --
It would appear that this is a dx12 issue that WGPU needs to address. The proposed workarounds in the Bevy issue don't work for my, and other's, machine. It would appear that Bevy is "broken" irreparably for the time being, due to depending on WGPU.
It look like a bug see issues #4461 of bevy the bug was inside wgpu:
You can try to temporary use the last wgpu version:
[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
# or
wgpu = { git = "https://github.com/gfx-rs/wgpu" , rev = "3d10678a91b78557b0dea537407eb4a4ff754872" }

How to create a target specific profile in Cargo.toml?

I would like to specify a separate [profile.release] for my library when cfg(target_os = "ios") is active. I tried this:
[profile.'cfg(not(target_os = "ios"))'.release]
lto = true # Use link-time optimization.
[profile.'cfg(target_os = "ios")'.release]
lto = true # Use link-time optimization.
opt-level = "z" # Mobile devices are fast enough. Optimize for size instead.
strip = "symbols" # Not relevant for windows.
However when I now try to build my project / workspace I get the following error:
error: failed to parse manifest at `/path/to/Cargo.toml`
Caused by:
invalid character `(` in profile name `cfg(not(target_os = "ios"))`
Allowed characters are letters, numbers, underscore, and hyphen.
which is to be expected, because according to the documentation only [profile.<name>] is allowed.
Is there any method to achieve the desired behaviour?
P.S. The full target name would be aarch64-apple-ios in case this is needed.
This was requested in issue #4897, Per-target profiles?, but not yet implemented.
In the meantime, you can use a script that checks the target and set environment variables to override config (for example, set CARGO_PROFILE_RELEASE_LTO or CARGO_PROFILE_RELEASE_OPT_LEVEL) then invokes Cargo with them.
Here is an example, from users.rust-lang.org - How to modify profile.release only for a target?
Create a binary in the workspace named e.g. custom_build. In custom_build/src/main.rs put:
use std::env;
use std::process::Command;
fn main() {
let mut cargo = Command::new(env::var_os("CARGO").unwrap());
cargo.env("CARGO_CUSTOM_BUILD", "1"); // So we can disallow regular builds, to prevent mistakes
cargo.args(env::args_os().skip(1));
// You can determine the target OS by various way, but providing it manually to the build script is the simplest.
let for_ios = env::var("build_ios").is_ok();
if for_ios {
cargo.env("CARGO_PROFILE_RELEASE_LTO", "true");
cargo.env("CARGO_PROFILE_RELEASE_OPT_LEVEL", "z");
cargo.env("CARGO_PROFILE_RELEASE_STRIP", "symbols");
} else {
cargo.env("CARGO_PROFILE_RELEASE_LTO", "true");
}
let cargo_succeeded = cargo.status().ok().map_or(false, |status| status.success());
if !cargo_succeeded {
std::process::exit(1);
}
}
Then you can create a build.rs file to prevent manually running cargo:
use std::env;
fn main() {
if !env::var("CARGO_CUSTOM_BUILD").ok().map_or(false, |s| s == "1") {
panic!("Do not run `cargo ...`, run `cargo custom_build ...` instead")
}
}

Why does GetModuleHandleA return NULL?

I am trying to load a custom resource (.rc) from a .dll but the FindResource() function always ends up returning NULL
This is my code trying to load the resource:
HINSTANCE FragDll;
FragDll = GetModuleHandleA((LPCSTR)"FragmentShaders.dll");
HRSRC FragResource = FindResource(FragDll, MAKEINTRESOURCE(StartMenu_frag), L"FRAGMENTSHADER");
if (FragResource)
{
HGLOBAL FragLoadedResource = LoadResource(FragDll, FragResource);
if (FragLoadedResource)
{
LPVOID FragLockedResource = LockResource(FragLoadedResource);
if (FragLockedResource)
{
DWORD FragdwResourceSize = SizeofResource(FragDll, FragResource);
if (0 != FragdwResourceSize)
{
// Use pLockedResource and dwResourceSize however you want
}
}
}
}
FragResource for some reason always returns NULL. Does anyone know how to fix this?
Edit:
I have done a breakpoint in visual studios to get more information:
Values during runtime
EDIT:
If this method of loading resources from a .dll doesnt work, please then give another method of reading a resource (.rc) from a .dll.
as others pointed out in the commentaries, the problem here is not that FragRessource is Null, it is null because FragDLL is null in the first place.
So we come to why is FragDLL null ?
As stated in the documentation (https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea) of GetModuleHandleA : "The module must have been loaded by the calling process." Which means you have to load the module before retrieving his handle. You can do so using LoadLibraryExA (https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa).
Hopes this helps

Error: Invalid cache option true found. Expected "memory"

this error shows in cmd using rhc tail socialinteractive
i hosted this site to openshfit i use swig and modules consolidate and swing for template
guide me to slove this error
Error: Invalid cache option true found. Expected "memory" or { get: function (ke
y) { ... }, set: function (key, value) { ... } }.
at validateOptions (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/run
time/repo/node_modules/swig/lib/swig.js:113:15)
at parse (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtime/repo/
node_modules/swig/lib/swig.js:339:5)
at Object.precompile (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/r
untime/repo/node_modules/swig/lib/swig.js:486:23)
at Object.compile (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/runt
ime/repo/node_modules/swig/lib/swig.js:606:16)
at Function.exports.swig.render (/var/lib/openshift/5453580c500446bfbc000d3c
/app-root/runtime/repo/node_modules/consolidate/lib/consolidate.js:246:56)
at /var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtime/repo/node_mo
dules/consolidate/lib/consolidate.js:146:25
at read (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtime/repo/n
ode_modules/consolidate/lib/consolidate.js:91:22)
at /var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtime/repo/node_mo
dules/consolidate/lib/consolidate.js:144:9
at readPartials (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtim
e/repo/node_modules/consolidate/lib/consolidate.js:114:33)
at View.engine (/var/lib/openshift/5453580c500446bfbc000d3c/app-root/runtime
/repo/node_modules/consolidate/lib/consolidate.js:139:5)
GET / 500 4.312 ms - -
This is consolidate.js bug, not OpenShift bug.
It has been already addressed upstream, see:
https://github.com/tj/consolidate.js/pull/134
Either you need to update your consolidate.js npm package once they release version greater than 0.10.0.
Or you can use the following workaround (as suggested by #truongminh):
app.locals.cache = "memory"

Upgrade to varnish v4

We've upgraded varnish v3 to v4 and I currently working on converting my vcl.
In the v3 version we've used inline C to set and read headers with following functions:
VRT_GetHdr(sp, HDR_REQ, header);
VRT_SetHdr(sp, HDR_REQ, header, value , vrt_magic_string_end);
However in version 4 those functions are are slighty changed.
After some searching we've found that's we need to use a kind of a structure to define a header.
VCL_HEADER hdrdef;
hdrdef->where = HDR_REQ;
hdrdef->what = "\005Test:";
When using this we get a compiler fail with message that it cannot assign to a read only object.
Do somebody know how we can utilize/fill this structure?
Thanks in advance!
Kristof
This should do the trick:
C{
static const struct gethdr_s VGC_HDR_REQ_hdrdef = { HDR_REQ, "\005Test:" };
}C
C{
VRT_SetHdr(ctx, &VGC_HDR_REQ_hdrdef, value, vrt_magic_string_end);
}C
See: https://github.com/varnish/Varnish-Cache/blob/master/bin/varnishtest/tests/r01406.vtc

Resources