Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cannot install 2.5.0 on Windows 7 x64 #703

Closed
maratgaliev opened this Issue · 33 comments
@maratgaliev

All environment was set up from railsinstaller.
Ruby - 1.9.2-p290
Rails - 3.1.1 etc

Error:
G:\Projects\burk>gem install paperclip -v '2.5.0'
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument - C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/paperclip-2.5.0/test/fixtures/question?mark.png

Version 2.4.5 installed fine, but got error on migrate:

G:\Projects\burk>gem install paperclip -v '2.5.0' --trace
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --trace

G:\Projects\burk>rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== CreateBrands: migrating ===================================================
-- create_table(:brands)
rake aborted!
An error has occurred, all later migrations canceled:

undefined method has_attached_file' for #<ActiveRecord::ConnectionAdapters::Tab
leDefinition:0x5c804a0>
G:/Projects/burk/db/migrate/20120115082718_create_brands.rb:6:in
block in ch
ange'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/connection_adapters/abstract/schema_statements.rb:161:in create_table
'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/connection_adapters/mysql2_adapter.rb:481:in
create_table'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:447:in block in method_missing'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:422:in
block in say_with_time'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/benchmark.rb:295:in measure'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:422:in
say_with_time'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:442:in method_missing'
G:/Projects/burk/db/migrate/20120115082718_create_brands.rb:3:in
change'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:391:in block (2 levels) in migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/benchmark.rb:295:in
measure'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:391:in block in migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:185:in
with_connectio
n'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:375:in migrate'
C:in
migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:687:in block (2 levels) in migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:744:in
call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:744:in ddl_transaction'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:686:in
block in migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:671:in each'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:671:in
migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:549:in up'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/migration.rb:530:in
migrate'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/acti
ve_record/railties/databases.rake:161:in block (2 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:205:in
call'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:205:in block in execute'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:200:in
each'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:200:in execute'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:158:in
block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:151:in
invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.
rb:144:in invoke'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:116:in
invoke_task'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in
each'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in block in top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:133:in
standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:88:in top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:66:in
block in run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:133:in standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:63:in
run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in
<top (required)>'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in
load'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in `

'
Tasks: TOP => db:migrate

@jyurek
Owner

That's odd. Can you post the code in 20120115082718_create_brands.rb so I can see what line 6 is trying to do?

@pmarsceill

I believe this is related to this issue #621

@pmarsceill

because of this error:
Invalid argument - C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/paperclip-2.5.0/test/fixtures/question?mark.png

@maratgaliev

class CreateBrands < ActiveRecord::Migration
def change
create_table :brands do |t|
t.string :name
t.text :description

t.has_attached_file :logo
end
end
end

@jyurek
Owner

If this is related to #612, what should we do? Should we change that character on Windows?

@maratgaliev

I think so, yes. Why filename contains strange characters? You know, windows is very demanding system:)
Thanks.

@pmarsceill

The only way that I got this gem to work on a windows box is to manually install the gem from the zip file to /vendor/gem/paperclip , then added the :path => 'vendor/gem/paperclip' reference to my Gemfile.

That way you bypass the gem installer that tries to run the test that is failing and preventing it from being installed.

@maratgaliev

Thanks, but it's not a decision. I want to include gem 'paperclip' and it should work. It's normal.

@seizmo

I would also really appreciate this being fixed!

I think to test for question mark compatibility might be less important than breaking this gem for all Windows developers.

@xxx

The question mark compat test is important. The correct fix is to remove the file from the repo, then re-create it in the setup for the set of tests that work on question mark files on non-windows platform. It's just a copy of one of the fixture images that are already in the repo.

@jyurek
Owner

I don't believe that's the correct fix, because if someone uploads a file onto a Windows system, it will cause problems, even if the test doesn't run. This bug runs into a larger problem with URL escaping, which is what the best way to handle it all is. The "simple" way would be to bar any characters that are special in URLs or forbidden in file names, either by removal or converting to "_" or something. We tried URI escaping each interpolation, but that led to problems because recursion is possible. Finding out what characters are problematic on each FS might be similarly hairy.

It would be super awesome if someone could take a whack at this and submit a pull request, as my time is limited and I may not get a chance to sit down with this problem.

@asarig

the core problem is, paperclicp now use aws-sdk gem instead of aws-s3 and you get uninitialized constant AWS::S3::Base if you don' t upgrade to 2.5.0 ... which does not work on windows anymore because of question?mark.png

at a minimum the polite thing to do is fix the test case to be sensitive to the environment; the best is just not to have that test case.
thanks.

@maratgaliev

I agree, let's change this test case to environment depended, and windows systems just skip it.

@pmarsceill
@asarig

BTW the temporary workaround until this is fixed, especially if you work on both environments (win for dev and Heroku for deploy like I do) - is to have in your gemfile :

gem "aws-s3", :require => "aws/s3"
gem 'paperclip'
gem "aws-sdk"

seems to be working for me. Not ideal though, the Heroku slug will contain with unnecessary gem.

@pmarsceill
@nhjort

Another workaround is to use paperclip version 2.4.4 which is the newest version that does not contain that commit. Put in your gemfile
gem 'paperclip', '~> 2.4.4'

then bundle install will work on windows. It would be nice if this was resolved, especially since it's only associated with a test case.

