2013-05-20 カスタムセル(UITableViewCell)に配置したWebViewの高さを調整する方
ちょっとはまったので、久しぶりにブログでも書こうかなと。
TestTableViewCell.xib
UITableViewCellにUIWebViewを配置します。
TestTableViewCell.h
delegateを定義してます。また、UIWebViewDelegateを実装してます。
@protocol TestTableViewCellDelegate <NSObject> - (void)reloadTable:(NSInteger)height; @end @interface TestTableViewCell : UITableViewCell<UIWebViewDelegate> @property (weak, nonatomic) IBOutlet UIWebView *webView; @property (weak, nonatomic)id<TestTableViewCellDelegate> delegate; @end
TestTableViewCell.m
UIWebViewDelegateの実装します。また、この中でTestTableViewCellDelegate#reloadTableのdelegateをcallしてます。
- (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *output = [webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.clientHeight;"]; int contentHeight = [output intValue]; [self.delegate reloadTable:contentHeight]; }
TestTableViewController.h
webviewの高さを保持しておく変数を定義しておきます。
@interface TestTableViewController : UITableViewController<TestTableViewCellDelegate> @property int height; TestTableViewController.m - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *Cell = @"Cell"; PMSShopDetailFreeText *cell = [tableView dequeueReusableCellWithIdentifier:Cell forIndexPath:indexPath]; // delegate設定 cell.delegate = self; // webviewの読み込み NSMutableString *htmlCode = [NSMutableString stringWithString:@"<html><head>"]; [htmlCode appendString:@"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"]; [htmlCode appendString:@"</head><body>"]; [htmlCode appendString:@"test"]; [htmlCode appendString:@"</body><html>"]; [cell.freeTextWebView loadHTMLString:htmlCode baseURL:nil]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return height; } // 高さを設定してtableviewを更新 // ※reloadDataを使うと無限ループするので注意!! - (void)reloadTable:(NSInteger)height { freeTextHeight = height; [self.tableView beginUpdates]; [self.tableView endUpdates]; }
こんな感じにすると、以下の順番でdelegateが呼ばれて無事高さを設定できます。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - (void)webViewDidFinishLoad:(UIWebView *)webView - (void)reloadTable:(NSInteger)height
ちなみに、
- (void)reloadTable:(NSInteger)height
で、reloadDataを使うと、上記順番のdelegateが無限ループするので注意です!
2011-12-26
right_awsとaws/s3を一緒に使うときの注意点
Ruby |
はまったのでメモ。
S3に保存するときは、aws/s3で、SQSを使うときはright_awsと使い分けてたのだけど、S3に保存するときに以下のようなエラーが発生
コード
AWS::S3::S3Object.store("test.mp4",open("aa.mp4"), "test_bucket",:access => :public_read)
エラー内容
E, [2011-12-26T17:05:11.650235 #1903] ERROR -- : wrong number of arguments (5 for 4) (ArgumentError) /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:310:in `send_request_with_body_stream' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/right_http_connection-1.3.0/lib/net_fix.rb:85:in `exec' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/right_http_connection-1.3.0/lib/net_fix.rb:144:in `request' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb:45:in `block in request' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:627:in `start' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb:52:in `request' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:69:in `request' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:88:in `put' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p290/gems/aws-s3-0.6.2/lib/aws/s3/object.rb:241:in `store' aws_sqs_task.rb:84:in `<main>'
引数間違ってないし、と散々悩んだあげく、requireの順番変更したらうまくいった
before
require 'right_aws' require 'aws/s3'
after
require 'aws/s3' require 'right_aws'
2011-12-25
https接続でRubyがクラッシュした件
Ruby |
一応メモ。
あるシステムを開発していて、キュー処理が必要になったので、前々から気になっていたAWSのSQSを使ってみることにしました。
で、標題のエラーが発生したわけです。
エラー箇所
sqs = RightAws::SqsGen2.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) q = sqs.queue(queue_name)
※RightAwsというフレームワークを使ってます。
キューを取り出すところで以下のエラーが出ました。(ちょっと長いですけど
******* after controller end *********** Completed 200 OK in 133ms (Views: 51.5ms | ActiveRecord: 1.1ms) /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.8.0] -- control frame ---------- c:0088 p:---- s:0487 b:0487 l:000486 d:000486 CFUNC :connect c:0087 p:0011 s:0484 b:0484 l:0015a0 d:000483 BLOCK /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678 c:0086 p:0109 s:0482 b:0482 l:002260 d:002260 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57 c:0085 p:0026 s:0470 b:0470 l:000469 d:000469 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87 c:0084 p:0444 s:0464 b:0464 l:0015a0 d:0015a0 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678 c:0083 p:0011 s:0456 b:0456 l:000455 d:000455 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:637 c:0082 p:0089 s:0453 b:0453 l:000452 d:000452 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:632 c:0081 p:0408 s:0450 b:0450 l:001450 d:001450 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:329 c:0080 p:0350 s:0444 b:0444 l:000430 d:000443 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:392 c:0079 p:---- s:0436 b:0436 l:000435 d:000435 FINISH c:0078 p:---- s:0434 b:0434 l:000433 d:000433 CFUNC :loop c:0077 p:0065 s:0431 b:0431 l:000430 d:000430 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:364 c:0076 p:0016 s:0423 b:0423 l:002428 d:000422 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/right_awsbase.rb:531 c:0075 p:0043 s:0420 b:0420 l:000419 d:000419 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:294 c:0074 p:0019 s:0412 b:0412 l:000411 d:000411 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/benchmark_fix.rb:30 c:0073 p:0106 s:0407 b:0407 l:002428 d:002428 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/right_awsbase.rb:529 c:0072 p:0019 s:0396 b:0396 l:000395 d:000395 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:142 c:0071 p:0055 s:0391 b:0391 l:000390 d:000390 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:167 c:0070 p:0034 s:0386 b:0386 l:000385 d:000385 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:356 c:0069 p:0022 s:0381 b:0381 l:000380 d:000380 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2.rb:89 c:0068 p:0071 s:0374 b:0374 l:000373 d:000373 METHOD /Users/yamazaki/src/ruby/web/workspace/trunk/test1/app/models/movie.rb:18 c:0067 p:0461 s:0367 b:0367 l:000366 d:000366 METHOD /Users/yamazaki/src/ruby/web/workspace/trunk/test1/app/controllers/client_controller.rb:243 c:0066 p:0012 s:0362 b:0362 l:000361 d:000361 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/implicit_render.rb:4 c:0065 p:0015 s:0357 b:0357 l:000356 d:000356 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/base.rb:150 c:0064 p:0041 s:0352 b:0352 l:000351 d:000351 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rendering.rb:11 c:0063 p:0012 s:0348 b:0348 l:002588 d:000347 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/callbacks.rb:18 c:0062 p:0243 s:0346 b:0346 l:000345 d:000345 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:466 c:0061 p:0113 s:0340 b:0340 l:000339 d:000339 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:410 c:0060 p:0024 s:0331 b:0331 l:000330 d:000330 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:94 c:0059 p:0020 s:0325 b:0325 l:002588 d:002588 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/callbacks.rb:17 c:0058 p:0012 s:0320 b:0320 l:000301 d:000319 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/instrumentation.rb:30 c:0057 p:0017 s:0316 b:0316 l:000306 d:000315 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications.rb:52 c:0056 p:0032 s:0314 b:0314 l:000313 d:000313 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications/instrumenter.rb c:0055 p:0036 s:0307 b:0307 l:000306 d:000306 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications.rb:52 c:0054 p:0152 s:0302 b:0302 l:000301 d:000301 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/instrumentation.rb:29 c:0053 p:0012 s:0296 b:0296 l:000295 d:000295 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rescue.rb:17 c:0052 p:0093 s:0291 b:0291 l:000290 d:000290 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/base.rb:119 c:0051 p:0084 s:0285 b:0285 l:000284 d:000284 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/rendering.rb:41 c:0050 p:0048 s:0280 b:0280 l:000279 d:000279 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal.rb:138 c:0049 p:0086 s:0275 b:0275 l:000274 d:000274 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rack_delegation.rb:14 c:0048 p:0030 s:0269 b:0269 l:000788 d:000268 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal.rb:178 c:0047 p:---- s:0266 b:0266 l:000265 d:000265 FINISH c:0046 p:---- s:0264 b:0264 l:000263 d:000263 CFUNC :call c:0045 p:0022 s:0260 b:0260 l:000259 d:000259 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:62 c:0044 p:0094 s:0254 b:0254 l:000253 d:000253 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:27 c:0043 p:0097 s:0248 b:0248 l:000220 d:000247 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:148 c:0042 p:0014 s:0242 b:0242 l:000226 d:000241 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:93 c:0041 p:0361 s:0237 b:0237 l:000236 d:000236 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:75 c:0040 p:0190 s:0227 b:0227 l:000226 d:000226 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:92 c:0039 p:0092 s:0221 b:0221 l:000220 d:000220 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:139 c:0038 p:0025 s:0215 b:0215 l:000214 d:000214 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:493 c:0037 p:0015 s:0211 b:0211 l:000210 d:000210 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/best_standards_suppo c:0036 p:0093 s:0204 b:0204 l:000203 d:000203 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/head.rb:14 c:0035 p:0155 s:0197 b:0197 l:000196 d:000196 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/methodoverride.rb:24 c:0034 p:0046 s:0191 b:0191 l:000190 d:000190 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/params_parser.rb:21 c:0033 p:0047 s:0186 b:0186 l:000185 d:000185 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/jpmobile-1.0.4/lib/jpmobile/rack/mobile_carrier.rb:13 c:0032 p:0054 s:0182 b:0182 l:000181 d:000181 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/flash.rb:182 c:0031 p:0027 s:0175 b:0175 l:000174 d:000174 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/session/abstract_sto c:0030 p:0015 s:0164 b:0164 l:000163 d:000163 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/cookies.rb:302 c:0029 p:0014 s:0156 b:0156 l:001780 d:000155 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:32 c:0028 p:0019 s:0154 b:0154 l:000153 d:000153 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/qu c:0027 p:0051 s:0150 b:0150 l:000149 d:000149 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:12 c:0026 p:0019 s:0146 b:0146 l:001780 d:001780 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:31 c:0025 p:0015 s:0142 b:0142 l:000141 d:000141 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/co c:0024 p:0029 s:0138 b:0138 l:001db0 d:000137 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:46 c:0023 p:0155 s:0136 b:0136 l:000135 d:000135 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:416 c:0022 p:0011 s:0126 b:0126 l:001db0 d:001db0 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:44 c:0021 p:0015 s:0122 b:0122 l:000121 d:000121 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/sendfile.rb:107 c:0020 p:0049 s:0112 b:0112 l:000111 d:000111 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/remote_ip.rb:48 c:0019 p:0017 s:0108 b:0108 l:000107 d:000107 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/show_exceptions.rb:4 c:0018 p:0027 s:0100 b:0100 l:000099 d:000099 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/rack/logger.rb:13 c:0017 p:0032 s:0096 b:0096 l:000095 d:000095 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/runtime.rb:17 c:0016 p:0052 s:0087 b:0087 l:000086 d:000086 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/cache/strategy/local_cache.rb c:0015 p:0014 s:0083 b:0083 l:000077 d:000082 BLOCK /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/lock.rb:11 c:0014 p:0019 s:0081 b:0081 l:000080 d:000080 METHOD <internal:prelude>:10 c:0013 p:0054 s:0078 b:0078 l:000077 d:000077 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/lock.rb:11 c:0012 p:0193 s:0073 b:0073 l:000072 d:000072 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/static.rb:30 c:0011 p:0032 s:0066 b:0066 l:000065 d:000065 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/application.rb:168 c:0010 p:0021 s:0062 b:0062 l:000061 d:000061 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/application.rb:77 c:0009 p:---- s:0057 b:0057 l:000056 d:000056 FINISH c:0008 p:0015 s:0055 b:0055 l:000054 d:000054 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/rack/log_tailer.rb:14 c:0007 p:0015 s:0050 b:0050 l:000049 d:000049 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/content_length.rb:13 c:0006 p:0338 s:0042 b:0042 l:000041 d:000041 METHOD /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/handler/webrick.rb:52 c:0005 p:0257 s:0030 b:0030 l:000029 d:000029 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111 c:0004 p:0393 s:0020 b:0020 l:000019 d:000019 METHOD /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70 c:0003 p:0126 s:0009 b:0009 l:001b68 d:000008 BLOCK /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP --------------------------- -- Ruby level backtrace information ---------------------------------------- /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/handler/webrick.rb:52:in `service' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/content_length.rb:13:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/rack/log_tailer.rb:14:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/application.rb:168:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/static.rb:30:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/lock.rb:11:in `call' <internal:prelude>:10:in `synchronize' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/lock.rb:11:in `block in call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/runtime.rb:17:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/railties-3.0.9/lib/rails/rack/logger.rb:13:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/remote_ip.rb:48:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/sendfile.rb:107:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:44:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:416:in `_run_call_callbacks' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:46:in `block in call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:31:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:12:in `cache' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activerecord-3.0.9/lib/active_record/query_cache.rb:32:in `block in call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/cookies.rb:302:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/flash.rb:182:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/jpmobile-1.0.4/lib/jpmobile/rack/mobile_carrier.rb:13:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/params_parser.rb:21:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-1.2.3/lib/rack/methodoverride.rb:24:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/head.rb:14:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:493:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:139:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:92:in `recognize' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:75:in `optimized_each' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:93:in `block in recognize' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:148:in `block in call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:27:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:62:in `dispatch' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:62:in `call' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal.rb:178:in `block in action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal.rb:138:in `dispatch' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/rendering.rb:41:in `process' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/base.rb:119:in `process' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rescue.rb:17:in `process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/instrumentation.rb:29:in `process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications.rb:52:in `instrument' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications/instrumenter.rb:21:in `instrument' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/notifications.rb:52:in `block in instrument' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/callbacks.rb:17:in `process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:94:in `run_callbacks' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:466:in `_run__3757862011870043610__process_action__2046539961009806014__callbacks' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/callbacks.rb:18:in `block in process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/rendering.rb:11:in `process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/abstract_controller/base.rb:150:in `process_action' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/actionpack-3.0.9/lib/action_controller/metal/implicit_render.rb:4:in `send_action' /Users/yamazaki/src/ruby/web/workspace/trunk/test1/app/controllers/client_controller.rb:243:in `movie_upload' /Users/yamazaki/src/ruby/web/workspace/trunk/test1/app/models/movie.rb:18:in `tmp_save' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2.rb:89:in `queue' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:356:in `queue_url_by_name' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:167:in `list_queues' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/sqs/right_sqs_gen2_interface.rb:142:in `request_info' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/right_awsbase.rb:529:in `request_info_impl' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/benchmark_fix.rb:30:in `add!' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:294:in `measure' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_aws-3.0.0/lib/awsbase/right_awsbase.rb:531:in `block in request_info_impl' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:364:in `request' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:364:in `loop' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:392:in `block in request' /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@test1/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:329:in `start' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:632:in `start' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:637:in `do_start' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `connect' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87:in `timeout' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57:in `timeout' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `block in connect' /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:678:in `connect' -- C level backtrace information ------------------------------------------- [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Abort trap: 6
いろいろググってみた結果、SQSがどうというわけではなく、https接続がうまくいかない模様。
※Railsで動かすとこのエラーがでます。普通にRuby単体で動かした場合は問題なかったです
ローカル環境に依存したような問題っぽいなーと思ったら、opensslが原因だったぽい
rvmを使ってたので、以下を参考にしてRubyの再インストール
http://beginrescueend.com/packages/openssl/
$ rvm remove 1.9.2 $ rvm install 1.9.2 --with-openssl-dir=/opt/local
※opensslがインストールされてるディレクトリを指定します
これで無事解決できました
2011-11-27
Ruby1.9.3をインストールしたときのいろいろなエラー
サーバー環境 |
EC2で新しく環境構築して、Ruby1.9.3をソースからコンパイルしてgemをアップデートしようとしたら以下のエラーが出た。
[root@hoge ~]# gem update --system /usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. ERROR: Loading command: update (LoadError) cannot load such file -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::UpdateCommand
とりあえず、yumで以下を入れる。
yum install zlib-devel
[root@hoge ~]# gem update --system /usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.
エラーは出なくなったけど、警告がまだ消えない。
以下からソースファイルを持ってきてコンパイル
http://pyyaml.org/wiki/LibYAML
http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
が、passengerをインストールしようとしたらこんなエラーが、、
-------------------------------------------- Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Curl development headers with SSL support... found * OpenSSL development headers... found * Zlib development headers... found * Ruby development headers... found * OpenSSL support for Ruby... not found * RubyGems... found * Rake... found at /usr/local/bin/rake * rack... found * Apache 2... found at /usr/sbin/httpd * Apache 2 development headers... found at /usr/sbin/apxs * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config Some required software is not installed. But don't worry, this installer will tell you how to install them. Press Enter to continue, or Ctrl-C to abort. --------------------------------------------
OpenSSL...ぬぬ、、以下を入れる。
yum -y install httpd-devel yum -y install openssl-devel
結論
Ruby1.9.3を素のAmazon Linuxにソースからインストールする場合は、まず以下を実行するべし
yum -y install gcc yum -y install make yum -y install gcc-c++ yum -y install zlib-devel yum -y install httpd-devel yum -y install openssl-devel yum -y install curl-devel
これできっと幸せになれるはず
[追伸]
Rubyのコンパイルを何度もやり直したのだが、最初はmicroインスタンスだったんだけど、時間かかりすぎるので、以降はxlargeにして作業してました
参考URL
http://d.hatena.ne.jp/donbulinux/20111111/1321004527
2011-11-24
LionにしてからXCodeのアップデートするの忘れてた
Ruby |
rvmで新しくgemset作って、最新のrailsを入れようとしたら以下のようなエラーが出た。
$ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb checking for re.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/bin/ruby /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for' from /Users/yamazaki/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:833:in `have_header' from extconf.rb:14:in `<main>' Gem files will remain installed in /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@oshiri/gems/json-1.6.1 for inspection. Results logged to /Users/yamazaki/.rvm/gems/ruby-1.9.2-p180@oshiri/gems/json-1.6.1/ext/json/ext/parser/gem_make.out
なんかコンパイルでエラーになってるようだけど、、と思ったらgccが入ってない。。あれれ??
そういえばMacをLionにアップデートしてからXcodeのアップデートしてないなということでAppStoreからXcodeをダウンロードしてアップデート。無事にインストールできました^^

はじめまして。
ぐるなび食市場アフィリエイト事務局の岩井と申します。
今回は管理者様へお得なアフィリエイトのご案内となります。
ぐるなび食市場が新たな自社アフィリエイトプログラムを1月21日にオープン致しました。
もちろん初期費用等は一切かかりませんので是非この機会に以下URLよりご登録の程お願い致します。
http://aff.gnavi.co.jp/