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

"tdiary.rb:24:in `require': cannot load such file -- json (LoadError)" で起動しない #510

Closed
mfjt opened this Issue Sep 30, 2015 · 16 comments

Comments

Projects
None yet
5 participants
@mfjt

mfjt commented Sep 30, 2015

gem でインストールした tDiary の起動に失敗します。
バージョンさかのぼって確認しましたが、4.1.0 以降で発生しています。

% tdiary new tdiary
      create  tdiary
       :
       :
      create  tdiary/Gemfile.local
         run  bundle install --without test development from "./tdiary"
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Installing addressable 2.3.8
 :
 :
Installing therubyracer 0.12.2 with native extensions
Bundle complete! 24 Gemfile dependencies, 17 gems now installed.
Gems in the groups test and development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec tdiary htpasswd from "./tdiary"
Input your username/password
Username: hoge
New password:
Re-type new password:
install finished
run `tdiary server` in tdiary directory to start server

% cd tdiary
% bundle exec tdiary server
/home/hoge/.gem/ruby/gems/tdiary-4.2.0/lib/tdiary.rb:24:in `require': cannot load such file -- json (LoadError)
        from /home/hoge/.gem/ruby/gems/tdiary-4.2.0/lib/tdiary.rb:24:in `<top (required)>'
        from /home/hoge/.gem/ruby/gems/tdiary-4.2.0/lib/tdiary/cli.rb:102:in `require'
        from /home/hoge/.gem/ruby/gems/tdiary-4.2.0/lib/tdiary/cli.rb:102:in `server'
        from /home/hoge/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /home/hoge/.gem/ruby/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/hoge/.gem/ruby/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /home/hoge/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /home/hoge/.gem/ruby/gems/tdiary-4.2.0/bin/tdiary:7:in `<top (required)>'
        from /home/hoge/bin/tdiary:23:in `load'
        from /home/hoge/bin/tdiary:23:in `<main>'

環境は以下のような感じです。

% sudo yum list installed | grep ruby
ruby.x86_64                      2.0.0.598-25.el7_1                    @updates
ruby-devel.x86_64                2.0.0.598-25.el7_1                    @updates
ruby-irb.noarch                  2.0.0.598-25.el7_1                    @updates
ruby-libs.x86_64                 2.0.0.598-25.el7_1                    @updates
rubygem-bigdecimal.x86_64        1.2.0-25.el7_1                        @updates
rubygem-io-console.x86_64        0.4.2-25.el7_1                        @updates
rubygem-json.x86_64              1.7.7-25.el7_1                        @updates
rubygem-psych.x86_64             2.0.0-25.el7_1                        @updates
rubygem-rack.noarch              1:1.5.2-4.el7                         @epel
rubygem-rake.noarch              0.9.6-25.el7_1                        @updates
rubygem-rdoc.noarch              4.0.0-25.el7_1                        @updates
rubygems.noarch                  2.0.14-25.el7_1                       @updates

% ruby -v ; gem -v ; gem list
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
2.0.14

*** LOCAL GEMS ***

addressable (2.3.8)
bigdecimal (1.2.0)
bundler (1.10.6)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
execjs (2.6.0)
fastimage (1.7.0)
gemoji (2.1.0)
hikidoc (0.1.0)
io-console (0.4.2)
json (1.7.7)
libv8 (3.16.14.11 x86_64-linux)
mail (2.6.3)
mime-types (2.6.2)
psych (2.0.0)
rack (1.6.4, 1.5.2)
rake (0.9.6)
rdoc (4.0.0)
ref (2.0.0)
sprockets (3.3.5)
tdiary (4.2.0)
therubyracer (0.12.2)
thor (0.19.1)
@hsbt

This comment has been minimized.

Show comment
Hide comment
@hsbt

hsbt Sep 30, 2015

Member

ううむ、json は stdlib のはずなのでどこから require しても見つかるはずなんですが... 再現するか調べてみます。

Member

hsbt commented Sep 30, 2015

ううむ、json は stdlib のはずなのでどこから require しても見つかるはずなんですが... 再現するか調べてみます。

@tamoot

This comment has been minimized.

Show comment
Hide comment
@tamoot

tamoot Oct 1, 2015

Member

以下の2パターンの出力結果が気になります。

cd tdiary
bundle exec gem environment

gem environment
Member

tamoot commented Oct 1, 2015

以下の2パターンの出力結果が気になります。

cd tdiary
bundle exec gem environment

gem environment
@mfjt

This comment has been minimized.

Show comment
Hide comment
@mfjt

mfjt Oct 1, 2015

特に差はなかったです。

% pwd ; gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/hoge/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/hoge/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/hoge/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
% pwd ; bundle exec gem environment
/home/hoge/tdiary
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/hoge/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/hoge/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/hoge/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

mfjt commented Oct 1, 2015

特に差はなかったです。

% pwd ; gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/hoge/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/hoge/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/hoge/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
% pwd ; bundle exec gem environment
/home/hoge/tdiary
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/hoge/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/hoge/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/hoge/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
@tamoot

This comment has been minimized.

Show comment
Hide comment
@tamoot

tamoot Oct 8, 2015

Member
bundle exec ruby -rjson -e "p JSON.class"

ruby -rjson -e "p JSON.class"

も同じ出力になってるでしょうか?(あまり詳しくないのですが気になったので。。。

Member

tamoot commented Oct 8, 2015

bundle exec ruby -rjson -e "p JSON.class"

ruby -rjson -e "p JSON.class"

も同じ出力になってるでしょうか?(あまり詳しくないのですが気になったので。。。

@mfjt

This comment has been minimized.

Show comment
Hide comment
@mfjt

mfjt Oct 9, 2015

どちらも Module でした

mfjt commented Oct 9, 2015

どちらも Module でした

@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Nov 23, 2015

Member

rbenvでruby-2.0.0の環境を作ってみましたが、再現しませんでした。

$ rbenv install 2.0.0-p598
$ rbenv local 2.0.0-p598
$ ruby -v
ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-darwin15.2.0]
$ gem install tdiary
$ tdiary new d
$ cd d
$ bundle exec rackup
[2015-11-23 20:59:15] INFO  WEBrick 1.3.1
[2015-11-23 20:59:15] INFO  ruby 2.0.0 (2014-11-13) [x86_64-darwin15.2.0]
[2015-11-23 20:59:15] INFO  WEBrick::HTTPServer#start: pid=30653 port=9292
  • ruby -r 'json' -e "p JSON" を実行してもjsonの読み込みに失敗しますでしょうか
  • 「4.1.0 以降で発生」ということは、v4.0.5.1では正常に動いていますでしょうか
Member

machu commented Nov 23, 2015

rbenvでruby-2.0.0の環境を作ってみましたが、再現しませんでした。

$ rbenv install 2.0.0-p598
$ rbenv local 2.0.0-p598
$ ruby -v
ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-darwin15.2.0]
$ gem install tdiary
$ tdiary new d
$ cd d
$ bundle exec rackup
[2015-11-23 20:59:15] INFO  WEBrick 1.3.1
[2015-11-23 20:59:15] INFO  ruby 2.0.0 (2014-11-13) [x86_64-darwin15.2.0]
[2015-11-23 20:59:15] INFO  WEBrick::HTTPServer#start: pid=30653 port=9292
  • ruby -r 'json' -e "p JSON" を実行してもjsonの読み込みに失敗しますでしょうか
  • 「4.1.0 以降で発生」ということは、v4.0.5.1では正常に動いていますでしょうか
@tdtds

This comment has been minimized.

Show comment
Hide comment
@tdtds

tdtds Nov 24, 2015

Member

jsonがloadできない環境、ググってみるとぼちぼち見受けられるので、OS標準のrubyパッケージが腐っているとか、そういう話の可能性もありますねぇ。

Member

tdtds commented Nov 24, 2015

jsonがloadできない環境、ググってみるとぼちぼち見受けられるので、OS標準のrubyパッケージが腐っているとか、そういう話の可能性もありますねぇ。

@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Nov 24, 2015

Member

すみません。 ruby -rjson -e "p JSON.class" ではJSONライブラリを読めていましたね。

Member

machu commented Nov 24, 2015

すみません。 ruby -rjson -e "p JSON.class" ではJSONライブラリを読めていましたね。

@mfjt

This comment has been minimized.

Show comment
Hide comment
@mfjt

mfjt Nov 28, 2015

言葉足らずですいません。
4.0.5.1ではgemのインストールでこけてます。

% gem install tdiary -v 4.0.5.1
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: bundler-1.10.6.gem (100%)
Successfully installed bundler-1.10.6
Fetching: tdiary-4.0.5.1.gem (100%)
Successfully installed tdiary-4.0.5.1
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for bundler-1.10.6
Installing ri documentation for bundler-1.10.6
Parsing documentation for tdiary-4.0.5.1
Before reporting this, could you check that the file you're documenting
has proper syntax:

  /usr/bin/ruby -c ChangeLog

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

        (NoMethodError) undefined method `<' for nil:NilClass