@jrutt17

I'm trying to install Spree and paperclip 2.5.0 is a dependency (and I'm getting the same error). Win 7-x64.

Any suggestions? I can't put it in my project's gemfile because I can't create a Spree project w/o this!!

Thanks

@maratgaliev

Btw, we can't perform changes only in source code, because bundle install downloads source files, and file with incorrect name rises "Invalid argument error" on this stage. Test cases are not running at this time.

@sikachu sikachu was assigned
@sikachu
Owner

Ok, so I'm going to fix this problem, and here's what I'm going to do:

  1. We're going to convert some of the special characters in the file name into an underscore, such as :;\/?&+=. You can turn this off as well if you don't want, but it's not recommmend to do so as we're also seeing that Rails sometime cannot handle some of these special characters in the image_tag.

  2. We'll remove the question?mark.png file and using StringIO to test the functionality instead. This will make sure that people who're using Windows will be able to use the gem, and also safely save file onto their system.

@jyurek jyurek referenced this issue
Closed

Bad urls #661

@filipegiusti

@sikachu please add url special characters like []#. That would probably fix problems with paperclip generating invalid urls.

@sikachu sikachu closed this issue from a commit
Commit has since been removed from the repository and is no longer available.
@sikachu sikachu closed this in ae6c82c
@MSNexploder MSNexploder referenced this issue from a commit in MSNexploder/paperclip
@sikachu sikachu Replacing all special characters to underscore
Fixes #703
604304e
@alexdowad

I have a Spree project which runs on a Linux server, but I am trying to also get it running locally, just to do a few simple tests. I am not going to try uploading files with question marks in the filename while testing locally, and in production, it won't be an issue anyways. I can install other versions of Paperclip, but Spree specifically requires 2.5.0. This issue is causing a lot of pain! The patch from @MSNExploder doesn't help, because a "bundle install" of Spree always tries to install the 2.5.0 gem, which doesn't include the patch.

@sikachu
Owner

I think in that case I we should contact Spree to upgrade to newer version of Paperclip. There's a file with question mark in there with make the install fail, and I'm not sure what's the way to get around that except upgrading.

@radar

Hi Alex. If you upgrade to either the 1-0-stable or 1-1-stable branch of Spree using this line in your Gemfile rather than a traditional gem line:

gem 'spree', :github => "spree/spree", :branch => "1-0-stable"

That will make your application use the latest stable we have for that version and will fix the Paperclip problem you're having here.

@alexdowad

For anyone else who runs into the same problem on Windows, I just worked around it by installing 2.6.0, renaming the gemspec file in lib/ruby/gems/1.9.1/specifications from paperclip-2.6.0.gemspec to paperclip-2.5.0.gemspec, and editing the file to change "2.6.0" to "2.5.0". It seems that the files for 2.5.0 were actually installed into the lib/ruby/gems/1.9.1/gems directory before, so I'm hoping the combination of (edited) 2.6.0 gemspec file and 2.5.0 source files will not cause any adverse results.

@alexdowad

@radar, thanks for the suggestion, but... this Spree app is a client's, not mine, and I've just been hired to add a few simple things to the existing code. For obvious reasons, I want to use the exact same version of Spree as what the client is running on his server. Since Spree is under active development and changing all the time, I wouldn't want to test my modifications on anything else than the exact version which will be used. This is not a big-money job, so I can't consider upgrading all the existing code, including all the modifications the client has already made, to a newer version of Spree.

@radar

Ok then, there's nothing much else we can do from our end. I think your solution is a bit hacky and you would probably do better if you forked paperclip 2.6.0 into vendor/gems and pointed your Gemfile there, rather than modifying the gemspec on every single system.

@alexdowad

@radar, with all due respect, my solution is not "a bit" hacky. It's a stinky, festering hack, and I hate myself for even thinking of it. It's just a one-time thing to get the app up locally for a few simple tests, before moving the new code to "greener pastures" on a Linux-based server.

@alan50

@radar Hey Radar,
if i add "gem 'spree', :github => "spree/spree", :branch => "1-0-stable"" to my gemfile the following fault message appears: C:\Sites\mystore>bundle install
You passed :github as an option for gem 'spree', but it is invalid.
What should i do?
Sorry i m a rookie :) Thanks!

@radar

@alan50 What version of Bundler are you using? The github option was only recently introduced. I would recommend you upgrade the version of Bundler that you are using.

@alan50

@radar Good suggestion. I succeeded in installing spree. But if i m starting the webserver only the welcome aboard page of ruby on rails is presented.
How can i configure spree? I wasn't asked to install sample data or things like this.
thx.

@radar

Did you run rails g spree:install as mentioned in the Getting started guide?

@alan50

@radar It works! Thanks a lot. But there is a new problem if i m trying to build an integrated extension. First of all i cant run bundle install inside the extension because there are the known problems with paperclip 2.5.0. And secondly i cant create a resource because the following fault message appears.
C:\Sites\myshop\spree_FlagPromotions>rails g resource some_bar
internal:lib/rubygems/custom_require:29:in require': no such file to load --
C:/Sites/myshop/spree_FlagPromotions/config/boot (LoadError)
from <internal:lib/rubygems/custom_require>:29:in
require'
from script/rails:4:in `

'
It seems to be like spree doesnt like me or i m just to stupid?!. ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.