1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby GD2 がぜんぜん動きません!

Posted at

GD2 というグラフィックライブラリがありますが、PHPでは比較的ポピュラーなようです。
Ruby でも GD2 モジュールがあるので入れてみましたが、ぜんぜん動きません。
下のエラーは、Windows 7 + Ruby 2.0.x です。

C:\workspace\Scripts\Ruby\GD2>ruby canvas.rb c:/bin/ruby/lib/ruby/gems/2.0.0/gems/gd2-1.1.1/lib/gd2.rb:53: warning: else with out rescue is useless c:/bin/ruby/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:inrequire':
c:/bin/ruby/lib/ruby/gems/2.0.0/gems/gd2-1.1.1/lib/gd2.rb:46: syntax error, une
xpected ':', expecting keyword_then or ',' or ';' or '\n' (SyntaxError)
when ?D: 8
^
c:/bin/ruby/lib/ruby/gems/2.0.0/gems/gd2-1.1.1/lib/gd2.rb:180: syntax error, une
xpected keyword_end, expecting end-of-input
from c:/bin/ruby/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:
in rescue in require' from c:/bin/ruby/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:i n require'
from canvas.rb:4:in `'

C:\workspace\Scripts\Ruby\GD2>
`

もしかしたら、Linux じゃないとだめなのかと思って、Ubuntu 14.04LTS でやってみましたが、やはりダメです。

ubuntu@ip-172-31-11-130:~/workspace/ruby/GD2$ sudo gem install gd2 Fetching: gd2-1.1.1.gem (100%) Successfully installed gd2-1.1.1 1 gem installed Installing ri documentation for gd2-1.1.1... Installing RDoc documentation for gd2-1.1.1... ubuntu@ip-172-31-11-130:~/workspace/ruby/GD2$ vi test.rb ubuntu@ip-172-31-11-130:~/workspace/ruby/GD2$ ruby test.rb /var/lib/gems/1.9.1/gems/gd2-1.1.1/lib/gd2.rb:53: warning: else without rescue is useless /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:inrequire': /var/lib/gems/1.9.1/gems/gd2-1.1.1/lib/gd2.rb:46: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n' (SyntaxError)
when ?D: 8
^
/var/lib/gems/1.9.1/gems/gd2-1.1.1/lib/gd2.rb:180: syntax error, unexpected keyword_end, expecting $end
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in rescue in require' from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in require'
from test.rb:3:in <main>' ubuntu@ip-172-31-11-130:~/workspace/ruby/GD2$

テストプログラムの内容ですが、たったこれだけです。
`
#!/usr/bin/ruby

coding: utf-8

require 'gd2'
`

ググってみても情報があまりありませんね。
ただ、そのままではダメというのがありました。GD2 のコードをちょっといじったら起動したみたいですが、それでも警告が出てそのまま使うのは問題のようです。

1
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?