Archive for: 󈥫月 2011’

Ruby1.9.2 デバッグ

2011年11月30日 Posted by PURGE

eclispe plugin版の Aptana Studio on WindowsXP で、Rails3.1.1 のサーバデバッグモード起動でエラー。
デバッガが無いとの事・・・。

gem で ruby-debug19 とやらをインストール。

C:project>gem install ruby-debug19
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Fetching: ruby-debug-base19-0.11.25.gem (100%)
Building native extensions.  This could take a while...
Fetching: ruby-debug19-0.11.6.gem (100%)
Successfully installed linecache19-0.5.12
Successfully installed ruby-debug-base19-0.11.25
Successfully installed ruby-debug19-0.11.6
3 gems installed
Installing ri documentation for linecache19-0.5.12...
Installing ri documentation for ruby-debug-base19-0.11.25...
Installing ri documentation for ruby-debug19-0.11.6...
Installing RDoc documentation for linecache19-0.5.12...
Installing RDoc documentation for ruby-debug-base19-0.11.25...
Installing RDoc documentation for ruby-debug19-0.11.6...
C:project>gem install ruby-debug-ide19
Fetching: ruby-debug-ide19-0.4.12.gem (100%)
Successfully installed ruby-debug-ide19-0.4.12
1 gem installed
Installing ri documentation for ruby-debug-ide19-0.4.12...
Installing RDoc documentation for ruby-debug-ide19-0.4.12...

それでもエラーとなるので、下記もインストール。

C:project>gem install builder -v '2.1.2'
WARNING: builder-2.1.2 has an invalid nil value for @cert_chain
Successfully installed builder-2.1.2
1 gem installed
Installing ri documentation for builder-2.1.2...
Installing RDoc documentation for builder-2.1.2...

Excel VBA で別シートの最終行の値を取得する

2011年11月29日 Posted by PURGE

ワークシートの”Sheet2″ の値の存在する最終行のValue を取得する方法。
一度、シートの最終行を取得し、xlUpで戻るイメージ。

Sub getLastRowValue()
    Dim val As String

    val = Worksheets("Sheet2").Range("E" & Rows.Count).End(xlUp).Value

    MsgBox val

End Sub

uninitialized constant Rake::DSL エラー

2011年11月28日 Posted by PURGE

C:project>rake db:migrate
(in C:/project)
rake aborted!
uninitialized constant Rake::DSL

どうやらrake のバージョンが良ろしくないらしい。
gem list rake でバージョンを調べる。

C:worksWhoocus_R>gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.8.7)

で、プロジェクトのGemfile に下記を追記して、bundle install

gem "rake", "0.8.7"
C:project>bundle install
Fetching source index for http://rubygems.org/
You have requested:
  rake = 0.8.7
The bundle currently has rake locked at 0.9.2.2.
Try running `bundle update rake`

また怒られたので、bundle update rake

C:worksWhoocus_R>bundle update rake
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using multi_json (1.0.3)
Using activesupport (3.1.3)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.3)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.3)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.3)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.3)
Using activeresource (3.1.3)
Using ansi (1.4.1)
Using bundler (1.0.21)
Using coffee-script-source (1.1.3)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.2)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.3)
Using coffee-rails (3.1.1)
Using jquery-rails (1.0.19)
Using mysql2 (0.3.10)
Using rails (3.1.3)
Using sass (3.1.10)
Using sass-rails (3.1.5)
Using turn (0.8.2)
Using uglifier (1.1.0)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
C:project>rake db:migrate
==  CreateMembers: migrating ==================================================
-- create_table(:members)
   -> 0.3906s
==  CreateMembers: migrated (0.3906s) =========================================

うまく行ったようです。

Excel VBA 選択範囲のセルの数取得

2011年11月28日 Posted by PURGE

    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    rowcnt = Selection.Rows.Count

gem install mysql2 でエラー on WindowsXP

2011年11月26日 Posted by PURGE

先日のMac版でのエラーと同様に、gem install mysql2 でエラー発生。
Mac版と同様の現象であると思ったのだが、どうやら原因が別のようだ。

そもそも、mysql5.0 で試したのだが、とりあえず、mysql5.5にアップグレード。
その間、mysql5.5のインストーラが .NetFrameWork4 以上でしか動作しないとか、WindowsXP SP3 上でしか動作しないとかで、OSレベルでアップグレード。

で、ようやくスタート地点に立てたのだが、gem install mysql2 がうまく行かない。

結論としては、オプション引数の書き方がよろしくなかったようだ。
引数を渡す場合は、シングルクウォートとダブルクウォートとエスケープ(円)とスラッシュ(/)を、正しく記述すること。

C:RailsTest>gem install mysql2 -v '0.3.10' -- --with-mysql-dir="C:/usr/local/mysql
5.5/MySQL Server 5.5" 
--with-mysql-include="C:/usr/local/mysql5.5/MySQL Server 5.5/inclu
de" 
--with-mysql-lib="C:/usr/local/mysql5.5/MySQL Server 5.5/lib"

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

ちなみに、-v ‘0.3.10’ というバージョン指定しないと別のエラーになる。
原因はよく分からないのだが・・・。

gem install rails エラー

2011年11月26日 Posted by PURGE

Windows XP 環境でgem install railsが失敗した場合の対応。

C:>gem install rails
Fetching: activesupport-3.1.3.gem (100%)
Fetching: activemodel-3.1.3.gem (100%)
Fetching: actionpack-3.1.3.gem (100%)
Fetching: activerecord-3.1.3.gem (100%)
Fetching: activeresource-3.1.3.gem (100%)
Fetching: actionmailer-3.1.3.gem (100%)
ERROR:  Error installing rails:
        The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

DevKit を使いなさいとのこと。

Ruby Installer for Windowsのページで、DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe をダウンロードして、適当なフォルダに解凍する。
そして下記にて初期化&インストール。

C:DevKit>ruby dk.rb init

[INFO] found RubyInstaller v1.9.2 at C:/usr/local/ruby1.9.2

Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

C:usrlocalDevKit>ruby dk.rb install

[INFO] Updating convenience notice gem override for 'C:/usr/local/ruby1.9.2'
[INFO] Installing 'C:/usr/local/ruby1.9.2/lib/ruby/site_ruby/devkit.rb'

再度、rails をインストール。

C:usrlocalDevKit>gem install rails
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Fetching: rdoc-3.11.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Fetching: railties-3.1.3.gem (100%)
Fetching: rails-3.1.3.gem (100%)
Successfully installed json-1.6.1
Successfully installed rdoc-3.11
Successfully installed railties-3.1.3
Successfully installed rails-3.1.3
4 gems installed
Installing ri documentation for json-1.6.1...
Installing ri documentation for rdoc-3.11...
unable to convert U+00A9 from UTF-8 to Windows-31J for lib/rdoc/text.rb, skipping
unable to convert "xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J fo
r History.rdoc, skipping
Installing ri documentation for railties-3.1.3...
Installing ri documentation for rails-3.1.3...
Installing RDoc documentation for json-1.6.1...
Installing RDoc documentation for rdoc-3.11...
unable to convert U+00A9 from UTF-8 to Windows-31J for lib/rdoc/text.rb, skipping
unable to convert "xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J fo
r History.rdoc, skipping
Installing RDoc documentation for railties-3.1.3...
Installing RDoc documentation for rails-3.1.3...

gem install rails 成功。

gem install mysql2 でエラー on Mac

2011年11月23日 Posted by PURGE

gem install mysql2 でエラーが発生し、どうしてもインストールできない。エラーはどうやらインストールされている mysql のヘッダ等が読み込めないとのことなので、gem install オプションを付けた。
しかし、どうしてもうまくいかない。

$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib/ --with-mysqlclientlib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include/
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

        /Users/username/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib/ --with-mysqlclientlib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include/
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make
/usr/bin/gcc-4.2 -I. -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/mysql/include  -Os -g -fno-common -fno-strict-aliasing -arch i386 -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe -Wall -funroll-loops  -o client.o -c client.c
In file included from /Users/northvan/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/intern.h:29,
                 from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/ruby.h:1327,
                 from /Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
make: *** [client.o] Error 1


Gem files will remain installed in /Users/username/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.10 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.10/ext/mysql2/gem_make.out

で3日はまったところで、下記の記事を発見。

http://www.mountposition.co.jp/blog/?p=210

mysql 32bit版から、64bit版へ再インストール。

gem install mysql2 が動きました。

$ gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

でも、32bit版PCで、64bit版のmysqlが動くのかいな?という感じです。狐につままれた感じ。

gemが失敗する場合

2011年11月15日 Posted by PURGE

gemが失敗する場合は、プロキシの設定を疑った方がよい。大抵ブラウザの設定はできているが、コマンドラインで実行するgemの場合は、タイムアウトとなる。

c:>gem install rails
ERROR:  Could not find a valid gem 'rails' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: 
接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続できませんでした。
または接続済みのホストが応答しなかったため、確立された接続は失敗しました。
 - connect(2) (http://rubygems.org latest_specs.4.8.gz)

その場合は、環境変数に設定してから実行するとよい

c:>set http_proxy=http://proxy名:ポート番号