Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"IO error: Failed to create dir: Invalid argument" when having non-latin characters in folder name (only on windows) #40

Open
apolkingg8 opened this issue Feb 27, 2018 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@apolkingg8
Copy link

const rocksdb = require("rocksdb")
const path = require("path")

rocksdb(path.resolve(__dirname, '中文')).open(function (res) {
    debugger
})
IO error: Failed to create dir: G:\GitHub\pouchdown-chinese-test\中文: Invalid argument

Mac works fine, only happened on Windows.

@apolkingg8
Copy link
Author

Tried leveldown, and it works.

const leveldown = require("leveldown")
const path = require("path")

leveldown(path.resolve(__dirname, '中文')).open(function (res) {
    debugger
})

@apolkingg8
Copy link
Author

Found a similar issue in a rust-rocksdb binding. Maybe we can do something like this PR in node binding file for this issue?

@ralphtheninja
Copy link
Member

Not exactly sure where the problem lies. Since it works on leveldown and rocksdb basically is a fork of that, there is either some differences in that layer or in the native lib itself. I took a quick glance at leveldown and it seems to me that we are just passing in a utf8-string to the C++ layer.

@ralphtheninja ralphtheninja added the bug Something isn't working label Feb 27, 2018
@apolkingg8
Copy link
Author

I'm not a c++ programmer, but it looks like rocksDB use _mkdir to create dir in windows. I tried something after some searching:

string dir_name = "中文";
_mkdir(dir_name.c_str()); // wont work
string dir_name = "中文";
_wmkdir(utf8_to_utf16(dir_name).c_str()); // it's works!

hope that'll be helpful, sorry I'm not familiar with this part.

@ralphtheninja
Copy link
Member

I'm right now wondering if the rocksdb lib should be compiled with Unicode enabled (UNICODE=true or similar) because I think that string is just a placeholder

@vweevers
Copy link
Member

RocksDB decided not to fix this: facebook/rocksdb#3408 (comment).

Tagging with help wanted; if someone wants to take a stab at this we'll gladly review a PR.

@vweevers vweevers added the help wanted Extra attention is needed label May 26, 2019
@vweevers
Copy link
Member

vweevers commented Oct 5, 2019

Update (facebook/rocksdb#3408 (comment)):

This is now fixed in facebook/rocksdb#4469 without having to use a custom env by using the WITH_WINDOWS_UTF8_FILENAMES option which defines ROCKSDB_WINDOWS_UTF8_FILENAMES.

So we can tackle this once #143 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

3 participants