0

The command that I'm trying to run is rails _3.2.13_ new App

When I run it in command line it creates a Rails app with version 3.2.13, but when I run it with system "rails _3.2.13_ new #{self.name} -T -B" it creates a Rails app with the latest version of Rails not 3.2.13 version.

robzdc
  • 312
  • 2
  • 12

1 Answers1

1

This is a result of Ruby using /bin/sh to execute shell commands, whereas you are probably using /bin/bash in Terminal on a daily basis. The way each is loaded and the specific configurations present in each will alter the configuration.

If you run which rails from both calls to system and in your terminal you'll likely see different paths. Check echo $PATH and you'll likely see different results too.

To resolve the situation, you can check out What's the difference between .bashrc, .bash_profile, and .environment? which will give you a much better understanding of what's going on, then adjust your shell configuration to accomodate.

coreyward
  • 77,547
  • 20
  • 137
  • 166
  • I ran `echo $PATH` in both and got the same result `/Users/xxxxx/.rvm/gems/ruby-2.3.3/bin:/Users/xxxxx/.rvm/gems/ruby-2.3.3@global/bin:/Users/xxxxx/.rvm/rubies/ruby-2.3.3/bin:/Users/xxxxx/.rvm/bin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin` – robzdc Jun 30 '17 at 22:00
  • I just found that when running `gem list --local` in terminal the gems are different than with `system()` – robzdc Jun 30 '17 at 22:09
  • @robzdc Sounds like you've got some different ENV vars then. – coreyward Jun 30 '17 at 22:29