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

Fix Tempfile binary mode on windows #109

Closed
wants to merge 2 commits into from
Closed

Conversation

bebac
Copy link

@bebac bebac commented Apr 12, 2013

This makes geminabox work on windows.

I have not tested this on other platforms than windows. Also not tested on other ruby versions than 1.9.3p392, but I expect binmode is supported on all ruby platforms.

Apparently the ':encoding => 'binary'' option does not change file to binmode, at least not on windows.

This changeset changes file to binary mode by calling binmode on the IO object.
Change tempfile in atomic_write to binary mode
@mattriley
Copy link

I'm experiencing the issue that this pull request would fix. Any chance it could be merged in soon?

@mtscout6
Copy link

I'm also getting hit by this issue. What needs to be done to wrap this up?

@mtscout6
Copy link

I'm presuming that this has not been pulled in due to a failed unit test on Travis. I have tried running the unit tests against ruby 1.9.3p327 on a ubuntu machine, but they all passed. Was this test failure due to an outlying issue on Travis or is something wrong with my setup. I just ran rake to run the tests, which appeared to be the same that Travis ran.

@jfoy
Copy link
Contributor

jfoy commented Aug 27, 2013

Next chance I get, I'm going to kill off the 1.8.7 tests on Travis -- we should no longer support this.

@bebac
Copy link
Author

bebac commented Aug 27, 2013

The test failure is not caused by this change, it was broken prior to this. I am also pretty sure the change will work on ruby 1.8

@mtscout6
Copy link

I have patched my local machine with this change and after I upload a custom gem of mine I am seeing this error:

Errno::ENOENT:No such file or directory - var/geminabox-data/specs.4.8
c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox/indexer.rb:24:in stat' c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox/indexer.rb:24:inupdated_gemspecs'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:189:in reindex' c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:177:inwrite_and_index'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:116:in handle_incoming_gem' c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:97:inblock in class:Geminabox'

any thoughts?

@mtscout6
Copy link

I can see that the file exists, so I don't understand why I would get this error.

@bebac
Copy link
Author

bebac commented Aug 27, 2013

No - Not sure, maybe something with the Geminabox.data setting. It's been a while since I messed with this and I can't remember how I configured it. Maybe try with an absolute path

@mtscout6
Copy link

absolute path did not work

@mtscout6
Copy link

ok, so I get that error on the first gem that I upload then it goes away after that. The problem I'm seeing now is that home page is throwing on:

Zlib::BufError - buffer error:
        c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:517:in `inflate'
        c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:517:in `inflate'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:247:in `spec_for'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/../views/index.erb:40:in `block (2 levels) in singletonclass'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox/gem_version_collection.rb:49:in `each'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox/gem_version_collection.rb:49:in `by_name'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/../views/index.erb:17:in `block in singletonclass'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/../views/index.erb:65531:in `instance_eval'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/../views/index.erb:65531:in `singletonclass'
        c:/Ruby193/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/../views/index.erb:65529:in `__tilt_19411284'

@bebac
Copy link
Author

bebac commented Aug 27, 2013

@mtscout6 can you try on my forked patch-1 branch, maybe this is a new issue. I am on an Ubuntu machine at the moment, so I cannot try it out right now

@mtscout6
Copy link

I've tried from both your patch-1 branch as well as by merging in the lastest master branch from the upstream repo.

@mtscout6
Copy link

See pull request #129 I finally got things working.

@bebac
Copy link
Author

bebac commented Aug 27, 2013

Ok - Got a windows machine booted and gem installed geminabox version 0.11.0 and applied my patch. Got this error at first

C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/indexer.rb:16:in <class:Indexer>': uninitialized constant Gem::UserInteraction (NameError) from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/indexer.rb:14:in<top (required)>'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/geminabox-0.11.0/lib/geminabox.rb:5:in <top (required)>' from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:inrequire'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in rescue in require' from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:inrequire'
from C:/Users/bebac/Projects/geminabox/config.ru:3:in block in <main>' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:ininstance_eval'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize' from C:/Users/bebac/Projects/geminabox/config.ru:innew'
from C:/Users/bebac/Projects/geminabox/config.ru:in <main>' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:ineval'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:in new_from_string' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:40:inparse_file'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:277:in build_app_and_options_from_config' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:199:inapp'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:314:in wrapped_app' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:250:instart'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:141:in start' from C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.5.2/bin/rackup:4:in<top (required)>'
from C:/Ruby/bin/rackup:23:in load' from C:/Ruby/bin/rackup:23:in

'

Then required 'rubygems/user_interaction' and it worked. I do get the error with the spec file, but the upload works. I uploaded via the web interface though.

Heres my config.ru:

require "rubygems"
require "rubygems/user_interaction"
require "geminabox"

Geminabox.data = "data"
run Geminabox

I used webrick as server

@mtscout6
Copy link

@bebac You are correct that the file upload was working. The problem that I was seeing was that the home page would no longer work. I finally figured out that the File.read operation that was reading the spec file was not respecting binary read. I fixed it is pull request #129. Thanks for helping me out.

@bebac
Copy link
Author

bebac commented Aug 27, 2013

@mtscout6 Sorry - missed you last comment. You got it working - Cool!

@mtscout6
Copy link

I vote we close this pull request now in favor of #129 which includes the changes within this pull request.

@bebac
Copy link
Author

bebac commented Aug 27, 2013

I agree

@bebac bebac closed this Aug 27, 2013
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

Successfully merging this pull request may close these issues.

None yet

4 participants