Permission denied @ apply2files when unlinking C:/Users/travis/.npmrc in Windows

Every time I tried deploying to npm after a successfull build, the project get deployed to npm successfully but the build still fails when dpl ruby tries to unlink C:/Users/travis/.npmrc file.

the travis build file is

The error log below.

C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:1437:in `unlink': Permission denied @ apply2files - C:/Users/travis/.npmrc (Errno::EACCES)
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:1437:in `block in remove_file'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:1445:in `platform_support'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:1436:in `remove_file'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:775:in `remove_file'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:562:in `block in rm'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:561:in `each'
	from C:/tools/ruby26/lib/ruby/2.6.0/fileutils.rb:561:in `rm'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-npm-1.10.14/lib/dpl/provider/npm.rb:36:in `push_app'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/lib/dpl/provider.rb:199:in `block in deploy'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/lib/dpl/cli.rb:41:in `fold'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/lib/dpl/provider.rb:199:in `deploy'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/lib/dpl/cli.rb:32:in `run'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/lib/dpl/cli.rb:7:in `run'
	from C:/tools/ruby26/lib/ruby/gems/2.6.0/gems/dpl-1.10.14/bin/dpl:5:in `<top (required)>'
	from C:/tools/ruby26/bin/dpl:23:in `load'
	from C:/tools/ruby26/bin/dpl:23:in `<main>'

dpl 2.0 should not have this problem.

Thank BanzaiMan, npm is still in beta in dpl 2.0 but I found a work around solution in the article, I added the allow_failure: true to my npm deploy, the error persist but my package still get publish and my build passes.

1 Like

I believe explicitly closing the .npmrc file will fix the problem.

In Windows, you cannot delete a file that’s open without FILE_SHARE_DELETE. The translated errno in this case is EACCES but the actual winapi error is ERROR_SHARING_VIOLATION.

@Thecarisma you can test the fix with

    source: 'native-api/dpl'
    branch: 'fix_eaccess'
1 Like

native-api your fix works fine. I hope your PR is merged soon to fix the issue.

1 Like