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

chmod inside of File block fails to create file #1149

Closed
jkutner opened this issue Oct 22, 2013 · 7 comments
Closed

chmod inside of File block fails to create file #1149

jkutner opened this issue Oct 22, 2013 · 7 comments
Labels
Milestone

Comments

@jkutner
Copy link
Member

@jkutner jkutner commented Oct 22, 2013

While looking at a CI failure on the rubyzip gem, I found that an error
was generated from a line like this:

File.open("data/generated/empty_chmod640.txt", "w") { |f| f.chmod(0640) }

The error was:

RuntimeError: No such file or directory - data/generated/empty_chmod640.txt

I haven't been able to isolate the issue, but it can easily be reproduced from the rubyzip test suite like so:

$ git clone git@github.com:rubyzip/rubyzip.git
$ cd rubyzip
$ git checkout cb6e628fb27b3785527945068e01fcc3fa8d8654
$ bundle install
$ bundle exec rake
...
  adding: data/file2.txt (deflated 79%)
deleting: data/file2.txt
    zip warning: zip file empty
RuntimeError: No such file or directory - data/generated/empty_chmod640.txt
...

The test suite fails to create it's fixtures because of this line (which is the same as the one shown at the top of the issue):
https://github.com/rubyzip/rubyzip/blob/cb6e628fb27b3785527945068e01fcc3fa8d8654/test/gentestfiles.rb#L96

@headius
Copy link
Member

@headius headius commented Oct 22, 2013

I remember seeing something reported (and being able to reproduce, I think) where File.new { } was not creating the file on disk. I was unable to figure out why it would happen. It seems to be specific to a certain combination of file flags, but I have not managed to narrow it down.

@headius
Copy link
Member

@headius headius commented Oct 22, 2013

Tried adding f.flush before the chmod and it doesn't seem to make any difference.

@headius
Copy link
Member

@headius headius commented Oct 22, 2013

I've investigated why it doesn't create the file but not gotten anywhere. There are a couple cases online where FileOutputStream does not create the specified file automatically, so maybe we're not the only ones seeing this. Unsure how to proceed, since I went down to the native code and the JVM even passes O_CREAT to open/64.

@jkutner
Copy link
Member Author

@jkutner jkutner commented Oct 23, 2013

The workaround isn't bad:

File.open("data/generated/empty_chmod640.txt", "w") { }
File.chmod(0640, "data/generated/empty_chmod640.txt")

So I'm not too worried about it.

@enebo
Copy link
Member

@enebo enebo commented Feb 17, 2017

@jkutner @headius I do not see this on MacOS. Is this specific to Linux? On 9k, I know we do some native calls now but even with native disabled I am not seeing an issue.

@jkutner
Copy link
Member Author

@jkutner jkutner commented Feb 17, 2017

@enebo no, this was definitely on MacOS, so maybe it went away.

@enebo enebo added this to the JRuby 9.1.8.0 milestone Feb 17, 2017
@enebo
Copy link
Member

@enebo enebo commented Feb 17, 2017

Well optimistically calling this resolved then!

@enebo enebo closed this Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.