question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS Driver Build is Broken: SQLITE_CANTOPEN

See original GitHub issue

I’ve tracked the problem down to there not being a Librarys/Keychains/TrustStore.sqlite3 directory in the sim’s data dir, on Travis. Not sure why this would be. But the certificate trust store module then dies with SQLITE_CANTOPEN error that is uncatchable, for some reason.

The temporary solution is probably to quarantine the test on Travis. See https://github.com/appium/appium-ios-driver/pull/201

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
midopacommented, Dec 21, 2016

The most naive, brute force way to fix this is to create the paths/file/table. This is obviously fragile and can break without notice. Is there some way to trigger the simulator to create these files without have to manually recreate a SQLite database/table/schema?

Otherwise, here’s a patch for getting the file created. It goes in appium-ios-simulator. I’m not inclined to submit a PR for this since it’s sooo hacky:

diff --git a/lib/certificate.js b/lib/certificate.js
index 11cf4e7..6b10150 100644
--- a/lib/certificate.js
+++ b/lib/certificate.js
@@ -1,6 +1,8 @@
+import log from './logger';
 import crypto from 'crypto';
 import B from 'bluebird';
 import path from 'path';
+import fs from 'fs';

 const sqlite3 = B.promisifyAll(require('sqlite3'));
 const openssl = B.promisify(require('openssl-wrapper').exec);
@@ -110,8 +112,22 @@ class Certificate {
  */
 class TrustStore {
   constructor (sharedResourceDir) {
-    this.sqliteDBPath = path.resolve(sharedResourceDir, 'Library/Keychains/TrustStore.sqlite3');
+    let sqlDBFolder = path.resolve(sharedResourceDir, 'Library/Keychains');
+    let folderExists = fs.existsSync(sqlDBFolder);
+    if (!folderExists) {
+      log.warn('SQLite DB folder did not exist. Creating');
+      fs.mkdirSync(sqlDBFolder);
+    }
+
+    this.sqliteDBPath = path.resolve(sqlDBFolder, 'TrustStore.sqlite3');
+    let dbFileExists = fs.existsSync(this.sqliteDBPath);
     this.db = new sqlite3.Database(this.sqliteDBPath);
+
+    // We'll have to create the tables
+    if (!dbFileExists) {
+      log.warn('Recreating SQLite DB...');
+      this.db.exec("CREATE TABLE tsettings(sha1 BLOB NOT NULL DEFAULT '',subj BLOB NOT NULL DEFAULT '',tset BLOB,data BLOB,PRIMARY KEY(sha1)); CREATE INDEX isubj ON tsettings(subj);");
+    }
   }

   /**

The schema was lifted from opening and inspecting the TrustStore DB after drag/dropping a self-signed cert onto the simulator and installing it.

0reactions
lock[bot]commented, Apr 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLITE_CANTOPEN - windows c++ - Stack Overflow
I am trying to create an Sqlite database in the selected folder but can`t do this. Operating System - Windows, editor - Visual...
Read more >
error: sqlite_cantopen: unable to open database file - You.com
Its working fine on using npm start (on normally run) but not working when i try to create release file for linux using...
Read more >
Unable to open database file" using SQLite on Windows ...
I am using SQLite for Windows Phone 7 (http://sqlitewindowsphone.codeplex.com/) and I have done every steps from this tutorial ...
Read more >
4458 check-ins using file mkopcodeh.awk version 29b8465650
Fixes for builds without SQLITE_ENABLE_STAT4. check-in: 84999e27cc user: dan ... to the commit breaks the build. check-in: 71effa59c9 user: dan tags: typo.
Read more >
Documentation - Fossil SCM
If the output buffer ** is not large enough, [SQLITE_CANTOPEN] should be ... The PRNG is also used for ** the build-in random()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found