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

On Windows, folders are not extracted properly if cwd contains non-latin characters #209

Closed
bvachon opened this issue Apr 4, 2019 · 3 comments

Comments

@bvachon
Copy link

bvachon commented Apr 4, 2019

The below test shows the problem. Setting options.preservePaths allows to work around the problem.

    const fse = require('fs-extra')
    const tar = require('tar')
    const tmp = require('tmp')

    it('should extract tarball content', async () => {
      // File obtained from http://registry.npmjs.org/tar/-/tar-4.4.4.tgz
      const tarballPath = 'tar-4.4.4.tgz'
      const targetFolder = path.join(tmp.dirSync().name, 'İİİİİİİİİ/tar')
      fse.ensureDirSync(targetFolder)

      await tar.extract({
        cwd: targetFolder,
        file: tarballPath,
        strip: 1,
        // preservePaths: true,
      })

      expect(fse.existsSync(path.join(targetFolder, 'lib/buffer.js'))).to.be.true
    })
@monoblaine
Copy link

Thank you so much for the workaround @bvachon! Without this workaround, it is impossible to install any npm package when the path to the project dir contains the İ character.

@monoblaine
Copy link

The root of the problem seems to be nodejs/node#27534. (I have a PR that fixes that issue.) The problem I've stated (not being able to install any npm packages under e.g. C:\İİİİ\) is also fixed when that patch is applied.

@isaacs
Copy link
Owner

isaacs commented Jan 29, 2020

It seems like this is a Node error, and trying to work around it in node-tar (eg, by using something other than the built-in path functions) would be unsafe. And, if you're ok with the un-safety, you can work around it yourself by setting preservePaths: true.

I think we can close this then? If not, lmk, and I'll reopen.

@isaacs isaacs closed this as completed Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants