简体   繁体   中英

Why it's so slow to use `rails new`?

The version is:

bash-3.2$ rails -v
Rails 3.2.9

And my ruby is the built-in ruby on MacOSX:

bash-3.2$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
bash-3.2$ which ruby 
/usr/bin/ruby

My problem is that in the last step of rails new ( run bundle install ), it seems that rails need to connect the internet to download some packages. And usually I need 5 minutes just wait for rails to create any project using rails new .

I was wondering whether somethings is not configured well for rails on my computer.

Another strange thing is that after I finished rails new PROJECT_NAME , it shows:

Using sqlite3 (1.3.6)
Using uglifier (1.3.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

It seems that sqlite3 has already been installed, however, when I try:

bash-3.2$ bundle show sqlite3
 Could not locate Gemfile

It still complains that sqlite3 is not installed. Maybe that's the reason that rails new is slow (Even sqlite3 has been installed once. It still needs to download the bundle)

Before bundle install , rails asks for my system password:

Enter your password to install the bundled RubyGems to your system

But I'm still not sure whether these packages have been installed into system, as bundle show sqlite3 failed.

Does anyone have ideas about why rails new is so slow on my computer? Thanks!

Another solution is to use RVM . It is similar to rbenv. I personally use RVM. I don't and would not recommend using the gemsets. Bundler does the separation of gem versions anyway.

  1. Check what is up with your bundle install ie the last step in the rails new sequence. Run this instead:

rails new appname -B

The -B flag tells rails to "skip bundle" ( reference ). Then go into the app folder to run:

bundle install --verbose

Check for potential errors in the output.

  1. Using different bundler versions can give you different results. So try other versions .

gem uninstall bundler -v your-version-number

gem install bundler -v new-version-number

  1. In 2016, we got bundler v1.12.x which is causing some users to experience slow bundle install issues . In this case, using 1.11.2 is the faster option until they fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM