[#49536] コマンドラインで ruby の変数に値を設定する方法 — 尾川敏也 <ogw@...>

尾川と申します。

31 messages 2013/08/09
[#49537] Re: コマンドラインで ruby の変数に値を設定する方法 — 古川大輔 <mogya99@...> 2013/08/09

>スクリプト名に続く, `-'で始まる引数を解釈して, 同名のグローバル変数に値 を設定します。

[#49538] Re: コマンドラインで ruby の変数に値を設定する方法 — 尾川敏也 <ogw@...> 2013/08/11

尾川です。

[#49539] Re: コマンドラインで ruby の変数に値を設定する方法 — Nobuyoshi Nakada <nobu@...> 2013/08/11

(13/08/11 11:14), 尾川敏也 wrote:

[#49596] シェルスクリプトの Ruby での置き換え (was Re: コマンドラインで ruby の変数に値を設定する方法) — 尾川敏也 <ogw@...> 2013/09/21

尾川と申します。おはようございます。

[#49598] IO.popen に不具合? — 尾川敏也 <ogw@...> 2013/09/24

たびたびお騒がせします。尾川と申します。

[#49611] IO.popen の不審な挙動を再現するサンプルコード — 尾川敏也 <ogw@...> 2013/09/28

尾川です。

[ruby-list:49519] OSX ruby-tkのextconf.rb

From: 天野 竜太郎 <pikara-giresse82@...>
Date: 2013-08-01 06:40:50 UTC
List: ruby-list #49519
天野といいます。

環境は、OSX 10.8.4、XCode 4.6.3 ActiveTcl8.5.14
OSデフォルトとして、tcltk8.5.9がインストールされています。

最近こちらで、OSX10.8で、ruby-tkがインストールできない、できても落ちるという話が出ました。brewやmac portsなどを利用しての話のようでしたが、当方は、ソースからのインストールでうまくいきませんでした。

ruby-2.0.0-p247および1.9.3-p448では、

./configure --enable-shared --enable-pthread
make
で、

check struct members..
check libraries....
Use ActiveTcl libraries (if available).
Search tclConfig.sh and tkConfig.sh.wrong number of arguments (2 for 1)
Failed to configure tk. It will not be installed.
configuring tk/tkutil
Failed to configure tk/tkutil. It will not be installed.
となります。

以前はこうなりませんでした。
ずいぶん前のソースになりますが、たとえば1.9.2-p320だと、
make
make install
問題なく終わり、ruby-tkも動きます。

tk/extconf.rbを比べると
308行目から

1.9.2が

  paths = [
    #"~/Library/Frameworks",
    "/Library/Frameworks",
    "/Network/Library/Frameworks", "/System/Library/Frameworks"
  ]
  paths.reverse! unless TkLib_Config["ActiveTcl"] # system has higher priority

  paths.map{|dir| dir.strip.chomp('/')}.each{|dir|
    next unless File.directory?(tcldir = File.join(dir, "Tcl.framework"))
    next unless File.directory?(tkdir  = File.join(dir, "Tk.framework"))
    TkLib_Config["tcltk-framework"] = dir
    return [tcldir, tkdir]
  }

1.9.3-p448が

  paths = [
    #"~/Library/Frameworks",
    "/Library/Frameworks",
    "/Network/Library/Frameworks", "/System/Library/Frameworks"
  ]
  paths.reverse! unless TkLib_Config["ActiveTcl"] # system has higher priority

  paths.map{|dir| dir.strip.chomp('/')}.each{|dir|
    next unless File.exist?(File.join(dir, "Tcl.framework", "Headers"))
    next unless File.directory?(tcldir = File.join(dir, "Tcl.framework"))
    next unless File.exist?(File.join(dir, "Tk.framework"), "Headers")
    next unless File.directory?(tkdir  = File.join(dir, "Tk.framework"))
    TkLib_Config["tcltk-framework"] = dir
    return [tcldir, tkdir]
  }


next unless File.exist?(File.join(dir, "Tcl.framework", "Headers"))
next unless File.exist?(File.join(dir, "Tk.framework"), "Headers")
を削除すると
makeは通りますが、
インストール後、
require "tk"で落ちます(ruby-2.0.0-p247および1.9.3-p448どちらも同じ)。

rb(main):001:0> require "tk"
objc[19535]: Class TKApplication is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[19535]: Class TKMenu is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[19535]: Class TKContentView is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[19535]: Class TKWindow is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
RuntimeError: tcltklib: fail to Tk_Init(). Can't find a usable tk.tcl in the following directories: 
    /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts

/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl: version conflict for package "Tk": have 8.5.14, need exactly 8.5.9
version conflict for package "Tk": have 8.5.14, need exactly 8.5.9
    while executing
"package require -exact Tk  8.5.9"
    (file "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl" line 20)
    invoked from within
"source /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $file]"


This probably means that tk wasn't installed properly.

	from /Users/ryutaro/ru2/lib/ruby/2.0.0/tk.rb:31:in `initialize'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/tk.rb:31:in `initialize'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/tk.rb:1238:in `new'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/tk.rb:1238:in `<module:TkCore>'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/tk.rb:1152:in `<top (required)>'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
	from /Users/ryutaro/ru2/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
	from (irb):1
	from ru2/bin/irb:12:in `<main>'
irb(main):002:0> 

extconf.rbをruby-1.9.2-p320のものと取り替えると、makeは問題なく、
インストール後のruby-tkの動作も問題ないようです。(ActiveTcl8.5.14の方とくっついて、demo-jp/widgetも普通に動いています。ruby-2.0.0-p247および1.9.3-p448どちらも動作しています。)

Ryutaro Amano

pikara-giresse82@mb.pikara.ne.jp

In This Thread

Prev Next