Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

githubからcloneしたソースを利用してcgi環境で動作させるとInternal Server Error #321

Closed
tamoot opened this issue Jun 10, 2013 · 10 comments
Milestone

Comments

@tamoot
Copy link
Member

tamoot commented Jun 10, 2013

以下のような環境でInternal Server Errorとなりました。

  • Wiki記法
  • githubからcloneした tdiary-core を /home/tdiary/github/tdiary-core に配置
grep 3.2.2 /home/tdiary/github/tdiary-core/tdiary/version.rb
        VERSION = '3.2.2.20130604'
  • Apacheは以下のupdate.rb, index.rbを参照
head ~tdiary/public_html/sample/*.rb
==> /home/tdiary/public_html/ror_note/index.rb <==
#!/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
require '/home/tdiary/workspace/github/tdiary-core-official/index'

==> /home/tdiary/public_html/ror_note/update.rb <==
#!/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
require '/home/tdiary/workspace/github/tdiary-core-official/update'

出力されたbacktraceは以下の通りです。

cannot load such file -- bundler/setup (LoadError)

/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/environment.rb:6:in `<top (required)>'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/workspace/github/tdiary-core-official/tdiary.rb:26:in `<top (required)>'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/workspace/github/tdiary-core-official/index.rb:18:in `<top (required)>'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
index.rb:9:in `<main>'

以下で引っかかっていました。

  • tdiary-core/tdiary/environment.rb
  1 # -*- coding: utf-8 -*-
  2
  3 # Set up gems listed in the Gemfile.
  4 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
  5
  6 require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
  7
  8 if defined?(Bundler)
  9   env = [:default]
 10   env << :development if ENV['RACK_ENV'].nil? || ENV['RACK_ENV'].empty?
 11   env << ENV['RACK_ENV'].intern if ENV['RACK_ENV']
 12   env = env.reject{|e| Bundler.settings.without.include? e }
 13   Bundler.require *env
 14 end

6行目をコメントアウトすると次は以下のエラーでした。これはちょっと手強そうです。。

cannot load such file -- hikidoc (LoadError)

/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/style/wiki_style.rb:13:in `<top (required)>'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:44:in `block (2 levels) in load_styles'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:43:in `glob'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:43:in `block in load_styles'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:41:in `each'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:41:in `load_styles'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/io/base.rb:13:in `initialize'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/base.rb:24:in `new'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/base.rb:24:in `initialize'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/author_only_base.rb:10:in `initialize'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/admin.rb:8:in `initialize'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/admin.rb:27:in `initialize'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/dispatcher/update_main.rb:84:in `new'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/dispatcher/update_main.rb:84:in `create_tdiary'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/dispatcher/update_main.rb:19:in `run'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/dispatcher/update_main.rb:6:in `run'
/home/tdiary/workspace/github/tdiary-core-official/tdiary/dispatcher.rb:26:in `dispatch_cgi'
/home/tdiary/workspace/github/tdiary-core-official/update.rb:31:in `<top (required)>'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/home/tdiary/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
update.rb:8:in `<main>'

wiki_style.rb:13行目時点での$LOAD_PATHは以下のようになっていました。

/home/tdiary/workspace/github/tdiary-core-official/misc/lib
/home/tdiary/workspace/github/tdiary-core-official
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/i686-linux
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/vendor_ruby/2.0.0
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/vendor_ruby/2.0.0/i686-linux
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/vendor_ruby
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0
/home/tdiary/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/i686-linux
@tamoot
Copy link
Member Author

tamoot commented Jun 10, 2013

自己レスです。以下のコミット以降 vendor に hikidocが存在しないから、ですね。

1a81da3

@hsbt
Copy link
Member

hsbt commented Jun 10, 2013

これは bundler に準拠した使い方が何処にも書いていないというのが問題ですね... git clone した環境で tDiary を使うには gem install bundler; bundle install を実行する必要があります。なお、この方法でも CGI で動作させる場合は動かないという問題が現在はあります。ref #320

@machu
Copy link
Member

machu commented Jun 10, 2013

リリース時に想定していた手順(従来のvendorに配置していたライブラリを取得)を実施してもらうのではダメなのでしょうか。
純粋なCGI環境ではrackライブラリを使わないので、 #320 は発生しないと思っていました。

@machu
Copy link
Member

machu commented Jun 10, 2013

それはそうと、ドキュメントはちゃんと(僕が)書きます!

@tamoot
Copy link
Member Author

tamoot commented Jun 11, 2013

以下のように自分の中で整理してみました。

  • CGI環境では、bundle未導入、あるいは bundle installしていない場合、tdiary/environment.rbでエラーになってしまう(私はrvmを使っていたのでrvm-bundlerのせいか気づくことができませんでした。。今回たまたままっさらな環境を用意していました)
  • rubygemそのものやhikidoc等のgemを利用していないCGI環境ユーザ向けとして、次版リリース時にはドキュメントを作成する

ちなみにgem install hikidoc した後はCGI環境での動作を確認できました。

CGIの場合、rackの場合、と明に書き分けたドキュメントが必要と感じました。http://www.tdiary.org/20021110.html あたりでしょうか。

@machu
Copy link
Member

machu commented Jun 15, 2013

動作環境ごとのインストール手順(とりあえずメモ)です。

  • gem + rack: gem install tdiary && tdiary new mydiary
  • rack: bundle install && rackup
  • CGI: リリース版のtar.gzを展開 (bundle installは不要にする)
  • CGI + GitHub最新版: 以下参照

GitHubから最新版のtDiaryを取得し、CGI環境で動かす場合の手順。

$ gem install bundle
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
Fetching: bundle-0.0.1.gem (100%)
Successfully installed bundle-0.0.1
Parsing documentation for bundler-1.3.5
Installing ri documentation for bundler-1.3.5
Parsing documentation for bundle-0.0.1
Installing ri documentation for bundle-0.0.1
Done installing documentation for bundler, bundle (5 sec).
2 gems installed

$ git clone git@github.com:tdiary/tdiary-core.git

$ cd tdiary-core

$ bundle install --path vendor --gemfile Gemfile.cgi
Fetching gem metadata from https://rubygems.org/.........
Installing hikidoc (0.0.6)
Installing imagesize (0.1.1)
Installing rdtool (0.6.38)
Using bundler (1.3.5)
Your bundle is complete!
It was installed into ./vendor

@machu machu closed this as completed Jun 15, 2013
@tamoot
Copy link
Member Author

tamoot commented Jun 17, 2013

. @machu の手順を実行しましたが、tdiary/environment.rb にて以下のエラーが出ます。(元々のissueの通り)

cannot load such file -- bundler/setup (LoadError)
require 'bundler/setup'

をコメントアウトすることで動作はします。CGI + GitHub最新版という環境のために修正を入れるのもなんだかおかしいようにも思えます。。

@tamoot
Copy link
Member Author

tamoot commented Jun 17, 2013

手元の別環境だと上記は発生しなかったので、上記コメントは一旦忘れて下さい。失礼いたしました。

(rvmとrbenvの違いなのか何なのか・・・)

@hsbt
Copy link
Member

hsbt commented Jun 17, 2013

bundler をインストールしていないことが原因のように見えます

@tamoot
Copy link
Member Author

tamoot commented Jun 18, 2013

@hsbt 指摘ありがとうございます。bundler未インストールのためでした。gem listだと bundler出てきますが(これはこれで理由が判っていない)、実際のところはインストールされていませんでした。

LANG=C ls -l `rvm gemdir`/gems
total 16
drwxrwxr-x 5 tdiary tdiary 4096 Jun 11 09:13 hikidoc-0.0.6/
drwxr-xr-x 3 tdiary tdiary 4096 Jun 10 12:17 rake-0.9.6/
drwxr-xr-x 3 tdiary tdiary 4096 Jun 10 12:17 rdoc-4.0.0/
drwxr-xr-x 3 tdiary tdiary 4096 Jun 10 12:17 test-unit-2.0.0.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants