I'm trying to make a new rails application with a intent not to install gems as system gem as possible. At first I installed bundler as system gem, made a Gemfile which specified only rails and executed 'bundle install'. (In my opinion, bundler is OK to be a system gem...)
mkdir -p /opt/rails/rails_app
cd /opt/rails/rails_app
gem install bundler
bundle init
cp Gemfile /tmp
sed 's/#gem rails/gem rails/' /tmp/Gemfile > Gemfile
bundle config build.nokogiri --use-system-libraries
bundle install --path vendor/bundle
Rails was installed as a 'local gem' which is limitted within /opt/rails/rails_app.
Then I tried to make a rails application by 'rails new'.
bundle exec rails new . --skip-bundle
This caused replacing the Gemfile, so a message was shown like this.
Overwrite /opt/rails/rails_app/Gemfile? (enter "h" for help) [Ynaqdh]
Usually what should be done is only type 'y'. However, this time, I want to do that automatically for making a vagrant's provision script.
So I tried expect but it never worked. All results were either timeout or syntax error:
expect -c "
spawn bundle exec rails new . --skip-bundle --quiet
expect \"Overwrite /opt/rails/rails_app/Gemfile? (enter \"h\" for help) \[Ynaqdh\] \"
send \"y\r\"
"
I couldn't find where is wrong in this code and other solutions than using expect.