Kinopyo Blog

プログラマとしてRuby, Rails, iPhone, iPad,Macなどなどと向き合う日々のログポース

Posts Tagged ‘環境構築’

Ruby 1.9.3-p0 をRVMでインストール

2011年11月02日

インストール

rvm get head
rvm reload
rvm install 1.9.3-p0
rvm use 1.9.3
view raw gistfile1.sh This Gist brought to you by GitHub.

リリースノート

http://www.ruby-lang.org/ja/news/2011/10/31/ruby-1-9-3-p0-is-released/

速度

結構速くなったらしいです。

この記事を参考:http://stjhimy.com/posts/24-ruby-1-9-3-freaking-fast-bro

RVMの更新、Ruby 1.9.2p290の更新

2011年08月19日

ruby 1.9.2p290へ更新しました。rvmもついでに。

# update rvm
$ rvm get head
# or older versions such as 1.0.0
$ rvm update --head
# you need to run reload to reflect the update
$ rvm reload
$ rvm -v
  rvm 1.7.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]

# install ruby 1.9.2.p290
$ rvm install 1.9.2-p290
  ...
$ rvm list
  ruby-1.9.2-p0
  ruby-1.9.2-p180
# you need to replace the p0 based on your environment
$ rvm upgrade ruby-1.9.2-p0 ruby-1.9.2-p290
yes
yes
yes ...
Upgrade complete!
$ rvm list
  ruby-1.9.2-p290 [ x86_64 ]
$ rvm --default use 1.9.2
$ ruby -v
  ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

TextMateをLionのフルスクリーンに

2011年08月16日
git clone https://github.com/enormego/EGOTextMateFullScreen.git /tmp/EGOTextMateFullScreen

xcodebuild -project /tmp/EGOTextMateFullScreen/EGOTextMateFullScreen.xcodeproj -target EGOTextMateFullScreen

cp -R /tmp/EGOTextMateFullScreen/build/Release/EGOTextMateFullScreen.tmplugin ~/Library/Application\ Support/TextMate/PlugIns

# after installed
rm -rf /tmp/EGOTextMateFullScreen/

これが完成図!

coffee-scriptのインストール、TextMate Bundleで実行(Mac OS X)

2011年07月04日

coffee-scriptをMacportsを使ってインストールし、TextMateのcoffee-script bundleでコンパイルするメモです。

注意すべきなのはたとえターミナルでcoffeeが実行できても、TextMateはPATHをインクルードしないので(インクルードしているのは/usr/binらしい)、/usr/binにcoffeeのシンボリックを作る必要があります。

またcoffee-scriptをコンパイルするにはnodejsとnpm(Node Package Manager)が前提条件となるため、それらのインストールも必要です。

# don't forget to update your port tree first
sudo port selfupdate

# install coffee script using macport
sudo port install nodejs
node -v

# install npm - the Node Package Manager
git clone http://github.com/isaacs/npm.git
cd npm
sudo make install
npm -v

# now install coffee-script!
sudo npm install -g coffee-script
coffee -v

# because TextMate doesn't inherit your regular PATH
# you need to set a symbol link to /usr/bin
# so that you can run coffee in your textmate

which node
/opt/local/bin/node

which coffee
/opt/local/bin/coffee

cd /usr/bin
sudo ln -s /opt/local/bin/node
sudo ln -s /opt/local/bin/coffee

# install textmate coffee-script bundle
mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript.tmbundle

# now you can use command + B to compile and display javascript in your textmate!

これでtextmateでcommand + Bでコンパイル後のJavascriptが表示できるようになります!

Macのrubyで、no such file to load — ubygems (LoadError)

2011年05月23日

Sinatraを試したところこのようなエラーになりました。

ruby -rubygems myapp.rb
no such file to load -- ubygems (LoadError)

ググッてみたらやはりPATHが間違ったっぽいです。

Macportでrubygemsをインストールすることで解決できるそうです。

その後はgemを再度インストールする必要があるらしいです。

操作の流れ:

#パスの確認
which gem
/usr/bin/gem

sudo port install rb-rubygems
...
# Terminal再起動
# パスの確認
which gem
/opt/local/bin/gem

sudo gem install sinatra

一旦はこれで解決です。

参考になったサイト:

Macでrubygemsのrequireエラーが発生する件 – holyppの日記

Macのrubyで、require 'rubygems'ができなかったので対処 – Kuna の逆行列

PHP: mysqlnd cannot connect to MySQL 4.1+ using old authentication

2011年03月17日

問題

新しい mysqlnd ライブラリは、MySQL 4.1 用の41バイトの新しいパスワードフォーマットを使用します。 古い16バイトのパスワードを使うと、mysql_connect() 系の関数は次のようなエラーメッセージを生成します。”mysqlnd cannot connect to MySQL 4.1+ using old authentication”

http://www.php.net/manual/ja/migration53.incompatible.php

MacPortでインストールしたPHP5.3では、

mysqlnd(php5.3のmysql native client)が適用される。

しかし、CentOSなどのyumでインストールできるMySQLサーバーとの相性がよろしくない。

PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using old authentication

というエラーが現れ、接続することができません。

mysqlndを利用しないよう再コンパイルが必要となる。

http://taikimen.blogspot.com/2010/10/snowleopard-php53mysql.html

解決方法

portでインストールしたモジュールを確認、mysqlndがactiveなってるはず。

sudo port installed

php5-mysql @5.3.5_0+mysqlnd (active)

そしてmysql5のvariantsを指定で再インストール。

% sudo port install php5-mysql +mysql5
--->  Computing dependencies for php5-mysql
--->  Fetching php5-mysql
--->  Verifying checksum(s) for php5-mysql
--->  Extracting php5-mysql
--->  Configuring php5-mysql
--->  Building php5-mysql
--->  Staging php5-mysql into destroot
--->  Installing php5-mysql @5.3.5_0+mysql5
--->  Deactivating php5-mysql @5.3.5_0+mysqlnd
--->  Cleaning php5-mysql
--->  Activating php5-mysql @5.3.5_0+mysql5
--->  Cleaning php5-mysql

再度port installedで確認すればmysql5がactiveになるはず。これで解決。

php5-mysql @5.3.5_0+mysqlnd
php5-mysql @5.3.5_0+mysql5 (active)

参考

【php】mysqlndを使うとMySQLに接続できない

http://www.softel.co.jp/blogs/tech/archives/2225

SnowLeopard + PHP5.3でのMySQLリモート接続

http://taikimen.blogspot.com/2010/10/snowleopard-php53mysql.html

PHP: mysqlnd cannot connect to MySQL 4.1+ using old authentication

http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx

おまけ

mysqlが古い16バイトのパスワードを使ってるかを確認する方法です。

mysqlにログインして下記コマンドを実行:

mysql> select password('aa');

+------------------+
| password('aa')         |
+------------------+
| 0123456789abcdef |
+------------------+

16位だっだら古いです。40位なら新しいってことです。

CakePHP, and Strict Standards

MacportでPHPをインストールし、CakePHPを動かしたら「Strict Standards」エラーが出ました。

当時のエラー本文は残ってませんので、Googleで検索したエラー本文を貼り付けます。パス以外は同じのはずです。

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/basics.php on line 279
Strict Standards: Redefining already defined constructor for class Object in /Applications/MAMP/htdocs/xxxx/cake/libs/object.php on line 65
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/object.php on line 92
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/inflector.php on line 65
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/configure.php on line 96
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/configure.php on line 154
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/cache.php on line 71
Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/cache.php on line 157
Strict Standards: Non-static method Configure::getInstance() should not be called statically in /Applications/MAMP/htdocs/xxxx/cake/bootstrap.php on li

解決方法

これはCakePHPの問題ではなく、PHPのerror_reportingの設定問題だそうです。

php.iniを開いてerror_reportingで検索します。

値をE_ALLに変更すれば解決です。

ちなみにMacportでPHPをインストールしたときのphp.iniパスは/opt/local/etc/php5/php.iniになります。

参考リンク

http://oldblog.awpny.com/2007/12/mamp-php5-cakephp-and-strict-standards/

Error installing rails bundler requires RubyGems version >= 1.3.6

2011年03月07日

sudo gem install railsでこんなエラーが出ちゃいました。

Error installing rails bundler requires RubyGems version >= 1.3.6

解決策は

sudo gem update --system

pdating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.6.1
Updating RubyGems to 1.6.1
Installing RubyGems 1.6.1
RubyGems 1.6.1 installed

=== 1.6.1 / 2011-03-03

Bug Fixes:

* Installation no longer fails when a dependency from a version that won't be
  installed is unsatisfied.
* README.rdoc now shows how to file tickets and get help.  Pull Request #40 by
  Aaron Patterson.
* Gem files are cached correctly again.  Patch #29051 by Mamoru Tasaka.
* Tests now pass with non-022 umask.  Patch #29050 by Mamoru Tasaka.

------------------------------------------------------------------------------

RubyGems installed the following executables:
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

を実行した後にsudo gem install railsでrailsをインストールすればOKです。

Windows XAMPPにOracle Instantclientをインストール

2011年02月18日

Oracle Instantclientをインストールすることで、PHPからOracleデータベースへの接続が可能になります。

XAMPPのデフォルトインストールではそれが無効となっています。確認方法はphpinfoのページから’oci8′を検索して何もなかったらつまり接続できてないことです。

手順

  • php.ini(XAMPP/phpのパスにある)の中から;extension=php_oci8.dllを検索して、セミコロン(;)を削除。
  • Oracleから“Instant Client Package – Basic” for Windowsをダウンロードし、任意の場所に解凍。ここではc:\instantclient_11_1とする。
  • Windowsの環境変数pathに上記instantclientが解凍されたパスを追加(c:\instantclient_11_1)
  • そしてWindowsを再起動!
  • Apacheを再起動


確認

phpinfoのページからoci8を検索してあれば成功!


その他

  • ORACLE_HOMEやORACLE_SIDなどの環境変数はInstant Clientでは必要ないから設定しなくても大丈夫だそう。
  • パス設定後Windowsを再起動しないと、”unable to load dynamic library php_oci8.dll”のようなエラーが出た。

[更新]MacでRuby on Rails開発:環境構築から

2010年11月29日

MacにはデフォルトでRubyが入ってそうです。

ターミナルを開いてrails -vを叩いたらバージョン情報が出てきました。

ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]

そしてRubyだけじゃなくRailsも入ってましてびっくりしました。

すごいですねMacは。。。

て、railsのバージョンもrails -vで確認できますが、

デフォルトのバージョンは古いそうで下記のコマンドでアップグレードできます。

sudo gem update rails

するとこんなログ情報が出ます。

Updating installed gems
Updating rails
WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
	  /usr/bin aren't both writable.
WARNING:  You don't have /Users/zolo/.gem/ruby/1.8/bin in your PATH,
	  gem executables will not run.
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.0
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
Gems updated: activesupport, activerecord, rack, actionpack, actionmailer, activeresource, rails
Installing ri documentation for activesupport-2.3.8...
Installing ri documentation for activerecord-2.3.8...
Installing ri documentation for rack-1.1.0...
Installing ri documentation for actionpack-2.3.8...
Installing ri documentation for actionmailer-2.3.8...
Installing ri documentation for activeresource-2.3.8...
Installing ri documentation for rails-2.3.8...
Installing RDoc documentation for activesupport-2.3.8...
Installing RDoc documentation for activerecord-2.3.8...
Installing RDoc documentation for rack-1.1.0...
Installing RDoc documentation for actionpack-2.3.8...
Installing RDoc documentation for actionmailer-2.3.8...
Installing RDoc documentation for activeresource-2.3.8...
Installing RDoc documentation for rails-2.3.8...

多少時間がかかります。

これでMacでのRuby開発の準備は完了です。

更新

gem update railsにsudoを付けないとこんなエラーが出るかも


WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
	  /usr/bin aren't both writable.
WARNING:  You don't have /Users/paku-k/.gem/ruby/1.8/bin in your PATH,
	  gem executables will not run.
ERROR:  Error installing rails:
	bundler requires RubyGems version >= 1.3.6