2
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 1 year has passed since last update.

rails 6のアプリをgit clone後に遭遇したエラー

Last updated at Posted at 2022-01-08

rails6 git clone後の手順

やりたいこと・背景

  • 実装途中のrails6のアプリをgit cloneしたい
  • 間違えて、ローカルのリポジトリを消してしまった際にそんなこと滅多にないgithubにpushしていればなんとかなる
  • 昔作っていたrails6のアプリ実装を再開したい
  • などなど

ざっくり手順

1. Githubでgit cloneしたいリポジトリをコピー

terminal.
$ git clone クローンしたいリポジトリのurl

2. rm -rf Gemfile.lockでgemのバージョン依存関係をなくす

git cloneしてきたrailsのアプリは、gemのバージョンの依存関係が固定されてしまっているため。
そのまま、bundle installするとエラーが出る。

cd アプリ名
で、railsアプリのディレクトリに移動した後

terminal.
$ rm -rf Gemfile.lock

私は、bundlerでアプリごとに環境指定しているので、bundle install --path vendor/bundleとしていますが、bundle installでも問題ないです。

terminal.
$ bundle install --path vendor/bundle
terminal.
$ rails db:migrate

エラーです少数の方は出ます

terminal.
/Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/ext/libsass.bundle': dlopen(/Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/ext/libsass.bundle, 0x0005): tried: '/Users/○○/○○/○○/○○/○○/bundle/ruby/2.6.0/gems/sassc-2.4.0/ext/libsass.bundle' (no such file), '/usr/local/lib/libsass.bundle' (no such file), '/usr/lib/libsass.bundle' (no such file) (LoadError)
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:99:in `map'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:99:in `ffi_lib'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:13:in `rescue in <module:Native>'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:10:in `<module:Native>'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:6:in `<module:SassC>'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:5:in `<main>'
	from /Users/○○/○○/○○/○○/○○/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
...
省略
...

rails db:migrate後に上記のようなエラーが出た方は、以下のように対応してください。

Gemfile.
gem "sassc", "< 2.2.0"     追記

優秀な先輩エンジニアが教えてくれていました

Also fails for me on CentOS 7 + Ruby 2.5. However unlike what was reported by OP, Jekyll 4.0 doesn't seem to require sassc 2.2.0. Just adding gem "sassc", "< 2.2.0" to my Gemfile worked around the bug successfully.

When installing the extension from 2.1.0, libsass.so is at ~/.gem/ruby/2.5.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/libsass.so. When building it from 2.2.0, it is at ~/.gem/ruby/2.5.0/gems/sassc-2.2.0/ext/libsass.so.

再度

terminal.
$ bundle install

エラー

terminal.
You have requested:
  sassc < 2.2.0

The bundle currently has sassc locked at 2.4.0.
Try running `bundle update sassc`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

素直にbundle update sassc

terminal.
$ bundle update sassc

以下のような出来たメッセージ出たらok

terminal.
...
Installing sassc 2.1.0 (was 2.4.0) with native extensions
Using sassc-rails 2.1.2
Using sass-rails 6.0.0
Note: sassc version regressed from 2.4.0 to 2.1.0
Bundle updated!

3. rails db:migrate

terminal.
$ rails db:migrate

4. rails sで立ち上げよう

terminal.
$ rails s

5. Webpacker::Manifest::MissingEntryError in Homes#topエラー

terminal.
ActionView::Template::Error (Webpacker can't find application.js in /Users/yade/pg/dmm/review/meshiterro/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
     7:     <%= csp_meta_tag %>
     8:
     9:     <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    10:     <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
    11:   </head>
    12:
    13:   <body>

app/views/layouts/application.html.erb:10

これはrails6で必要なwebpackerなどがないので以下実行

詳しくは、先輩エンジニアの方を参考にしてください。

terminal.
$ rails webpacker:install
$ rails webpacker:compile
terminal.
$ rails s

終わりです。

最後まで読んでいただきありがとうございました。独学でやっているので、情報不足や分かりづらい点がございましたら、コメントしていただければ幸いです。
少しでもお役に立てたら、幸いです。

2
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
2
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?