(1) By jscchank (jschank) on 2021-01-25 15:43:45 [link]
I'm not sure where in the process this occurred, but I am creating a web-app using nest.js and typeorm to connect to a sqlite3 database. And I used detenv to specify the database location. I am using a Mac, latest version of Big Sur, if that helps. I was using '~/.appname/database.sqlite' as the database path. I am pretty sure this resulted in a hard link to ~ being created in my project directory. As you can imagine. such a link is **scary** and difficult to get rid of. Does this sound like it is a problem with: - sqlite3 - typeorm - nest.js - dotenv Because I think it is unexpected behavior, and a bug ticket should be filed with the appropriate software project.
(2) By Stephan Beal (stephan) on 2021-01-25 15:48:27 in reply to 1 [link]
> Because I think it is unexpected behavior, and a bug ticket should be filed with the appropriate software project. In this case, that would be your project. Expansion of the tilde is a function of a Unix shell, which doesn't come into play when passing paths directly (or, in the case of a JS binding, indirectly) to the C APIs which deal with filenames.
(3) By Stephan Beal (stephan) on 2021-01-25 17:04:17 in reply to 1
Some more context now that i'm back on a computer... > I am pretty sure this resulted in a hard link to ~ being created in my project directory. That's definitely not what happened: hardlinks to directories are not possible in Unix because they can create endless loops and apps cannot, using C-standard APIs, distinguish between "normal" files and hard links because there is no difference. A hard link is just an increased reference count on an existing file (which is why hard links cannot span filesystems). > I was using '~/.appname/database.sqlite' as the database path. What has, in all likelihood, happened is that the JS wrapper you're passing that path to has decided to create all directories, if needed, for the path it is given. You gave it a *relative* path which starts with a directory named `~` (which is a perfectly legal directory name). Under that, it created `.appname`, then it passed the whole string to sqlite, which finds that directory and creates `database.sqlite`. That's my bet, anyway.
(4) By anonymous on 2021-01-26 07:43:20 in reply to 1 [link]
> As you can imagine. such a link is scary and difficult to get rid of. I think that a safe way of removing the tilde-named directory (thanks Stephan for explaining what happened!) is by addressing it as `./~` or `'~'` in the shell. Feel free to experiment with this by creating a throw-away user on a virtual machine.
(5) By Trudge on 2021-01-26 17:24:19 in reply to 4 [link]