LoginSignup
0
1

More than 5 years have passed since last update.

rails newの際に `--skip-bundle` と `--webpack=xxx` は同時に指定できない

Posted at

TL;DR

  • rails new する時に --skip-bundle--webpack=react を同時に指定するとエラーになった
  • 現状は仕様みたい
  • newした後でGemfileに gem 'webpacker' を追加してbundleした後 ./bin/rails webpacker:install すればOK

rails newしたらエラーになった

reactを使った rails プロジェクトを作ろうと思って rails new を実行したらエラーになりました。

$ rails new -B --webpack=react sample
      create
      create  README.md
      create  Rakefile
(中略)
       rails  webpacker:install
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
       rails  webpacker:install:react
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

考えてみると gem 'webpacker' がインストールされてないので webpacker:install 出来ないですよね。

本家のgithubにもissueとして挙がってました。

解決策

単純ですが new時に --skip-bundle したい場合 new した後で手動でwebpackerを入れればOKです。

$ rails new -B PROJECT_NAME

$ cd PROJECT_NAME

# 以下のコマンド、もしくはエディタでGemfileに追加
$ echo "gem 'webpacker', '~> 2.0'" >> Gemfile

$ bundle install

$ ./bin/rails webpacker:install

# 今回はreactを入れたかったので以下を実行
$ ./bin/rails webpacker:install:react
0
1
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
0
1