1
0

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.

LoadError: cannot load such file -- haml

Posted at

LoadError: cannot load such file -- hamlのエラーが出てかなり詰まったので、残しておきます。

実行環境

  • Ruby 2.5.1
  • Rails 5.2.3

実際に起きたエラー

rails aborted!
LoadError: cannot load such file -- haml
/Users/ユーザー名/mysite/koto_mono/config/application.rb:7:in `<top (required)>'
/Users/ユーザー名/mysite/koto_mono/Rakefile:4:in `<top (required)>'
/Users/ユーザー名/mysite/koto_mono/bin/rails:9:in `<top (required)>'
/Users/ユーザー名/mysite/koto_mono/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

とりあえず、bundle installしたが、直らず。。。

hamlのバージョンを確認。

$gem list haml
haml (default: 5.1.1, 5.0.4)

fileがないとのことなので、以下のコマンドでファイルが存在するかどうか確かめました。

find ~/.rbenv -type f | grep haml

すると、

/Users/ユーザー名/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/haml-5.0.4/.yardopts
/Users/ユーザー名/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/haml-5.0.4/REFERENCE.md
/Users/ユーザー名/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/haml-5.0.4/haml.gemspec
/Users/ユーザー名/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/haml-5.0.4/bin/haml
/Users/ユーザー名/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/haml-5.0.4/CHANGELOG.md
.
.
.
.

とたくさんコードが出てきますが、、、あれ?
5.0.4のファイルはあるのに、5.1.1のファイルがない!?

解決策

ということでhamlの5.1.1を入れ直します。

$ gem uninstall haml -v 1.14.3
$ gem install

これで rails sすると、エラーが消えました。

1
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?