ERROR:  While executing gem ... (NoMethodError)
    undefined method `<' for nil:NilClass

こちらでもrbenvだと問題いことは確認しており、また #514 のこともあるので、そろそろrbenvにせざるを得なさそうです。。

mfjt commented Nov 28, 2015

言葉足らずですいません。
4.0.5.1ではgemのインストールでこけてます。

% gem install tdiary -v 4.0.5.1
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: bundler-1.10.6.gem (100%)
Successfully installed bundler-1.10.6
Fetching: tdiary-4.0.5.1.gem (100%)
Successfully installed tdiary-4.0.5.1
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for bundler-1.10.6
Installing ri documentation for bundler-1.10.6
Parsing documentation for tdiary-4.0.5.1
Before reporting this, could you check that the file you're documenting
has proper syntax:

  /usr/bin/ruby -c ChangeLog

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

        (NoMethodError) undefined method `<' for nil:NilClass

ERROR:  While executing gem ... (NoMethodError)
    undefined method `<' for nil:NilClass

こちらでもrbenvだと問題いことは確認しており、また #514 のこともあるので、そろそろrbenvにせざるを得なさそうです。。

@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Nov 29, 2015

Member

CentOS 7.1で再現しました。

$ cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
$ sudo yum install ruby
$ sudo yum install git
$ git clone https://github.com/tdiary/tdiary-core.git
$ cd tdiary-core/
$ bundle --without development test coffee
$ bundle exec rackup
/home/vagrant/tdiary-core/lib/tdiary.rb:24:in `require': cannot load such file -- json (LoadError)
    from /home/vagrant/tdiary-core/lib/tdiary.rb:24:in `<top (required)>'

Bundlerから起動した場合に、jsonライブラリのロードに失敗します。

$ ruby -e "require 'json'; p JSON"
JSON
$ bundle exec ruby -e "require 'json'; p JSON"
-e:1:in `require': cannot load such file -- json (LoadError)
    from -e:1:in `<main>'
Member

machu commented Nov 29, 2015

CentOS 7.1で再現しました。

$ cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
$ sudo yum install ruby
$ sudo yum install git
$ git clone https://github.com/tdiary/tdiary-core.git
$ cd tdiary-core/
$ bundle --without development test coffee
$ bundle exec rackup
/home/vagrant/tdiary-core/lib/tdiary.rb:24:in `require': cannot load such file -- json (LoadError)
    from /home/vagrant/tdiary-core/lib/tdiary.rb:24:in `<top (required)>'

Bundlerから起動した場合に、jsonライブラリのロードに失敗します。

$ ruby -e "require 'json'; p JSON"
JSON
$ bundle exec ruby -e "require 'json'; p JSON"
-e:1:in `require': cannot load such file -- json (LoadError)
    from -e:1:in `<main>'
@hsbt

This comment has been minimized.

Show comment
Hide comment
@hsbt

hsbt Nov 29, 2015

Member

CentOS の ruby は ruby-json として分離してるからですかねえ...

Member

hsbt commented Nov 29, 2015

CentOS の ruby は ruby-json として分離してるからですかねえ...

@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Nov 29, 2015

Member

workaroundですが、最新のjsonライブラリをインストールし、Gemfile.localで明示的に指定することで動作しました。

$ sudo yum install ruby-devel
$ sudo yum install gcc
$ gem install json
Building native extensions.  This could take a while...
Successfully installed json-1.8.3
Parsing documentation for json-1.8.3
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for lib/json/ext/generator.so, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for lib/json/ext/parser.so, skipping
Installing ri documentation for json-1.8.3
1 gem installed
$ cat > Gemfile.local
gem 'json'
$ cp tdiary.conf.beginner tdiary.conf
$ bundle exec rackup
[2015-11-29 12:03:53] INFO  WEBrick 1.3.1
[2015-11-29 12:03:53] INFO  ruby 2.0.0 (2014-11-13) [x86_64-linux]
[2015-11-29 12:03:53] INFO  WEBrick::HTTPServer#start: pid=13166 port=9292
Member

machu commented Nov 29, 2015

workaroundですが、最新のjsonライブラリをインストールし、Gemfile.localで明示的に指定することで動作しました。

$ sudo yum install ruby-devel
$ sudo yum install gcc
$ gem install json
Building native extensions.  This could take a while...
Successfully installed json-1.8.3
Parsing documentation for json-1.8.3
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for lib/json/ext/generator.so, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for lib/json/ext/parser.so, skipping
Installing ri documentation for json-1.8.3
1 gem installed
$ cat > Gemfile.local
gem 'json'
$ cp tdiary.conf.beginner tdiary.conf
$ bundle exec rackup
[2015-11-29 12:03:53] INFO  WEBrick 1.3.1
[2015-11-29 12:03:53] INFO  ruby 2.0.0 (2014-11-13) [x86_64-linux]
[2015-11-29 12:03:53] INFO  WEBrick::HTTPServer#start: pid=13166 port=9292
@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Nov 29, 2015

Member

rubygem-jsonパッケージの問題なのか、rubygemsの問題なのか、bundlerの問題なのか、よく分からないんですよね…。

Member

machu commented Nov 29, 2015

rubygem-jsonパッケージの問題なのか、rubygemsの問題なのか、bundlerの問題なのか、よく分からないんですよね…。

@tdtds tdtds added this to the 4.2.1 milestone Dec 1, 2015

@tdtds

This comment has been minimized.

Show comment
Hide comment
@tdtds

tdtds Dec 25, 2015

Member

これどうしましょう? 回避するためのドキュメントだけ書いてcloseするとか?

Member

tdtds commented Dec 25, 2015

これどうしましょう? 回避するためのドキュメントだけ書いてcloseするとか?

@machu

This comment has been minimized.

Show comment
Hide comment
@machu

machu Dec 26, 2015

Member

ドキュメント書いてもいいですが、次バージョンでruby-2.0.0のサポートを終了するので今回だけになりそうですね。

Member

machu commented Dec 26, 2015

ドキュメント書いてもいいですが、次バージョンでruby-2.0.0のサポートを終了するので今回だけになりそうですね。

@tdtds

This comment has been minimized.

Show comment
Hide comment
@tdtds

tdtds Dec 28, 2015

Member

そっか……じゃあ申し訳ないがこのままにしておきます。回避策はあるのでここはcloseで。

Member

tdtds commented Dec 28, 2015

そっか……じゃあ申し訳ないがこのままにしておきます。回避策はあるのでここはcloseで。

@tdtds tdtds closed this Dec 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment