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

Cannot delete file after requiring it on Windows in 9.0.0.0.rc1 #3055

Closed
jeremyevans opened this Issue Jun 15, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@jeremyevans
Contributor

jeremyevans commented Jun 15, 2015

Looks like this broke between pre1 and pre2:

D:\>C:\jruby-9.0.0.0.pre1\bin\jruby -e "File.open('a.rb', 'a'){}; require './a.rb'; File.delete('a.rb'); p 1"
1

D:\>C:\jruby-9.0.0.0.pre2\bin\jruby -e "File.open('a.rb', 'a'){}; require './a.rb'; File.delete('a.rb'); p 1"
Errno::EACCES: Permission denied - a.rb
  delete at org/jruby/RubyFile.java:1116
   <top> at -e:1

D:\>C:\jruby-9.0.0.0.rc1\bin\jruby -e "File.open('a.rb', 'a'){}; require './a.rb'; File.delete('a.rb'); p 1"
Errno::EACCES: Permission denied - a.rb
  delete at org/jruby/RubyFile.java:1116
   <top> at -e:1

It doesn't matter if the a.rb file already exists or if the process creates it, trying to delete it after requiring it raises the error.

Found by running Sequel's specs.

I didn't test on a *nix, but it's unlikely to be a problem there as *nix allows deletion of files that are in use.

@djberg96

This comment has been minimized.

Show comment
Hide comment
@djberg96

djberg96 Jun 16, 2015

Contributor

No problem on Windows 8 with MRI:

PS C:\Users\Daniel> ruby -v
ruby 2.0.0p645 (2015-04-13) [i386-mingw32]

PS C:\Users\Daniel> ruby -e "File.open('a.rb', 'a'){}; require './a.rb'; File.delete('a.rb'); p 1"
1

I don't know the implemenation details of require, but I wouldn't think it would retain a handle to the file once it was loaded.

Contributor

djberg96 commented Jun 16, 2015

No problem on Windows 8 with MRI:

PS C:\Users\Daniel> ruby -v
ruby 2.0.0p645 (2015-04-13) [i386-mingw32]

PS C:\Users\Daniel> ruby -e "File.open('a.rb', 'a'){}; require './a.rb'; File.delete('a.rb'); p 1"
1

I don't know the implemenation details of require, but I wouldn't think it would retain a handle to the file once it was loaded.

@enebo enebo added the JRuby 9000 label Jun 16, 2015

@enebo enebo added this to the JRuby 9.0.0.0.rc2 milestone Jun 16, 2015

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jun 16, 2015

Member

Strange. Lexer changed between those two but it should not retain a reference to anything which would retain a HANDLE. Perhaps some IO fixes are hanging onto a handle in an IO table somewhere? We do use IO.gets for a small amount of parsing now so it could ??? who knows...just brainstorming but thanks for heads up.

Member

enebo commented Jun 16, 2015

Strange. Lexer changed between those two but it should not retain a reference to anything which would retain a HANDLE. Perhaps some IO fixes are hanging onto a handle in an IO table somewhere? We do use IO.gets for a small amount of parsing now so it could ??? who knows...just brainstorming but thanks for heads up.

@djberg96

This comment has been minimized.

Show comment
Hide comment
@djberg96

djberg96 Jun 17, 2015

Contributor

@enebo can you point us to the IO.gets changes you're referring to?

Contributor

djberg96 commented Jun 17, 2015

@enebo can you point us to the IO.gets changes you're referring to?

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jun 18, 2015

Member

@djberg96 org.jruby.lexer.GetsLexerSource

Member

enebo commented Jun 18, 2015

@djberg96 org.jruby.lexer.GetsLexerSource

@djberg96

This comment has been minimized.

Show comment
Hide comment
@djberg96

djberg96 Jun 18, 2015

Contributor

I tried adding some explicit close calls in there, but then it complained about a closed stream, so I must have done it too soon.

Contributor

djberg96 commented Jun 18, 2015

I tried adding some explicit close calls in there, but then it complained about a closed stream, so I must have done it too soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment